From 3e97fbf02a10fcce7426b7aae11ea24de7e2eed2 Mon Sep 17 00:00:00 2001 From: Jose Buitron Date: Wed, 22 Nov 2023 13:11:19 -0500 Subject: [PATCH] fix: Storage tests fixes --- terraso_backend/tests/storage/conftest.py | 12 ++++++++---- terraso_backend/tests/storage/test_views.py | 4 +++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/terraso_backend/tests/storage/conftest.py b/terraso_backend/tests/storage/conftest.py index e8e3d1e95..abc7b97b7 100644 --- a/terraso_backend/tests/storage/conftest.py +++ b/terraso_backend/tests/storage/conftest.py @@ -17,7 +17,9 @@ from mixer.backend.django import mixer from apps.auth.services import JWTService -from apps.core.models import Group, Landscape, LandscapeGroup, User +from apps.collaboration.models import Membership as CollaborationMembership +from apps.core import landscape_collaboration_roles +from apps.core.models import Landscape, User @pytest.fixture @@ -33,7 +35,9 @@ def user(): @pytest.fixture def landscape(user): landscape = mixer.blend(Landscape) - group = mixer.blend(Group) - group.add_manager(user) - mixer.blend(LandscapeGroup, landscape=landscape, group=group, is_default_landscape_group=True) + landscape.membership_list.save_membership( + user.email, + landscape_collaboration_roles.ROLE_MANAGER, + CollaborationMembership.APPROVED, + ) return landscape diff --git a/terraso_backend/tests/storage/test_views.py b/terraso_backend/tests/storage/test_views.py index 14613a982..ac8f40517 100644 --- a/terraso_backend/tests/storage/test_views.py +++ b/terraso_backend/tests/storage/test_views.py @@ -56,7 +56,9 @@ def test_post_user_profile_image(mock_s3, client, access_token): assert response.status_code == 200 -def test_create_data_entry_successfully(logged_client, landscape_profile_image_payload): +def test_create_landscape_profile_image_successfully( + logged_client, landscape_profile_image_payload +): url = reverse("terraso_storage:landscape-profile-image") with patch( "apps.storage.forms.profile_image_upload_service.upload_file"