-
Notifications
You must be signed in to change notification settings - Fork 387
Expand file tree
/
Copy pathgraphql_test.py
More file actions
45 lines (41 loc) · 1.31 KB
/
graphql_test.py
File metadata and controls
45 lines (41 loc) · 1.31 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
41
42
43
44
45
import shopify
from test.test_helper import TestCase
class GraphQLTest(TestCase):
def setUp(self):
super(GraphQLTest, self).setUp()
shopify.ApiVersion.define_known_versions()
shopify_session = shopify.Session("this-is-my-test-show.myshopify.com", "unstable", "token")
shopify.ShopifyResource.activate_session(shopify_session)
self.client = shopify.GraphQL()
self.fake(
"graphql",
method="POST",
code=201,
headers={
"X-Shopify-Access-Token": "token",
"Accept": "application/json",
"Content-Type": "application/json",
},
)
def test_fetch_shop_with_graphql(self):
query = """
{
shop {
name
id
}
}
"""
result = self.client.execute(query)
self.assertTrue(result["shop"]["name"] == "Apple Computers")
def test_specify_operation_name(self):
query = """
query GetShop{
shop {
name
id
}
}
"""
result = self.client.execute(query, operation_name="GetShop")
self.assertTrue(result["shop"]["name"] == "Apple Computers")