Skip to content

Commit 9d9caa8

Browse files
committed
tests
1 parent 12ca411 commit 9d9caa8

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

backend/api/participants/tests/test_queries.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,54 @@ def test_query_participant(graphql_client):
2121
assert response["data"]["participant"]["fullname"] == participant.user.fullname
2222

2323

24+
def test_query_private_fields_of_own_user(graphql_client, user):
25+
graphql_client.force_login(user)
26+
participant = ParticipantFactory(
27+
user=user,
28+
speaker_availabilities={"test": "test"},
29+
previous_talk_video="test",
30+
speaker_level="level",
31+
)
32+
33+
response = graphql_client.query(
34+
"""query Participant($id: ID!, $conference: String!) {
35+
participant(id: $id, conference: $conference) {
36+
id
37+
speakerAvailabilities
38+
previousTalkVideo
39+
speakerLevel
40+
}
41+
}
42+
""",
43+
variables={"id": participant.hashid, "conference": participant.conference.code},
44+
)
45+
46+
assert response["data"]["participant"]["speakerAvailabilities"] == {"test": "test"}
47+
assert response["data"]["participant"]["previousTalkVideo"] == "test"
48+
assert response["data"]["participant"]["speakerLevel"] == "level"
49+
50+
51+
def test_cannot_query_private_fields_of_other_user(graphql_client):
52+
participant = ParticipantFactory()
53+
54+
response = graphql_client.query(
55+
"""query Participant($id: ID!, $conference: String!) {
56+
participant(id: $id, conference: $conference) {
57+
id
58+
speakerAvailabilities
59+
previousTalkVideo
60+
speakerLevel
61+
}
62+
}
63+
""",
64+
variables={"id": participant.hashid, "conference": participant.conference.code},
65+
)
66+
67+
assert response["data"]["participant"]["speakerAvailabilities"] is None
68+
assert response["data"]["participant"]["previousTalkVideo"] is None
69+
assert response["data"]["participant"]["speakerLevel"] is None
70+
71+
2472
def test_query_participant_with_wrong_conference(graphql_client):
2573
participant = ParticipantFactory()
2674

0 commit comments

Comments
 (0)