|
| 1 | +from conferences.tests.factories import ConferenceFactory |
| 2 | +from participants.tests.factories import ParticipantFactory |
| 3 | + |
| 4 | + |
| 5 | +def test_query_participant(graphql_client): |
| 6 | + participant = ParticipantFactory() |
| 7 | + |
| 8 | + response = graphql_client.query( |
| 9 | + """ |
| 10 | + query Participant($id: ID!, $conference: String!) { |
| 11 | + participant(id: $id, conference: $conference) { |
| 12 | + id |
| 13 | + fullname |
| 14 | + } |
| 15 | + } |
| 16 | + """, |
| 17 | + variables={"id": participant.hashid, "conference": participant.conference.code}, |
| 18 | + ) |
| 19 | + |
| 20 | + assert response["data"]["participant"]["id"] == participant.hashid |
| 21 | + assert response["data"]["participant"]["fullname"] == participant.user.fullname |
| 22 | + |
| 23 | + |
| 24 | +def test_query_participant_with_wrong_conference(graphql_client): |
| 25 | + participant = ParticipantFactory() |
| 26 | + |
| 27 | + response = graphql_client.query( |
| 28 | + """ |
| 29 | + query Participant($id: ID!, $conference: String!) { |
| 30 | + participant(id: $id, conference: $conference) { |
| 31 | + id |
| 32 | + fullname |
| 33 | + } |
| 34 | + } |
| 35 | + """, |
| 36 | + variables={"id": participant.hashid, "conference": ConferenceFactory().code}, |
| 37 | + ) |
| 38 | + |
| 39 | + assert response["data"]["participant"] is None |
| 40 | + |
| 41 | + |
| 42 | +def test_query_participant_with_non_existent_id(graphql_client): |
| 43 | + response = graphql_client.query( |
| 44 | + """ |
| 45 | + query Participant($id: ID!, $conference: String!) { |
| 46 | + participant(id: $id, conference: $conference) { |
| 47 | + id |
| 48 | + fullname |
| 49 | + } |
| 50 | + } |
| 51 | + """, |
| 52 | + variables={"id": "abcabc", "conference": ConferenceFactory().code}, |
| 53 | + ) |
| 54 | + |
| 55 | + assert response["data"]["participant"] is None |
0 commit comments