Exemple #1
0
 def test_raised_exception_message_explains_error(self):
     invalid_date = '-'.join(
         [self.random_month, self.random_day, self.random_year])
     with self.assertRaises(ValidationError) as e:
         utils.valid_reduced_date(invalid_date)
     expected = 'Value must follow YYYY-MM-DD pattern'
     self.assertEqual(expected, e.exception.messages[0])
Exemple #2
0
 def test_raised_exception_message_explains_error(self):
     invalid_date = '-'.join([self.random_month, self.random_day,
             self.random_year])
     with self.assertRaises(ValidationError) as e:
         utils.valid_reduced_date(invalid_date)
     expected = 'Value must follow YYYY-MM-DD pattern'
     self.assertEqual(expected, e.exception.messages[0])
Exemple #3
0
 def test_raised_exceptions_on_invalid_date_different(self):
     invalid_date = '2013-02-29'
     with self.assertRaises(ValidationError) as e:
         utils.valid_reduced_date(invalid_date)
     expected = 'Value must be a valid date'
     self.assertEqual(expected, e.exception.messages[0])
Exemple #4
0
 def test_passes_on_feb_29_2012(self):
     valid_date = '2012-02-29'
     self.assertEqual(None, utils.valid_reduced_date(valid_date))
Exemple #5
0
 def test_raises_on_feb_29_2013(self):
     invalid_date = '2013-02-29'
     with self.assertRaises(ValidationError):
         utils.valid_reduced_date(invalid_date)
Exemple #6
0
 def test_raised_exception_has_code_invalid_value(self):
     invalid_date = '-'.join([self.random_month, self.random_day,
             self.random_year])
     with self.assertRaises(ValidationError) as e:
         utils.valid_reduced_date(invalid_date)
     self.assertEqual('invalid_choice', e.exception.code)
Exemple #7
0
 def test_raises_on_month_day_year(self):
     invalid_date = '-'.join([self.random_month, self.random_day,
             self.random_year])
     with self.assertRaises(ValidationError):
         utils.valid_reduced_date(invalid_date)
Exemple #8
0
 def test_raises_on_month_day_year(self):
     invalid_date = '-'.join(
         [self.random_month, self.random_day, self.random_year])
     with self.assertRaises(ValidationError):
         utils.valid_reduced_date(invalid_date)
Exemple #9
0
 def test_accepts_a_valid_year(self):
     self.assertEqual(None, utils.valid_reduced_date(self.random_year))
Exemple #10
0
 def test_raised_exception_on_invalid_date_has_code_invalid_value(self):
     invalid_date = '2013-02-29'
     with self.assertRaises(ValidationError) as e:
         utils.valid_reduced_date(invalid_date)
     self.assertEqual('invalid_choice', e.exception.code)
Exemple #11
0
 def test_raised_exceptions_on_invalid_date_different(self):
     invalid_date = '2013-02-29'
     with self.assertRaises(ValidationError) as e:
         utils.valid_reduced_date(invalid_date)
     expected = 'Value must be a valid date'
     self.assertEqual(expected, e.exception.messages[0])
Exemple #12
0
 def test_passes_on_feb_29_2012(self):
     valid_date = '2012-02-29'
     self.assertEqual(None, utils.valid_reduced_date(valid_date))
Exemple #13
0
 def test_raises_on_feb_29_2013(self):
     invalid_date = '2013-02-29'
     with self.assertRaises(ValidationError):
         utils.valid_reduced_date(invalid_date)
Exemple #14
0
 def test_raised_exception_has_code_invalid_value(self):
     invalid_date = '-'.join(
         [self.random_month, self.random_day, self.random_year])
     with self.assertRaises(ValidationError) as e:
         utils.valid_reduced_date(invalid_date)
     self.assertEqual('invalid_choice', e.exception.code)
Exemple #15
0
 def test_raised_exception_on_invalid_date_has_code_invalid_value(self):
     invalid_date = '2013-02-29'
     with self.assertRaises(ValidationError) as e:
         utils.valid_reduced_date(invalid_date)
     self.assertEqual('invalid_choice', e.exception.code)
Exemple #16
0
 def test_accepts_valid_year_month_day(self):
     date = '-'.join([self.random_year, self.random_month, self.random_day])
     self.assertEqual(None, utils.valid_reduced_date(date))
Exemple #17
0
 def test_accepts_a_valid_year(self):
     self.assertEqual(None, utils.valid_reduced_date(self.random_year))
Exemple #18
0
 def test_accepts_valid_year_month_day(self):
     date = '-'.join([self.random_year, self.random_month, self.random_day])
     self.assertEqual(None, utils.valid_reduced_date(date))