home · contact · privacy
Remove and shrink tests under redundancy with test utils defaults.
authorChristian Heller <c.heller@plomlompom.de>
Tue, 18 Jun 2024 08:57:27 +0000 (10:57 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Tue, 18 Jun 2024 08:57:27 +0000 (10:57 +0200)
tests/days.py
tests/todos.py

index f1d13b3fe7d03a7f43e5ed263ebbe74996460e82..f26885e27468bdab9f9d9fc5ff383f3011cb8403 100644 (file)
@@ -5,7 +5,6 @@ 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):
@@ -13,15 +12,12 @@ class TestsSansDB(TestCase):
     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__."""
@@ -31,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."""
index 51297a8ceadc1812713a681489cc718814b7f066..4bc1411b74cbddace9cf0a745527c0dcbb971b1d 100644 (file)
@@ -53,16 +53,6 @@ class TestsWithDB(TestCaseWithDB, TestCaseSansDB):
         self.assertEqual(todo_yes_id.enables, [])
         self.assertEqual(todo_yes_id.disables, [])
 
-    def test_Todo_by_id(self) -> None:
-        """Test findability of Todos."""
-        todo = Todo(1, self.proc, False, self.date1)
-        todo.save(self.db_conn)
-        self.assertEqual(Todo.by_id(self.db_conn, 1), todo)
-        with self.assertRaises(NotFoundException):
-            Todo.by_id(self.db_conn, 0)
-        with self.assertRaises(NotFoundException):
-            Todo.by_id(self.db_conn, 2)
-
     def test_Todo_by_date(self) -> None:
         """Test findability of Todos by date."""
         t1 = Todo(None, self.proc, False, self.date1)