Skip to content

Commit 57ba5e7

Browse files
committed
Remove redundant tests & fix tox.
1 parent 4e08819 commit 57ba5e7

File tree

2 files changed

+3
-72
lines changed

2 files changed

+3
-72
lines changed

graphene/contrib/django/tests/test_views.py

Lines changed: 1 addition & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -5,68 +5,6 @@ def format_response(response):
55
return json.loads(response.content.decode())
66

77

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-
708
def test_client_get_good_query(settings, client):
719
settings.ROOT_URLCONF = 'graphene.contrib.django.tests.test_urls'
7210
response = client.get('/graphql', {'query': '{ headline }'})
@@ -83,8 +21,7 @@ def test_client_get_good_query_with_raise(settings, client):
8321
settings.ROOT_URLCONF = 'graphene.contrib.django.tests.test_urls'
8422
response = client.get('/graphql', {'query': '{ raises }'})
8523
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'
8825
assert json_response['data']['raises'] is None
8926

9027

@@ -112,10 +49,3 @@ def test_client_post_good_query_graphql(settings, client):
11249
}
11350
}
11451
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.'}]}

tox.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ deps=
1313
six
1414
blinker
1515
singledispatch
16+
mock
1617
setenv =
1718
PYTHONPATH = .:{envdir}
1819
commands=
19-
py.test tests/ examples/
20+
py.test
2021

2122
[testenv:flake8]
2223
deps = flake8

0 commit comments

Comments
 (0)