-
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.
add sanity check when importing data from a dictionary
Signed-off-by: Jose Borreguero <[email protected]>
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# third-party imports | ||
import pytest | ||
|
||
# lr_reduction imports | ||
from lr_reduction.reduction_template_reader import ReductionParameters | ||
|
||
|
||
class TestReductionParameters: | ||
|
||
def test_two_backgrounds(self): | ||
r"""verify the xml dump writes what we want""" | ||
redparms = ReductionParameters() | ||
redparms.two_backgrounds = True | ||
assert "<two_backgrounds_flag>True</two_backgrounds_flag>" in redparms.to_xml() | ||
|
||
def test_from_dict(self): | ||
r"""verify method from_dict raises when passed some nonsense""" | ||
|
||
redparms = ReductionParameters() | ||
# valid data dictionary | ||
redparms.from_dict(dict(two_backgrounds=True)) | ||
assert redparms.two_backgrounds | ||
# invalid data dictionary | ||
with pytest.raises(ValueError) as excinfo: | ||
redparms.from_dict(dict(nonsense=True)) | ||
assert "data_dir contains invalid entries" == str(excinfo.value) | ||
|
||
if __name__ == "__main__": | ||
pytest.main(__file__) |