Skip to content
Snippets Groups Projects
Verified Commit 5e36abb8 authored by Ernesto Rico Schmidt's avatar Ernesto Rico Schmidt
Browse files

test: fix tests broken by adding _id suffix

Four tests in `test_notes.py` still broken for now
parent bb9218c3
No related branches found
No related tags found
No related merge requests found
Pipeline #3408 passed
...@@ -14,15 +14,17 @@ from program.tests.factories import ( ...@@ -14,15 +14,17 @@ from program.tests.factories import (
ScheduleFactory, ScheduleFactory,
ShowFactory, ShowFactory,
TimeslotFactory, TimeslotFactory,
TypeFactory, ImageFactory, TypeFactory,
ImageFactory,
) )
def assert_data(response, data) -> None: def assert_data(response, data) -> None:
if "schedule" in data: if "schedule" in data:
for key, value in data["schedule"].items(): for key, value in data["schedule"].items():
if key == "rrule": # this is ugly but for some reason
assert response.data[key] == value if key == "rrule_id" and "rrule" in response.data:
assert response.data["rrule"] == value
else: else:
assert str(response.data[key]) == value assert str(response.data[key]) == value
else: else:
......
...@@ -66,9 +66,10 @@ class NoteViewTestCase(tests.BaseMixin, APITransactionTestCase): ...@@ -66,9 +66,10 @@ class NoteViewTestCase(tests.BaseMixin, APITransactionTestCase):
client = self._get_client(self.user_admin) client = self._get_client(self.user_admin)
res = client.post( res = client.post(
self._url("notes"), self._url("notes"),
self._create_random_note_content(timeslot=timeslot.id), self._create_random_note_content(timeslot_id=timeslot.id),
format="json", format="json",
) )
print(res.content)
self.assertEqual(res.status_code, 201) self.assertEqual(res.status_code, 201)
def test_notes_can_be_created_through_nested_routes(self): def test_notes_can_be_created_through_nested_routes(self):
...@@ -77,8 +78,10 @@ class NoteViewTestCase(tests.BaseMixin, APITransactionTestCase): ...@@ -77,8 +78,10 @@ class NoteViewTestCase(tests.BaseMixin, APITransactionTestCase):
# /shows/{pk}/notes/ # /shows/{pk}/notes/
ts1 = self._create_timeslot(schedule=self.schedule_musikrotation) ts1 = self._create_timeslot(schedule=self.schedule_musikrotation)
url = self._url("shows", self.show_musikrotation.id, "notes") 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") res = client.post(url, note, format="json")
print(res.content)
self.assertEqual(res.status_code, 201) self.assertEqual(res.status_code, 201)
# /shows/{pk}/timeslots/{pk}/note/ # /shows/{pk}/timeslots/{pk}/note/
......
...@@ -30,7 +30,7 @@ def schedule_data(rrule) -> dict[str, dict[str | int]]: ...@@ -30,7 +30,7 @@ def schedule_data(rrule) -> dict[str, dict[str | int]]:
"end_time": in_an_hour.strftime("%H:%M:%S"), "end_time": in_an_hour.strftime("%H:%M:%S"),
"first_date": now.strftime("%Y-%m-%d"), "first_date": now.strftime("%Y-%m-%d"),
"last_date": in_a_year.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"), "start_time": now.strftime("%H:%M:%S"),
}, },
} }
...@@ -209,7 +209,7 @@ def test_update_schedule(admin_api_client, once_schedule): ...@@ -209,7 +209,7 @@ def test_update_schedule(admin_api_client, once_schedule):
"first_date": once_schedule.first_date, "first_date": once_schedule.first_date,
"start_time": once_schedule.start_time, "start_time": once_schedule.start_time,
"end_time": once_schedule.end_time, "end_time": once_schedule.end_time,
"rrule": once_schedule.rrule.id, "rrule_id": once_schedule.rrule.id,
}, },
} }
......
...@@ -12,11 +12,11 @@ def url(show=None) -> str: ...@@ -12,11 +12,11 @@ def url(show=None) -> str:
def show_data(funding_category, type_) -> dict[str, str | int]: def show_data(funding_category, type_) -> dict[str, str | int]:
return { return {
"funding_category": funding_category.id, "funding_category_id": funding_category.id,
"name": "NAME", "name": "NAME",
"short_description": "SHORT DESCRIPTION", "short_description": "SHORT DESCRIPTION",
"slug": "SLUG", "slug": "SLUG",
"type": type_.id, "type_id": type_.id,
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment