-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest_graphql.py
More file actions
40 lines (32 loc) · 1.43 KB
/
test_graphql.py
File metadata and controls
40 lines (32 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Copyright (c) 2023-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
def test_graphql(client):
data = client.rows.query(
graphql="query musicianQuery { test_musician { lastName firstName dob } }"
)
musicians = data["data"]["test_musician"]
assert 4 == len(musicians)
assert 1 == len([m for m in musicians if m["lastName"] == "Armstrong"])
def test_graphql_return_response(client):
response = client.rows.query(
graphql="query musicianQuery { test_musician { lastName firstName dob } }",
return_response=True,
)
assert 200 == response.status_code
data = response.json()
musicians = data["data"]["test_musician"]
assert 4 == len(musicians)
assert 1 == len([m for m in musicians if m["lastName"] == "Armstrong"])
def test_graphql_bad_graphql(client):
response = client.rows.query(
graphql="query musicianQuery { test_musician { lastName firstName dob } "
)
assert 1 == len(response["errors"])
assert (
"GRAPHQL-PARSE: Error parsing the GraphQL request string => \nquery musicianQuery { test_musician { lastName firstName dob } "
== response["errors"][0]["message"]
)
def test_graphql_bad_user(not_rest_user_client):
response = not_rest_user_client.rows.query(
graphql="query musicianQuery { test_musician { lastName firstName dob } }"
)
assert 403 == response.status_code