From: Christian Heller Date: Tue, 18 Jun 2024 08:57:27 +0000 (+0200) Subject: Remove and shrink tests under redundancy with test utils defaults. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/do_todos?a=commitdiff_plain;h=ffeee1618e4d169c9f125028ef7cd75b913cda8f;p=plomtask Remove and shrink tests under redundancy with test utils defaults. --- diff --git a/tests/days.py b/tests/days.py index f1d13b3..f26885e 100644 --- a/tests/days.py +++ b/tests/days.py @@ -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.""" diff --git a/tests/todos.py b/tests/todos.py index 51297a8..4bc1411 100644 --- a/tests/todos.py +++ b/tests/todos.py @@ -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)