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
8 class DayTests(TestCase):
9 """Tests for testing the days module."""
11 def test_Day_dates(self):
12 """Test Day's date format.."""
13 with self.assertRaises(HandledException):
15 with self.assertRaises(HandledException):
17 with self.assertRaises(HandledException):
19 with self.assertRaises(HandledException):
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)
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])
33 def test_Day_weekday(self):
34 """Test Day.weekday."""
35 self.assertEqual(Day('2024-03-17').weekday, 'Sunday')