-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rmf_cat: check mismatched structure/static frame
Check all the input files passed to rmf_cat to make sure that they have the same structure and static frame, and exit with an error if they don't. Add a --force option to allow the user to override this check if desired. Closes #128.
- Loading branch information
Showing
3 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import unittest | ||
import os | ||
import RMF | ||
import subprocess | ||
|
||
|
||
class Tests(unittest.TestCase): | ||
|
||
def test_help(self): | ||
"""Test rmf_cat --help""" | ||
p = subprocess.Popen(['rmf_cat', '--help'], stdin=subprocess.PIPE, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
universal_newlines=True) | ||
out, err = p.communicate() | ||
self.assertEqual(out, "") | ||
self.assertIn("Combine two or more rmf files", err) | ||
self.assertEqual(p.returncode, 1) | ||
|
||
def test_version(self): | ||
"""Test rmf_cat --version""" | ||
p = subprocess.Popen(['rmf_cat', '--version'], stdin=subprocess.PIPE, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
universal_newlines=True) | ||
out, err = p.communicate() | ||
self.assertEqual(err, "") | ||
self.assertIn("RMF version", out) | ||
self.assertEqual(p.returncode, 0) | ||
|
||
def test_cat_mismatch(self): | ||
"""Test rmf_cat of mismatched files""" | ||
p = subprocess.Popen( | ||
['rmf_cat', RMF._get_test_input_file_path("simple.rmf"), | ||
RMF._get_test_input_file_path("rep_and_geom.rmf"), | ||
'test_cat_mismatch.rmf'], | ||
stdin=subprocess.PIPE, stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, universal_newlines=True) | ||
out, err = p.communicate() | ||
self.assertIn("have different structure", err) | ||
self.assertEqual(p.returncode, 1) | ||
|
||
def test_cat_ok(self): | ||
"""Test rmf_cat of similar files""" | ||
p = subprocess.Popen( | ||
['rmf_cat', RMF._get_test_input_file_path("simple.rmf"), | ||
RMF._get_test_input_file_path("simple-new.rmf"), | ||
'test_cat_ok.rmf'], | ||
stdin=subprocess.PIPE, stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, universal_newlines=True) | ||
out, err = p.communicate() | ||
self.assertEqual(out, "") | ||
self.assertEqual(err, "") | ||
self.assertEqual(p.returncode, 0) | ||
os.unlink('test_cat_ok.rmf') | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |