home · contact · privacy
To DB schema validation error message add diff of offending lines.
[plomtask] / tests / test_days.py
1 """Test days module."""
2 from unittest import TestCase
3 from datetime import datetime
4 from plomtask.days import Day
5 from plomtask.misc import HandledException
6
7
8 class DayTests(TestCase):
9     """Tests for testing the days module."""
10
11     def test_Day_dates(self):
12         """Test Day's date format.."""
13         with self.assertRaises(HandledException):
14             Day('foo')
15         with self.assertRaises(HandledException):
16             Day(None)
17         with self.assertRaises(HandledException):
18             Day(3)
19         with self.assertRaises(HandledException):
20             Day('2024-02-30')
21         with self.assertRaises(HandledException):
22             Day('2024-02-01 23:00:00')
23         self.assertEqual(datetime(2024, 1, 1), Day('2024-01-01').datetime)
24
25     def test_Day_sorting(self):
26         """Test Day.__lt__."""
27         day1 = Day('2024-01-01')
28         day2 = Day('2024-01-02')
29         day3 = Day('2024-01-03')
30         days = [day3, day1, day2]
31         self.assertEqual(sorted(days), [day1, day2, day3])
32
33     def test_Day_weekday(self):
34         """Test Day.weekday."""
35         self.assertEqual(Day('2024-03-17').weekday, 'Sunday')