-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SCSB-174] move DMS requirement <-> test correlations from `@metrics_…
…logger` decorators to `romanisim/tests/dms_requirement_tests.json` (#146) * add `test_requirements.json` to repository to track requirements * remove usage of `metrics_logger` * add test checking if tests exist in source code * use pytest to obtain loaded tests * `test_requirements.json` -> `romanisim/tests/dms_requirement_tests.json` * reword assertion error message * scan source directory instead of using pytest * remove cython-generated file that slipped in
- Loading branch information
1 parent
44ed46d
commit ff0fb51
Showing
9 changed files
with
97 additions
and
24 deletions.
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,63 @@ | ||
{ | ||
"DMS214": [ | ||
"romanisim.tests.test_image.test_image_rendering" | ||
], | ||
"DMS215": [ | ||
"romanisim.tests.test_image.test_image_rendering" | ||
], | ||
"DMS216": [ | ||
"romanisim.tests.test_image.test_simulate" | ||
], | ||
"DMS217": [ | ||
"romanisim.tests.test_catalog.test_table_catalog" | ||
], | ||
"DMS218": [ | ||
"romanisim.tests.test_image.test_add_objects", | ||
"romanisim.tests.test_image.test_simulate" | ||
], | ||
"DMS219": [ | ||
"romanisim.tests.test_l3.test_sim_mosaic" | ||
], | ||
"DMS220": [ | ||
"romanisim.tests.test_l1.test_apportion_counts_to_resultants" | ||
], | ||
"DMS221": [ | ||
"romanisim.tests.test_image.test_simulate" | ||
], | ||
"DMS222": [ | ||
"romanisim.tests.test_l1.test_linearized_counts_to_resultants" | ||
], | ||
"DMS223": [ | ||
"romanisim.tests.test_l1.test_apportion_counts_to_resultants" | ||
], | ||
"DMS224": [ | ||
"romanisim.tests.test_image.test_simulate" | ||
], | ||
"DMS225": [ | ||
"romanisim.tests.test_l1.test_inject_source_into_ramp" | ||
], | ||
"DMS226": [ | ||
"romanisim.tests.test_l1.test_ipc" | ||
], | ||
"DMS227": [ | ||
"romanisim.tests.test_l1.test_make_l1_and_asdf" | ||
], | ||
"DMS228": [ | ||
"romanisim.tests.test_image.test_image_input" | ||
], | ||
"DMS229": [ | ||
"romanisim.tests.test_l1.test_apportion_counts_to_resultants" | ||
], | ||
"DMS230": [ | ||
"romanisim.tests.test_image.test_simulate_counts_generic" | ||
], | ||
"DMS231": [ | ||
"romanisim.tests.test_image.test_inject_source_into_image" | ||
], | ||
"DMS232": [ | ||
"romanisim.tests.test_l3.test_inject_sources_into_mosaic" | ||
], | ||
"DMS233": [ | ||
"romanisim.tests.test_bandpass.test_convert_flux_to_counts" | ||
] | ||
} |
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,34 @@ | ||
import json | ||
import re | ||
from pathlib import Path | ||
|
||
TEST_DIRECTORY = Path(__file__).parent.parent | ||
TEST_REQUIREMENTS_FILENAME = Path(__file__).parent / "dms_requirement_tests.json" | ||
|
||
|
||
def test_requirements(): | ||
test_requirements_filename = TEST_REQUIREMENTS_FILENAME.expanduser().absolute() | ||
test_directory = TEST_DIRECTORY.expanduser().absolute() | ||
|
||
with open(test_requirements_filename) as test_requirements_file: | ||
requirements = json.load(test_requirements_file) | ||
|
||
required_tests = { | ||
test | ||
for requirement_tests in requirements.values() | ||
for test in requirement_tests | ||
} | ||
|
||
existing_tests = set() | ||
test_regex = re.compile(r"def (test_[^\(]+)\(.*\):") | ||
for test_filename in test_directory.glob("**/test_*.py"): | ||
with open(test_filename) as test_file: | ||
test_file_contents = test_file.read() | ||
|
||
for match in re.finditer(test_regex, test_file_contents): | ||
test = f"{test_directory.stem}.{str(test_filename.relative_to(test_directory).parent).replace('/', '.')}.{test_filename.stem}.{match.group(1)}" | ||
if test in required_tests: | ||
existing_tests.add(test) | ||
|
||
missing_tests = required_tests - existing_tests | ||
assert not missing_tests, f"could not find the following tests correlated with DMS requirements: {missing_tests}" |
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