X-Git-Url: https://plomlompom.com/repos/feed.xml?a=blobdiff_plain;f=tests%2Fdays.py;h=c1e1343c63c7cb24e6e7133f09538a06f7104e11;hb=8945aa6762977c04538c49c320417311b38232be;hp=c143f985b22b7bdd41d65e21409c2016274de54c;hpb=f8148a40996d64878431ac59d47650741e1d79c5;p=plomtask diff --git a/tests/days.py b/tests/days.py index c143f98..c1e1343 100644 --- a/tests/days.py +++ b/tests/days.py @@ -2,7 +2,8 @@ from unittest import TestCase from datetime import datetime from tests.utils import TestCaseWithDB, TestCaseWithServer -from plomtask.days import Day, todays_date +from plomtask.dating import todays_date +from plomtask.days import Day from plomtask.exceptions import BadFormatException @@ -42,14 +43,18 @@ class TestsWithDB(TestCaseWithDB): checked_class = Day default_ids = ('2024-01-01', '2024-01-02', '2024-01-03') - def test_Day_saving_and_caching(self) -> None: - """Test .save/.save_core.""" - kwargs = {'date': '2024-01-01', 'comment': 'foo'} + def test_saving_and_caching(self) -> None: + """Test storage of instances. + + We don't use the parent class's method here because the checked class + has too different a handling of IDs. + """ + kwargs = {'date': self.default_ids[0], 'comment': 'foo'} self.check_saving_and_caching(**kwargs) def test_Day_from_table_row(self) -> None: """Test .from_table_row() properly reads in class from DB""" - self.check_from_table_row('2024-01-01') + self.check_from_table_row() def test_Day_by_id(self) -> None: """Test .by_id().""" @@ -77,13 +82,13 @@ class TestsWithDB(TestCaseWithDB): []) # check fill_gaps= instantiates unsaved dates within date range # (but does not store them) - day4 = Day('2024-01-04') day5 = Day('2024-01-05') day6 = Day('2024-01-06') day6.save(self.db_conn) - self.assertEqual(Day.all(self.db_conn, (date2, '2024-01-07'), + day7 = Day('2024-01-07') + self.assertEqual(Day.all(self.db_conn, (day5.date, day7.date), fill_gaps=True), - [day2, day3, day4, day5, day6]) + [day5, day6, day7]) self.check_storage([day1, day2, day3, day6]) # check 'today' is interpreted as today's date today = Day(todays_date()) @@ -96,7 +101,7 @@ class TestsWithDB(TestCaseWithDB): def test_Day_singularity(self) -> None: """Test pointers made for single object keep pointing to it.""" - self.check_singularity('comment', 'boo') + self.check_singularity('day_comment', 'boo') class TestsWithServer(TestCaseWithServer): @@ -115,7 +120,7 @@ class TestsWithServer(TestCaseWithServer): def test_do_POST_day(self) -> None: """Test POST /day.""" - form_data = {'comment': ''} + form_data = {'day_comment': ''} self.check_post(form_data, '/day', 400) self.check_post(form_data, '/day?date=foo', 400) self.check_post(form_data, '/day?date=2024-01-01', 302)