From 5e36abb8c87311d2128ab872da8d0958f83e999c Mon Sep 17 00:00:00 2001 From: Ernesto Rico Schmidt <ernesto@helsinki.at> Date: Tue, 6 Jun 2023 18:41:11 -0400 Subject: [PATCH] test: fix tests broken by adding _id suffix Four tests in `test_notes.py` still broken for now --- conftest.py | 8 +++++--- program/tests/test_notes.py | 7 +++++-- program/tests/test_schedules.py | 4 ++-- program/tests/test_shows.py | 4 ++-- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/conftest.py b/conftest.py index 67683060..7f7c9d40 100644 --- a/conftest.py +++ b/conftest.py @@ -14,15 +14,17 @@ from program.tests.factories import ( ScheduleFactory, ShowFactory, TimeslotFactory, - TypeFactory, ImageFactory, + TypeFactory, + ImageFactory, ) def assert_data(response, data) -> None: if "schedule" in data: for key, value in data["schedule"].items(): - if key == "rrule": - assert response.data[key] == value + # this is ugly but for some reason + if key == "rrule_id" and "rrule" in response.data: + assert response.data["rrule"] == value else: assert str(response.data[key]) == value else: diff --git a/program/tests/test_notes.py b/program/tests/test_notes.py index d21fdadc..08a13d30 100644 --- a/program/tests/test_notes.py +++ b/program/tests/test_notes.py @@ -66,9 +66,10 @@ class NoteViewTestCase(tests.BaseMixin, APITransactionTestCase): client = self._get_client(self.user_admin) res = client.post( self._url("notes"), - self._create_random_note_content(timeslot=timeslot.id), + self._create_random_note_content(timeslot_id=timeslot.id), format="json", ) + print(res.content) self.assertEqual(res.status_code, 201) def test_notes_can_be_created_through_nested_routes(self): @@ -77,8 +78,10 @@ class NoteViewTestCase(tests.BaseMixin, APITransactionTestCase): # /shows/{pk}/notes/ ts1 = self._create_timeslot(schedule=self.schedule_musikrotation) url = self._url("shows", self.show_musikrotation.id, "notes") - note = self._create_random_note_content(title="meh", timeslot=ts1.id) + note = self._create_random_note_content(title="meh", timeslot_id=ts1.id) + print(note) res = client.post(url, note, format="json") + print(res.content) self.assertEqual(res.status_code, 201) # /shows/{pk}/timeslots/{pk}/note/ diff --git a/program/tests/test_schedules.py b/program/tests/test_schedules.py index 32dabb5c..bbbed6bf 100644 --- a/program/tests/test_schedules.py +++ b/program/tests/test_schedules.py @@ -30,7 +30,7 @@ def schedule_data(rrule) -> dict[str, dict[str | int]]: "end_time": in_an_hour.strftime("%H:%M:%S"), "first_date": now.strftime("%Y-%m-%d"), "last_date": in_a_year.strftime("%Y-%m-%d"), - "rrule": rrule.id, + "rrule_id": rrule.id, "start_time": now.strftime("%H:%M:%S"), }, } @@ -209,7 +209,7 @@ def test_update_schedule(admin_api_client, once_schedule): "first_date": once_schedule.first_date, "start_time": once_schedule.start_time, "end_time": once_schedule.end_time, - "rrule": once_schedule.rrule.id, + "rrule_id": once_schedule.rrule.id, }, } diff --git a/program/tests/test_shows.py b/program/tests/test_shows.py index 3f997fd0..853aeefd 100644 --- a/program/tests/test_shows.py +++ b/program/tests/test_shows.py @@ -12,11 +12,11 @@ def url(show=None) -> str: def show_data(funding_category, type_) -> dict[str, str | int]: return { - "funding_category": funding_category.id, + "funding_category_id": funding_category.id, "name": "NAME", "short_description": "SHORT DESCRIPTION", "slug": "SLUG", - "type": type_.id, + "type_id": type_.id, } -- GitLab