|
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""" |
@@ -819,6 +820,33 @@ def test_pre_validate_protocol_applied(self): |
819 | 820 | ) |
820 | 821 |
|
821 | 822 | def test_pre_validate_protocol_applied_dose_number_positive_int(self): |
| 823 | + """ |
| 824 | + Test pre_validate_protocol_applied_dose_number_positive_int accepts valid values and |
| 825 | + rejects invalid values |
| 826 | + """ |
| 827 | + for value in range(1, PreValidators.DOSE_NUMBER_MAX_VALUE + 1): |
| 828 | + data = { |
| 829 | + "protocolApplied": [ |
| 830 | + {"doseNumberPositiveInt": value} |
| 831 | + ] |
| 832 | + } |
| 833 | + validator = PreValidators(data) |
| 834 | + # Should not raise |
| 835 | + validator.pre_validate_dose_number_positive_int(data) |
| 836 | + |
| 837 | + def test_out_of_range_dose_number(self): |
| 838 | + # Invalid: doseNumberPositiveInt < 1 or > 9 |
| 839 | + for value in [0, PreValidators.DOSE_NUMBER_MAX_VALUE + 1, -1]: |
| 840 | + data = { |
| 841 | + "protocolApplied": [ |
| 842 | + {"doseNumberPositiveInt": value} |
| 843 | + ] |
| 844 | + } |
| 845 | + validator = PreValidators(data) |
| 846 | + with self.assertRaises(ValueError): |
| 847 | + validator.pre_validate_dose_number_positive_int(data) |
| 848 | + |
| 849 | + def test_test_positive_integer_value(self): |
822 | 850 | """ |
823 | 851 | Test pre_validate_protocol_applied_dose_number_positive_int accepts valid values and |
824 | 852 | rejects invalid values |
|
0 commit comments