diff --git a/program/tests/test_shows.py b/program/tests/test_shows.py index 853aeefd8c270b618495d2d79463fc070d52c248..ad27d5bf712c9b39e51cb3d7fc10cfff27b52996 100644 --- a/program/tests/test_shows.py +++ b/program/tests/test_shows.py @@ -10,30 +10,70 @@ def url(show=None) -> str: return f"/api/v1/shows/{show.id}/" if show else "/api/v1/shows/" -def show_data(funding_category, type_) -> dict[str, str | int]: +def show_data( + category, funding_category, host, language, link_type, music_focus, owner, topic, type_ +) -> dict[str, str | int | list[dict[str, str | int]]]: return { + "category_ids": [category.id], "funding_category_id": funding_category.id, + "host_ids": [host.id], + "language_ids": [language.id], + "links": [ + { + "type_id": link_type.id, + "url": "https://aura.radio", + } + ], + "music_focus_ids": [music_focus.id], "name": "NAME", + "owner_ids": [owner.id], "short_description": "SHORT DESCRIPTION", "slug": "SLUG", + "topic_ids": [topic.id], "type_id": type_.id, } -def test_create_show(admin_api_client, funding_category, type_): - data = show_data(funding_category, type_) - - response = admin_api_client.post(url(), data=data) +def test_create_show( + admin_api_client, + category, + funding_category, + host, + language, + link_type, + music_focus, + owner, + topic, + type_, +): + data = show_data( + category, funding_category, host, language, link_type, music_focus, owner, topic, type_ + ) + + response = admin_api_client.post(url(), data=data, format="json") assert response.status_code == 201 assert_data(response, data) -def test_create_show_forbidden_for_common_user(common_api_client1, funding_category, type_): - data = show_data(funding_category, type_) - - response = common_api_client1.post(url(), data=data) +def test_create_show_forbidden_for_common_user( + common_api_client1, + category, + funding_category, + host, + language, + link_type, + music_focus, + owner, + topic, + type_, +): + data = show_data( + category, funding_category, host, language, link_type, music_focus, owner, topic, type_ + ) + + response = common_api_client1.post(url(), data=data, format="json") assert response.status_code == 403 @@ -68,19 +108,71 @@ def test_retrieve_show_as_admin_user(admin_api_client, show): assert "internal_note" in response.data -def test_update_show(admin_api_client, funding_category, type_, show): - update = show_data(funding_category, type_) - - response = admin_api_client.put(url(show), data=update) +def test_update_show( + admin_api_client, + category, + funding_category, + host, + language, + link_type, + music_focus, + owner, + topic, + type_, + show, +): + update = show_data( + category, funding_category, host, language, link_type, music_focus, owner, topic, type_ + ) + + response = admin_api_client.patch(url(show), data=update, format="json") assert response.status_code == 200 assert_data(response, update) -def test_update_show_forbidden_for_common_user(common_api_client1, funding_category, type_, show): - update = show_data(funding_category, type_) +def test_update_show_links( + admin_api_client, + category, + funding_category, + host, + language, + link_type, + music_focus, + owner, + topic, + type_, + show, +): + update = show_data( + category, funding_category, host, language, link_type, music_focus, owner, topic, type_ + ) + + response = admin_api_client.patch(url(show), data=update, format="json") + + assert response.status_code == 200 + + assert_data(response, update) + - response = common_api_client1.put(url(show), data=update) +def test_update_show_forbidden_for_common_user( + common_api_client1, + category, + funding_category, + host, + language, + link_type, + music_focus, + owner, + topic, + type_, + show, +): + update = show_data( + category, funding_category, host, language, link_type, music_focus, owner, topic, type_ + ) + + response = common_api_client1.patch(url(show), data=update, format="json") assert response.status_code == 403