@@ -7,32 +7,36 @@ def format_response(response):
7
7
8
8
def test_client_get_good_query (settings , client ):
9
9
settings .ROOT_URLCONF = 'graphene.contrib.django.tests.test_urls'
10
- response = client .get ('/graphql' , {'query' : '{ headline }' })
10
+ response = client .get ('/graphql' , {'query' : '{ human { headline } }' })
11
11
json_response = format_response (response )
12
12
expected_json = {
13
13
'data' : {
14
- 'headline' : None
14
+ 'human' : {
15
+ 'headline' : None
16
+ }
15
17
}
16
18
}
17
19
assert json_response == expected_json
18
20
19
21
20
22
def test_client_get_good_query_with_raise (settings , client ):
21
23
settings .ROOT_URLCONF = 'graphene.contrib.django.tests.test_urls'
22
- response = client .get ('/graphql' , {'query' : '{ raises }' })
24
+ response = client .get ('/graphql' , {'query' : '{ human { raises } }' })
23
25
json_response = format_response (response )
24
26
assert json_response ['errors' ][0 ]['message' ] == 'This field should raise exception'
25
- assert json_response ['data' ]['raises' ] is None
27
+ assert json_response ['data' ]['human' ][ ' raises' ] is None
26
28
27
29
28
30
def test_client_post_good_query_json (settings , client ):
29
31
settings .ROOT_URLCONF = 'graphene.contrib.django.tests.test_urls'
30
32
response = client .post (
31
- '/graphql' , json .dumps ({'query' : '{ headline }' }), 'application/json' )
33
+ '/graphql' , json .dumps ({'query' : '{ human { headline } }' }), 'application/json' )
32
34
json_response = format_response (response )
33
35
expected_json = {
34
36
'data' : {
35
- 'headline' : None
37
+ 'human' : {
38
+ 'headline' : None
39
+ }
36
40
}
37
41
}
38
42
assert json_response == expected_json
@@ -41,11 +45,13 @@ def test_client_post_good_query_json(settings, client):
41
45
def test_client_post_good_query_graphql (settings , client ):
42
46
settings .ROOT_URLCONF = 'graphene.contrib.django.tests.test_urls'
43
47
response = client .post (
44
- '/graphql' , '{ headline }' , 'application/graphql' )
48
+ '/graphql' , '{ human { headline } }' , 'application/graphql' )
45
49
json_response = format_response (response )
46
50
expected_json = {
47
51
'data' : {
48
- 'headline' : None
52
+ 'human' : {
53
+ 'headline' : None
54
+ }
49
55
}
50
56
}
51
57
assert json_response == expected_json
0 commit comments