home · contact · privacy
Remove and shrink tests under redundancy with test utils defaults.
[plomtask] / tests / days.py
index 9fb12add44b42d4a41bb8cbec543fb40c8e20978..f26885e27468bdab9f9d9fc5ff383f3011cb8403 100644 (file)
@@ -5,21 +5,19 @@ from json import loads as json_loads
 from tests.utils import TestCaseWithDB, TestCaseWithServer
 from plomtask.dating import date_in_n_days
 from plomtask.days import Day
-from plomtask.exceptions import BadFormatException
 
 
 class TestsSansDB(TestCase):
     """Days module tests not requiring DB setup."""
+    legal_ids = ['2024-01-01']
+    illegal_ids = ['foo', '2024-02-30', '2024-02-01 23:00:00']
 
-    def test_Day_valid_date(self) -> None:
-        """Test Day's date format validation and parsing."""
-        with self.assertRaises(BadFormatException):
-            Day('foo')
-        with self.assertRaises(BadFormatException):
-            Day('2024-02-30')
-        with self.assertRaises(BadFormatException):
-            Day('2024-02-01 23:00:00')
-        self.assertEqual(datetime(2024, 1, 1), Day('2024-01-01').datetime)
+    def test_Day_datetime_weekday_neighbor_dates(self) -> None:
+        """Test Day's date parsing."""
+        self.assertEqual(datetime(2024, 5, 1), Day('2024-05-01').datetime)
+        self.assertEqual('Sunday', Day('2024-03-17').weekday)
+        self.assertEqual('2023-12-31', Day('2024-01-01').prev_date)
+        self.assertEqual('2023-03-01', Day('2023-02-28').next_date)
 
     def test_Day_sorting(self) -> None:
         """Test sorting by .__lt__ and Day.__eq__."""
@@ -29,15 +27,6 @@ class TestsSansDB(TestCase):
         days = [day3, day1, day2]
         self.assertEqual(sorted(days), [day1, day2, day3])
 
-    def test_Day_weekday(self) -> None:
-        """Test Day.weekday."""
-        self.assertEqual(Day('2024-03-17').weekday, 'Sunday')
-
-    def test_Day_neighbor_dates(self) -> None:
-        """Test Day.prev_date and Day.next_date."""
-        self.assertEqual(Day('2024-01-01').prev_date, '2023-12-31')
-        self.assertEqual(Day('2023-02-28').next_date, '2023-03-01')
-
 
 class TestsWithDB(TestCaseWithDB):
     """Tests requiring DB, but not server setup."""
@@ -82,10 +71,6 @@ class TestsWithDB(TestCaseWithDB):
                                                   'today', 'today'),
                          [today])
 
-    def test_Day_remove(self) -> None:
-        """Test .remove() effects on DB and cache."""
-        self.check_remove()
-
 
 class TestsWithServer(TestCaseWithServer):
     """Tests against our HTTP server/handler (and database)."""