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

test: update tests for shows

parent 94f58e2b
No related branches found
No related tags found
No related merge requests found
Pipeline #8015 passed
......@@ -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
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