From 028884aa3a362335ff9b5d388ef28db5471bf46a Mon Sep 17 00:00:00 2001 From: Ernesto Rico Schmidt <ernesto@helsinki.at> Date: Thu, 30 Jan 2025 12:24:46 -0400 Subject: [PATCH] test: update tests for images --- program/tests/test_images.py | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/program/tests/test_images.py b/program/tests/test_images.py index 0c5613c..926a746 100644 --- a/program/tests/test_images.py +++ b/program/tests/test_images.py @@ -2,7 +2,7 @@ import pytest from conftest import assert_data from program.models import Image -from program.tests.factories import ContentLicenseFactory, ImageFactory +from program.tests.factories import ImageFactory, LicensingFactory pytestmark = pytest.mark.django_db @@ -26,9 +26,7 @@ def owned_image(image_file, common_user1) -> Image: @pytest.fixture def owned_licensed_image(image_file, common_user1, public_domain_license) -> Image: - return ImageFactory( - image=image_file, owner=common_user1, content_license=ContentLicenseFactory() - ) + return ImageFactory(image=image_file, owner=common_user1, licensing=LicensingFactory()) def test_create_image(image_file, common_api_client1): @@ -40,24 +38,24 @@ def test_create_image(image_file, common_api_client1): def test_create_image_with_license(image_file, common_api_client1, public_domain_license): - content_license = { + licensing = { "credits": "CREDITS", "is_use_explicitly_granted_by_author": True, "license_id": public_domain_license.id, } data = {"image": image_file} - data.update({"content_license." + key: value for key, value in content_license.items()}) + data.update({"licensing." + key: value for key, value in licensing.items()}) response = common_api_client1.post(url(), data=data) assert response.status_code == 201 - assert response.data["content_license"]["credits"] == content_license["credits"] + assert response.data["licensing"]["credits"] == licensing["credits"] assert ( - response.data["content_license"]["is_use_explicitly_granted_by_author"] - is content_license["is_use_explicitly_granted_by_author"] + response.data["licensing"]["is_use_explicitly_granted_by_author"] + is licensing["is_use_explicitly_granted_by_author"] ) - assert response.data["content_license"]["license_id"] == public_domain_license.id + assert response.data["licensing"]["license_id"] == public_domain_license.id def test_delete_image(owned_image, common_api_client1): @@ -124,7 +122,7 @@ def test_update_alt_text_not_found_for_different_user(owned_image, common_api_cl def test_update_credits(owned_image, common_api_client1, public_domain_license): update = { - "content_license": { + "licensing": { "credits": "CREDITS", }, } @@ -133,14 +131,14 @@ def test_update_credits(owned_image, common_api_client1, public_domain_license): assert response.status_code == 200 - assert response.data["content_license"]["credits"] == update["content_license"]["credits"] + assert response.data["licensing"]["credits"] == update["licensing"]["credits"] def test_update_credits_not_found_for_different_user( owned_image, common_api_client2, public_domain_license ): update = { - "content_license": { + "licensing": { "credits": "CREDITS", } } @@ -170,21 +168,21 @@ def test_update_ppoi_not_found_for_different_user(owned_image, common_api_client def test_set_image_license(owned_image, common_api_client1, public_domain_license): update = { - "content_license": {"license_id": public_domain_license.id}, + "licensing": {"license_id": public_domain_license.id}, } response = common_api_client1.patch(url(owned_image), data=update, format="json") assert response.status_code == 200 - assert response.data["content_license"]["license_id"] == public_domain_license.id + assert response.data["licensing"]["license_id"] == public_domain_license.id def test_unset_image_license(owned_licensed_image, common_api_client1): - update = {"content_license": None} + update = {"licensing": None} response = common_api_client1.patch(url(owned_licensed_image), data=update, format="json") assert response.status_code == 200 - assert response.data["content_license"] is None + assert response.data["licensing"] is None -- GitLab