Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoacierno committed Feb 15, 2025
1 parent 12ca411 commit 9d9caa8
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions backend/api/participants/tests/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,54 @@ def test_query_participant(graphql_client):
assert response["data"]["participant"]["fullname"] == participant.user.fullname


def test_query_private_fields_of_own_user(graphql_client, user):
graphql_client.force_login(user)
participant = ParticipantFactory(
user=user,
speaker_availabilities={"test": "test"},
previous_talk_video="test",
speaker_level="level",
)

response = graphql_client.query(
"""query Participant($id: ID!, $conference: String!) {
participant(id: $id, conference: $conference) {
id
speakerAvailabilities
previousTalkVideo
speakerLevel
}
}
""",
variables={"id": participant.hashid, "conference": participant.conference.code},
)

assert response["data"]["participant"]["speakerAvailabilities"] == {"test": "test"}
assert response["data"]["participant"]["previousTalkVideo"] == "test"
assert response["data"]["participant"]["speakerLevel"] == "level"


def test_cannot_query_private_fields_of_other_user(graphql_client):
participant = ParticipantFactory()

response = graphql_client.query(
"""query Participant($id: ID!, $conference: String!) {
participant(id: $id, conference: $conference) {
id
speakerAvailabilities
previousTalkVideo
speakerLevel
}
}
""",
variables={"id": participant.hashid, "conference": participant.conference.code},
)

assert response["data"]["participant"]["speakerAvailabilities"] is None
assert response["data"]["participant"]["previousTalkVideo"] is None
assert response["data"]["participant"]["speakerLevel"] is None


def test_query_participant_with_wrong_conference(graphql_client):
participant = ParticipantFactory()

Expand Down

0 comments on commit 9d9caa8

Please sign in to comment.