Esempio n. 1
0
 def test_end_before_start(self):
     """
     Test case for a timeframe when the end is before the start.
     """
     start = timezone.now()
     end = start - timedelta(seconds=1)
     with six.assertRaisesRegex(self, ValidationError, self.msg):
         validate_timeframe(start, end)
Esempio n. 2
0
 def test_start_and_end_equal(self):
     """
     Test case for a timeframe when the start is the same as the end.
     """
     start = timezone.now()
     end = start
     with six.assertRaisesRegex(self, ValidationError, self.msg):
         validate_timeframe(start, end)
Esempio n. 3
0
 def test_start_before_end(self):
     """
     Test case for a timeframe when the start is before the end.
     """
     start = timezone.now()
     end = start + timedelta(seconds=1)
     actual = validate_timeframe(start, end)
     expected = None
     self.assertEqual(actual, expected)
Esempio n. 4
0
 def clean(self):
     """
     Adds custom validations to the model's clean() method.
     """
     super(TimeFrame, self).clean()
     validate_timeframe(self.start, self.end)