def test_create_thresholds(self): roc_check = self._mommy_make_rate_of_change_check() threshold = RateOfChangeThreshold(rate_of_change_check=roc_check, delta_t="10min", allowed_diff=25.0) threshold.save() self.assertEqual(RateOfChangeThreshold.objects.count(), 1)
def test_raises_data_error_if_invalid_delta_t(self): roc_check = self._mommy_make_rate_of_change_check() threshold = RateOfChangeThreshold(rate_of_change_check=roc_check, delta_t="garbag", allowed_diff=25.0) msg = '"garbag" is not a valid delta_t' with self.assertRaisesRegex(DataError, msg): threshold.save()
def test_delta_t_with_days(self): self.assertTrue(RateOfChangeThreshold.is_delta_t_valid("3D"))
def test_delta_t_with_hours(self): self.assertTrue(RateOfChangeThreshold.is_delta_t_valid("2H"))
def test_delta_t_with_minutes(self): self.assertTrue(RateOfChangeThreshold.is_delta_t_valid("1min"))
def test_delta_t_with_invalid_unit_of_measurement_is_invalid(self): self.assertFalse(RateOfChangeThreshold.is_delta_t_valid("2garbg"))
def test_zero_delta_t_is_invalid(self): self.assertFalse(RateOfChangeThreshold.is_delta_t_valid("0min"))
def test_garbage_delta_t_is_invalid(self): self.assertFalse(RateOfChangeThreshold.is_delta_t_valid("garbge"))