Beispiel #1
0
 def test_020_760_ShouldHandleYearBefore2001(self):
     test_input = {'date': '2000-10-10'}
     expected = {'date': '2000-10-10', 'error': 'invalid date'}
     actual = predict.extractDate(test_input)
     self.assertIsNone(actual)
     self.assertEqual(test_input, expected,
                      'Should handle year before 2001')
Beispiel #2
0
 def test_020_740_ShouldHandleNonIntegerFields(self):
     test_input = {'date': '2011-a-b'}
     expected = {'date': '2011-a-b', 'error': 'invalid date'}
     actual = predict.extractDate(test_input)
     self.assertIsNone(actual)
     self.assertEqual(test_input, expected,
                      'Should handle non integer fields')
Beispiel #3
0
 def test_020_730_ShouldHandleTooManyFields(self):
     test_input = {'date': '2011-10-10-10'}
     expected = {'date': '2011-10-10-10', 'error': 'invalid date'}
     actual = predict.extractDate(test_input)
     self.assertIsNone(actual)
     self.assertEqual(test_input, expected, 'Should handle too many fields')
Beispiel #4
0
 def test_020_710_ShouldHandleNonStringDate(self):
     test_input = {'date': 17}
     expected = {'date': 17, 'error': 'invalid date'}
     actual = predict.extractDate(test_input)
     self.assertIsNone(actual)
     self.assertEqual(test_input, expected, 'Should handle non string date')
Beispiel #5
0
 def test_020_020_ShouldExtractDefaultDate(self):
     test_input = {}
     expected = datetime.date(2001, 01, 01)
     actual = predict.extractDate(test_input)
     self.assertEqual(actual, expected, 'Should extract default date')
Beispiel #6
0
 def test_020_010_ShouldExtractValidDate(self):
     test_input = {'date': '2011-3-15'}
     expected = datetime.date(2011, 3, 15)
     actual = predict.extractDate(test_input)
     self.assertEqual(actual, expected, 'Should extract nominal date')
Beispiel #7
0
 def test_020_750_ShouldHandleInvalidFields(self):
     test_input = {'date': '2011-13-01'}
     expected = {'date': '2011-13-01', 'error': 'invalid date'}
     actual = predict.extractDate(test_input)
     self.assertIsNone(actual)
     self.assertEqual(test_input, expected, 'Should handle invalid fields')