Skip to content

Commit

Permalink
test: Remove duplicate memberships in searching for projects
Browse files Browse the repository at this point in the history
Test that the projects query works
  • Loading branch information
David Code Howard committed Nov 2, 2023
1 parent 3ee89f4 commit 0f5ecb7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions terraso_backend/tests/graphql/test_projects_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 0f5ecb7

Please sign in to comment.