From 0f5ecb70d3ed986a842758685a368757ef27956b Mon Sep 17 00:00:00 2001 From: David Code Howard Date: Thu, 2 Nov 2023 15:05:48 -0400 Subject: [PATCH] test: Remove duplicate memberships in searching for projects Test that the projects query works --- .../tests/graphql/test_projects_query.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/terraso_backend/tests/graphql/test_projects_query.py b/terraso_backend/tests/graphql/test_projects_query.py index 5a5144703..2e9745484 100644 --- a/terraso_backend/tests/graphql/test_projects_query.py +++ b/terraso_backend/tests/graphql/test_projects_query.py @@ -14,7 +14,10 @@ # along with this program. If not, see https://www.gnu.org/licenses/. import pytest from graphene_django.utils.testing import graphql_query +from mixer.backend.django import mixer +from tests.utils import match_json +from apps.core.models import User from apps.project_management.models.projects import Project pytestmark = pytest.mark.django_db @@ -61,3 +64,14 @@ def test_query_by_non_member(client, project): assert "errors" not in payload assert len(payload["data"]["projects"]["edges"]) == 0 assert payload["data"]["projects"]["totalCount"] == 0 + + +def test_query_with_deleted_member(client, project): + user = mixer.blend(User) + project.add_manager(user) + project.remove_user(user) + project.add_viewer(user) + client.force_login(user) + payload = graphql_query(PROJECT_QUERY, client=client).json() + assert "errors" not in payload + assert len(match_json("data.projects.edges[*]", payload)) == 1