コード例 #1
0
 def test_date_in_future(self):
     """
     Verify that dates in the future error and provide reasonable message
     """
     with self.assertRaises(ArgumentTypeError) as context_manager:
         valid_date('2020-05-01')
         self.assertIn('Date must be earlier than or equal to today', str(context_manager.exception))
コード例 #2
0
 def test_invalid_input(self):
     """
     Verify that invalid date strings error and provide reasonable message
     """
     with self.assertRaises(ArgumentTypeError) as context_manager:
         valid_date('invalid')
         self.assertIn('Not a valid date', str(context_manager.exception))
コード例 #3
0
 def test_date_in_past(self):
     """
     Verify that a date in the past works
     """
     self.assertEqual(valid_date('2019-01-01'), '2019-01-01')
コード例 #4
0
 def test_today(self):
     """
     Verify that today works
     """
     self.assertEqual(valid_date('2020-01-01'), '2020-01-01')