X-Git-Url: https://plomlompom.com/repos/feed.xml?a=blobdiff_plain;f=tests%2Fdays.py;h=6a8773663032310d3b5d8cf73fcae92a27ec6cbe;hb=02aa60b59cea2c0401efd785f3bb5d06aec7bf4d;hp=286f75815ef51e74ade9e15e96bdb85dc4218a4b;hpb=3b15110c22c17d938d182a3d1a37b81b875c397f;p=plomtask diff --git a/tests/days.py b/tests/days.py index 286f758..6a87736 100644 --- a/tests/days.py +++ b/tests/days.py @@ -1,6 +1,7 @@ """Test Days module.""" from unittest import TestCase from datetime import datetime +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 @@ -52,10 +53,6 @@ class TestsWithDB(TestCaseWithDB): 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() - def test_Day_by_id(self) -> None: """Test .by_id().""" self.check_by_id() @@ -97,14 +94,27 @@ class TestsWithDB(TestCaseWithDB): """Test .remove() effects on DB and cache.""" self.check_remove() - def test_Day_singularity(self) -> None: - """Test pointers made for single object keep pointing to it.""" - self.check_singularity('day_comment', 'boo') - class TestsWithServer(TestCaseWithServer): """Tests against our HTTP server/handler (and database).""" + def test_get_json(self) -> None: + """Test /day for JSON response.""" + self.conn.request('GET', '/day?date=2024-01-01') + response = self.conn.getresponse() + self.assertEqual(response.status, 200) + expected = {'day': {'id': '2024-01-01', + 'comment': '', + 'todos': []}, + 'top_nodes': [], + 'make_type': '', + 'enablers_for': {}, + 'disablers_for': {}, + 'conditions_present': [], + 'processes': []} + retrieved = json_loads(response.read().decode()) + self.assertEqual(expected, retrieved) + def test_do_GET(self) -> None: """Test /day and /calendar response codes, and / redirect.""" self.check_get('/day', 200)