|
25 | 25 | from utils.pre_validation_test_utils import ValidatorModelTests |
26 | 26 | from utils.values_for_tests import ValidValues, InvalidValues |
27 | 27 | from models.constants import Constants |
| 28 | +from models.fhir_immunization_pre_validators import PreValidators |
28 | 29 |
|
29 | 30 | class TestImmunizationModelPreValidationRules(unittest.TestCase): |
30 | 31 | """Test immunization pre validation rules on the FHIR model using the covid sample data""" |
@@ -818,7 +819,35 @@ def test_pre_validate_protocol_applied(self): |
818 | 819 | valid_list_element=valid_list_element, |
819 | 820 | ) |
820 | 821 |
|
| 822 | + # SAW |
821 | 823 | def test_pre_validate_protocol_applied_dose_number_positive_int(self): |
| 824 | + """ |
| 825 | + Test pre_validate_protocol_applied_dose_number_positive_int accepts valid values and |
| 826 | + rejects invalid values |
| 827 | + """ |
| 828 | + for value in range(1, PreValidators.DOSE_NUMBER_MAX_VALUE + 1): |
| 829 | + data = { |
| 830 | + "protocolApplied": [ |
| 831 | + {"doseNumberPositiveInt": value} |
| 832 | + ] |
| 833 | + } |
| 834 | + validator = PreValidators(data) |
| 835 | + # Should not raise |
| 836 | + validator.pre_validate_dose_number_positive_int(data) |
| 837 | + |
| 838 | + def test_out_of_range_dose_number(self): |
| 839 | + # Invalid: doseNumberPositiveInt < 1 or > 9 |
| 840 | + for value in [0, PreValidators.DOSE_NUMBER_MAX_VALUE + 1, -1]: |
| 841 | + data = { |
| 842 | + "protocolApplied": [ |
| 843 | + {"doseNumberPositiveInt": value} |
| 844 | + ] |
| 845 | + } |
| 846 | + validator = PreValidators(data) |
| 847 | + with self.assertRaises(ValueError): |
| 848 | + validator.pre_validate_dose_number_positive_int(data) |
| 849 | + |
| 850 | + def test_test_positive_integer_value(self): |
822 | 851 | """ |
823 | 852 | Test pre_validate_protocol_applied_dose_number_positive_int accepts valid values and |
824 | 853 | rejects invalid values |
|
0 commit comments