@@ -5,68 +5,6 @@ def format_response(response):
5
5
return json .loads (response .content .decode ())
6
6
7
7
8
- def test_client_get_no_query (settings , client ):
9
- settings .ROOT_URLCONF = 'graphene.contrib.django.tests.test_urls'
10
- response = client .get ('/graphql' )
11
- json_response = format_response (response )
12
- assert json_response == {'errors' : [
13
- {'message' : 'Must provide query string.' }]}
14
-
15
-
16
- def test_client_post_no_query (settings , client ):
17
- settings .ROOT_URLCONF = 'graphene.contrib.django.tests.test_urls'
18
- response = client .post ('/graphql' , {})
19
- json_response = format_response (response )
20
- assert json_response == {'errors' : [
21
- {'message' : 'Must provide query string.' }]}
22
-
23
-
24
- def test_client_post_malformed_json (settings , client ):
25
- settings .ROOT_URLCONF = 'graphene.contrib.django.tests.test_urls'
26
- response = client .post ('/graphql' , 'MALFORMED' , 'application/json' )
27
- json_response = format_response (response )
28
- assert json_response == {'errors' : [
29
- {'message' : 'POST body sent invalid JSON.' }]}
30
-
31
-
32
- def test_client_post_empty_query_json (settings , client ):
33
- settings .ROOT_URLCONF = 'graphene.contrib.django.tests.test_urls'
34
- response = client .post (
35
- '/graphql' , json .dumps ({'query' : '' }), 'application/json' )
36
- json_response = format_response (response )
37
- assert json_response == {'errors' : [
38
- {'message' : 'Must provide query string.' }]}
39
-
40
-
41
- def test_client_post_empty_query_graphql (settings , client ):
42
- settings .ROOT_URLCONF = 'graphene.contrib.django.tests.test_urls'
43
- response = client .post (
44
- '/graphql' , '' , 'application/graphql' )
45
- json_response = format_response (response )
46
- assert json_response == {'errors' : [
47
- {'message' : 'Must provide query string.' }]}
48
-
49
-
50
- def test_client_post_bad_query_json (settings , client ):
51
- settings .ROOT_URLCONF = 'graphene.contrib.django.tests.test_urls'
52
- response = client .post (
53
- '/graphql' , json .dumps ({'query' : '{ MALFORMED' }), 'application/json' )
54
- json_response = format_response (response )
55
- assert 'errors' in json_response
56
- assert len (json_response ['errors' ]) == 1
57
- assert 'Syntax Error GraphQL' in json_response ['errors' ][0 ]['message' ]
58
-
59
-
60
- def test_client_post_bad_query_graphql (settings , client ):
61
- settings .ROOT_URLCONF = 'graphene.contrib.django.tests.test_urls'
62
- response = client .post (
63
- '/graphql' , '{ MALFORMED' , 'application/graphql' )
64
- json_response = format_response (response )
65
- assert 'errors' in json_response
66
- assert len (json_response ['errors' ]) == 1
67
- assert 'Syntax Error GraphQL' in json_response ['errors' ][0 ]['message' ]
68
-
69
-
70
8
def test_client_get_good_query (settings , client ):
71
9
settings .ROOT_URLCONF = 'graphene.contrib.django.tests.test_urls'
72
10
response = client .get ('/graphql' , {'query' : '{ headline }' })
@@ -83,8 +21,7 @@ def test_client_get_good_query_with_raise(settings, client):
83
21
settings .ROOT_URLCONF = 'graphene.contrib.django.tests.test_urls'
84
22
response = client .get ('/graphql' , {'query' : '{ raises }' })
85
23
json_response = format_response (response )
86
- assert json_response ['errors' ][0 ][
87
- 'message' ] == 'This field should raise exception'
24
+ assert json_response ['errors' ][0 ]['message' ] == 'This field should raise exception'
88
25
assert json_response ['data' ]['raises' ] is None
89
26
90
27
@@ -112,10 +49,3 @@ def test_client_post_good_query_graphql(settings, client):
112
49
}
113
50
}
114
51
assert json_response == expected_json
115
-
116
-
117
- # def test_client_get_bad_query(settings, client):
118
- # settings.ROOT_URLCONF = 'graphene.contrib.django.tests.test_urls'
119
- # response = client.get('/graphql')
120
- # json_response = format_response(response)
121
- # assert json_response == {'errors': [{'message': 'Must provide query string.'}]}
0 commit comments