Пример #1
0
 def test_missingSubtokens(self):
     with self.assertRaises(lectionary.MalformedDateError):
         lectionary._parseDate('-10-17')
     with self.assertRaises(lectionary.MalformedDateError):
         lectionary._parseDate('2017--17')
     with self.assertRaises(lectionary.MalformedDateError):
         lectionary._parseDate('2017-10-')
Пример #2
0
 def test_malformedSubtokens(self):
     with self.assertRaises(lectionary.MalformedDateError):
         lectionary._parseDate('banana-10-17')
     with self.assertRaises(lectionary.MalformedDateError):
         lectionary._parseDate('2017-banana-17')
     with self.assertRaises(lectionary.MalformedDateError):
         lectionary._parseDate('2017-10-banana')
Пример #3
0
 def test_nonString(self):
     with self.assertRaises(TypeError):
         lectionary._parseDate(None)
     with self.assertRaises(TypeError):
         lectionary._parseDate(123)
     with self.assertRaises(TypeError):
         lectionary._parseDate(0.123)
Пример #4
0
 def test_day(self):
     today = datetime.date.today()
     result = lectionary._parseDate('17')
     self.assertEqual(today.year, result.year)
     self.assertEqual(today.month, result.month)
     self.assertEqual(17, result.day)
Пример #5
0
 def test_yearMonthDay(self):
     today = datetime.date.today()
     result = lectionary._parseDate('2017-10-17')
     self.assertEqual(2017, result.year)
     self.assertEqual(10, result.month)
     self.assertEqual(17, result.day)
Пример #6
0
 def test_invalidDay(self):
     with self.assertRaises(lectionary.InvalidDateError):
         lectionary._parseDate('2017-13-0')
     with self.assertRaises(lectionary.InvalidDateError):
         lectionary._parseDate('2017-13-99')
Пример #7
0
 def test_invalidMonth(self):
     with self.assertRaises(lectionary.InvalidDateError):
         lectionary._parseDate('2017-0-17')
     with self.assertRaises(lectionary.InvalidDateError):
         lectionary._parseDate('2017-13-17')
Пример #8
0
 def test_invalidYear(self):
     with self.assertRaises(lectionary.InvalidDateError):
         lectionary._parseDate('0-10-17')
Пример #9
0
 def test_tooManySubtokens(self):
     with self.assertRaises(lectionary.MalformedDateError):
         lectionary._parseDate('2017-10-17-01')
Пример #10
0
 def test_emptyString(self):
     with self.assertRaises(lectionary.MalformedDateError):
         lectionary._parseDate('')