def test_haemoglobin_units_male_valid(self): self.cleaned_data.update(haemoglobin=14, results_abnormal=NO) form_validator = SpecimenResultFormValidator( cleaned_data=self.cleaned_data, instance=SpecimenResult()) try: form_validator.validate() except ValidationError as e: self.fail(f"ValidationError unexpectedly raised. Got{e}")
def test_neutrophil(self): self.cleaned_data.update(neutrophil=4, results_abnormal=NO) form_validator = SpecimenResultFormValidator( cleaned_data=self.cleaned_data, instance=SpecimenResult()) try: form_validator.validate() except ValidationError as e: self.fail(f"ValidationError unexpectedly raised. Got{e}")
def test_sodium(self): self.cleaned_data.update(sodium=135, results_abnormal=NO, results_reportable=NOT_APPLICABLE) form_validator = SpecimenResultFormValidator( cleaned_data=self.cleaned_data, instance=SpecimenResult()) try: form_validator.validate() except ValidationError as e: self.fail(f"ValidationError unexpectedly raised. Got{e}")
def test_creatinine_umol(self): self.cleaned_data.update(creatinine=100, creatinine_units=MICROMOLES_PER_LITER) form_validator = SpecimenResultFormValidator( cleaned_data=self.cleaned_data, instance=SpecimenResult()) try: form_validator.validate() except ValidationError as e: self.fail(f"ValidationError unexpectedly raised. Got{e}")
def test_creatinine_mg(self): self.cleaned_data.update( creatinine=1.3, creatinine_units=MILLIGRAMS_PER_DECILITER, results_abnormal=NO, results_reportable=NOT_APPLICABLE, ) form_validator = SpecimenResultFormValidator( cleaned_data=self.cleaned_data, instance=SpecimenResult()) try: form_validator.validate() except ValidationError as e: self.fail(f"ValidationError unexpectedly raised. Got {e}")
def test_no_creatinine_mg_invalid(self): self.cleaned_data.update(creatinine=0.3, creatinine_units=MILLIGRAMS_PER_DECILITER) form_validator = SpecimenResultFormValidator( cleaned_data=self.cleaned_data, instance=SpecimenResult()) self.assertRaises(ValidationError, form_validator.validate) self.assertIn("creatinine", form_validator._errors)
def test_platelets_invalid(self): self.cleaned_data.update(platelets=50, results_abnormal=YES) form_validator = SpecimenResultFormValidator( cleaned_data=self.cleaned_data, instance=SpecimenResult()) self.assertRaises(ValidationError, form_validator.validate) self.assertIn("platelets", form_validator._errors)
def test_no_creatinine_mg_sodium_invalid(self): self.cleaned_data.update(creatinine=900, creatinine_units=MICROMOLES_PER_LITER, results_abnormal=YES) form_validator = SpecimenResultFormValidator( cleaned_data=self.cleaned_data, instance=SpecimenResult()) self.assertRaises(ValidationError, form_validator.validate) self.assertIn("creatinine", form_validator._errors)
def test_results_reportable_invalid(self): self.cleaned_data.update(sodium=1000, results_abnormal=YES, results_reportable=NO) form_validator = SpecimenResultFormValidator( cleaned_data=self.cleaned_data, instance=SpecimenResult()) self.assertRaises(ValidationError, form_validator.validate) self.assertIn("sodium", form_validator._errors)
def test_potassium_low(self): self.cleaned_data.update(potassium=2.3, results_abnormal=YES, results_reportable=NO) form_validator = SpecimenResultFormValidator( cleaned_data=self.cleaned_data, instance=SpecimenResult()) self.assertRaises(ValidationError, form_validator.validate) self.assertIn("potassium", form_validator._errors)
def test_magnesium(self): self.cleaned_data.update(magnesium=0.35, results_abnormal=YES, results_reportable=YES) form_validator = SpecimenResultFormValidator( cleaned_data=self.cleaned_data, instance=SpecimenResult()) self.assertRaises(ValidationError, form_validator.validate) self.assertIn("magnesium", form_validator._errors)
def test_creatinine_umol_invalid(self): self.cleaned_data.update( creatinine=217, creatinine_units=MICROMOLES_PER_LITER, are_results_normal=YES, ) form_validator = SpecimenResultFormValidator( cleaned_data=self.cleaned_data, instance=SpecimenResult()) self.assertRaises(ValidationError, form_validator.validate) self.assertIn("creatinine", form_validator._errors)
def test_haemoglobin_units_invalid(self): self.cleaned_data.update(haemoglobin=6.4, results_abnormal=YES) form_validator = SpecimenResultFormValidator( cleaned_data=self.cleaned_data, instance=SpecimenResult()) self.assertRaises(ValidationError, form_validator.validate) self.assertIn("haemoglobin", form_validator._errors)
def test_neutrophil_invalid(self): self.cleaned_data.update(neutrophil=0.5) form_validator = SpecimenResultFormValidator( cleaned_data=self.cleaned_data, instance=SpecimenResult()) self.assertRaises(ValidationError, form_validator.validate) self.assertIn("neutrophil", form_validator._errors)
def test_alt_invalid(self): self.cleaned_data.update(alt=201, are_results_normal=YES) form_validator = SpecimenResultFormValidator( cleaned_data=self.cleaned_data, instance=SpecimenResult()) self.assertRaises(ValidationError, form_validator.validate) self.assertIn("alt", form_validator._errors)