mirror of
				https://github.com/graphql-python/graphene.git
				synced 2025-11-04 01:47:45 +03:00 
			
		
		
		
	Remove redundant tests & fix tox.
This commit is contained in:
		
							parent
							
								
									4e08819094
								
							
						
					
					
						commit
						57ba5e71f9
					
				| 
						 | 
				
			
			@ -5,68 +5,6 @@ def format_response(response):
 | 
			
		|||
    return json.loads(response.content.decode())
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_client_get_no_query(settings, client):
 | 
			
		||||
    settings.ROOT_URLCONF = 'graphene.contrib.django.tests.test_urls'
 | 
			
		||||
    response = client.get('/graphql')
 | 
			
		||||
    json_response = format_response(response)
 | 
			
		||||
    assert json_response == {'errors': [
 | 
			
		||||
        {'message': 'Must provide query string.'}]}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_client_post_no_query(settings, client):
 | 
			
		||||
    settings.ROOT_URLCONF = 'graphene.contrib.django.tests.test_urls'
 | 
			
		||||
    response = client.post('/graphql', {})
 | 
			
		||||
    json_response = format_response(response)
 | 
			
		||||
    assert json_response == {'errors': [
 | 
			
		||||
        {'message': 'Must provide query string.'}]}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_client_post_malformed_json(settings, client):
 | 
			
		||||
    settings.ROOT_URLCONF = 'graphene.contrib.django.tests.test_urls'
 | 
			
		||||
    response = client.post('/graphql', 'MALFORMED', 'application/json')
 | 
			
		||||
    json_response = format_response(response)
 | 
			
		||||
    assert json_response == {'errors': [
 | 
			
		||||
        {'message': 'POST body sent invalid JSON.'}]}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_client_post_empty_query_json(settings, client):
 | 
			
		||||
    settings.ROOT_URLCONF = 'graphene.contrib.django.tests.test_urls'
 | 
			
		||||
    response = client.post(
 | 
			
		||||
        '/graphql', json.dumps({'query': ''}), 'application/json')
 | 
			
		||||
    json_response = format_response(response)
 | 
			
		||||
    assert json_response == {'errors': [
 | 
			
		||||
        {'message': 'Must provide query string.'}]}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_client_post_empty_query_graphql(settings, client):
 | 
			
		||||
    settings.ROOT_URLCONF = 'graphene.contrib.django.tests.test_urls'
 | 
			
		||||
    response = client.post(
 | 
			
		||||
        '/graphql', '', 'application/graphql')
 | 
			
		||||
    json_response = format_response(response)
 | 
			
		||||
    assert json_response == {'errors': [
 | 
			
		||||
        {'message': 'Must provide query string.'}]}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_client_post_bad_query_json(settings, client):
 | 
			
		||||
    settings.ROOT_URLCONF = 'graphene.contrib.django.tests.test_urls'
 | 
			
		||||
    response = client.post(
 | 
			
		||||
        '/graphql', json.dumps({'query': '{ MALFORMED'}), 'application/json')
 | 
			
		||||
    json_response = format_response(response)
 | 
			
		||||
    assert 'errors' in json_response
 | 
			
		||||
    assert len(json_response['errors']) == 1
 | 
			
		||||
    assert 'Syntax Error GraphQL' in json_response['errors'][0]['message']
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_client_post_bad_query_graphql(settings, client):
 | 
			
		||||
    settings.ROOT_URLCONF = 'graphene.contrib.django.tests.test_urls'
 | 
			
		||||
    response = client.post(
 | 
			
		||||
        '/graphql', '{ MALFORMED', 'application/graphql')
 | 
			
		||||
    json_response = format_response(response)
 | 
			
		||||
    assert 'errors' in json_response
 | 
			
		||||
    assert len(json_response['errors']) == 1
 | 
			
		||||
    assert 'Syntax Error GraphQL' in json_response['errors'][0]['message']
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_client_get_good_query(settings, client):
 | 
			
		||||
    settings.ROOT_URLCONF = 'graphene.contrib.django.tests.test_urls'
 | 
			
		||||
    response = client.get('/graphql', {'query': '{ headline }'})
 | 
			
		||||
| 
						 | 
				
			
			@ -83,8 +21,7 @@ def test_client_get_good_query_with_raise(settings, client):
 | 
			
		|||
    settings.ROOT_URLCONF = 'graphene.contrib.django.tests.test_urls'
 | 
			
		||||
    response = client.get('/graphql', {'query': '{ raises }'})
 | 
			
		||||
    json_response = format_response(response)
 | 
			
		||||
    assert json_response['errors'][0][
 | 
			
		||||
        'message'] == 'This field should raise exception'
 | 
			
		||||
    assert json_response['errors'][0]['message'] == 'This field should raise exception'
 | 
			
		||||
    assert json_response['data']['raises'] is None
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -112,10 +49,3 @@ def test_client_post_good_query_graphql(settings, client):
 | 
			
		|||
        }
 | 
			
		||||
    }
 | 
			
		||||
    assert json_response == expected_json
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# def test_client_get_bad_query(settings, client):
 | 
			
		||||
#     settings.ROOT_URLCONF = 'graphene.contrib.django.tests.test_urls'
 | 
			
		||||
#     response = client.get('/graphql')
 | 
			
		||||
#     json_response = format_response(response)
 | 
			
		||||
#     assert json_response == {'errors': [{'message': 'Must provide query string.'}]}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user