mirror of
				https://github.com/graphql-python/graphene-django.git
				synced 2025-11-04 09:57:53 +03:00 
			
		
		
		
	* Fix Star Wars spaceship name * Fix some typos in comments * Typo fixes * More typo fixes
		
			
				
	
	
		
			54 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			54 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
import pytest
 | 
						|
 | 
						|
from ..data import initialize
 | 
						|
from ..schema import schema
 | 
						|
 | 
						|
pytestmark = pytest.mark.django_db
 | 
						|
 | 
						|
 | 
						|
def test_mutations():
 | 
						|
    initialize()
 | 
						|
 | 
						|
    query = """
 | 
						|
    mutation MyMutation {
 | 
						|
      introduceShip(input:{clientMutationId:"abc", shipName: "Peter", factionId: "1"}) {
 | 
						|
        ship {
 | 
						|
          id
 | 
						|
          name
 | 
						|
        }
 | 
						|
        faction {
 | 
						|
          name
 | 
						|
          ships {
 | 
						|
            edges {
 | 
						|
              node {
 | 
						|
                id
 | 
						|
                name
 | 
						|
              }
 | 
						|
            }
 | 
						|
          }
 | 
						|
        }
 | 
						|
      }
 | 
						|
    }
 | 
						|
    """
 | 
						|
    expected = {
 | 
						|
        "introduceShip": {
 | 
						|
            "ship": {"id": "U2hpcDo5", "name": "Peter"},
 | 
						|
            "faction": {
 | 
						|
                "name": "Alliance to Restore the Republic",
 | 
						|
                "ships": {
 | 
						|
                    "edges": [
 | 
						|
                        {"node": {"id": "U2hpcDox", "name": "X-Wing"}},
 | 
						|
                        {"node": {"id": "U2hpcDoy", "name": "Y-Wing"}},
 | 
						|
                        {"node": {"id": "U2hpcDoz", "name": "A-Wing"}},
 | 
						|
                        {"node": {"id": "U2hpcDo0", "name": "Millennium Falcon"}},
 | 
						|
                        {"node": {"id": "U2hpcDo1", "name": "Home One"}},
 | 
						|
                        {"node": {"id": "U2hpcDo5", "name": "Peter"}},
 | 
						|
                    ]
 | 
						|
                },
 | 
						|
            },
 | 
						|
        }
 | 
						|
    }
 | 
						|
    result = schema.execute(query)
 | 
						|
    assert not result.errors
 | 
						|
    assert result.data == expected
 |