mirror of
				https://github.com/graphql-python/graphene-django.git
				synced 2025-11-04 18:08:01 +03:00 
			
		
		
		
	Add tests
This commit is contained in:
		
							parent
							
								
									86f7f7a51b
								
							
						
					
					
						commit
						d7fec08168
					
				| 
						 | 
					@ -1,6 +1,8 @@
 | 
				
			||||||
import datetime
 | 
					import datetime
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from py.test import mark, raises
 | 
					from py.test import mark, raises
 | 
				
			||||||
 | 
					from rest_framework.exceptions import ValidationError
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from rest_framework import serializers
 | 
					from rest_framework import serializers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from graphene import Field, ResolveInfo
 | 
					from graphene import Field, ResolveInfo
 | 
				
			||||||
| 
						 | 
					@ -204,18 +206,21 @@ def test_mutate_and_get_payload_error():
 | 
				
			||||||
            serializer_class = MySerializer
 | 
					            serializer_class = MySerializer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # missing required fields
 | 
					    # missing required fields
 | 
				
			||||||
 | 
					    with raises(ValidationError):
 | 
				
			||||||
        result = MyMutation.mutate_and_get_payload(None, mock_info(), **{})
 | 
					        result = MyMutation.mutate_and_get_payload(None, mock_info(), **{})
 | 
				
			||||||
        assert len(result.errors) > 0
 | 
					        assert len(result.errors) > 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_model_mutate_and_get_payload_error():
 | 
					def test_model_mutate_and_get_payload_error():
 | 
				
			||||||
    # missing required fields
 | 
					    # missing required fields
 | 
				
			||||||
 | 
					    with raises(ValidationError):
 | 
				
			||||||
        result = MyModelMutation.mutate_and_get_payload(None, mock_info(), **{})
 | 
					        result = MyModelMutation.mutate_and_get_payload(None, mock_info(), **{})
 | 
				
			||||||
        assert len(result.errors) > 0
 | 
					        assert len(result.errors) > 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_mutation_error_camelcased():
 | 
					def test_mutation_error_camelcased():
 | 
				
			||||||
    graphene_settings.CAMELCASE_ERRORS = True
 | 
					    graphene_settings.CAMELCASE_ERRORS = True
 | 
				
			||||||
 | 
					    with raises(ValidationError):
 | 
				
			||||||
        result = MyModelMutation.mutate_and_get_payload(None, mock_info(), **{})
 | 
					        result = MyModelMutation.mutate_and_get_payload(None, mock_info(), **{})
 | 
				
			||||||
        assert result.errors[0].field == "coolName"
 | 
					        assert result.errors[0].field == "coolName"
 | 
				
			||||||
    graphene_settings.CAMELCASE_ERRORS = False
 | 
					    graphene_settings.CAMELCASE_ERRORS = False
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user