mirror of
				https://github.com/graphql-python/graphene.git
				synced 2025-11-04 18:07:48 +03:00 
			
		
		
		
	Added some relay tests.
This commit is contained in:
		
							parent
							
								
									2d87f527bf
								
							
						
					
					
						commit
						dde58ae4b1
					
				
							
								
								
									
										41
									
								
								tests/relay/test_relay.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								tests/relay/test_relay.py
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,41 @@
 | 
				
			||||||
 | 
					from pytest import raises
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import graphene
 | 
				
			||||||
 | 
					from graphene import relay
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class OtherNode(relay.Node):
 | 
				
			||||||
 | 
					    name = graphene.StringField()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @classmethod
 | 
				
			||||||
 | 
					    def get_node(cls, id):
 | 
				
			||||||
 | 
					        pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def test_field_no_contributed_raises_error():
 | 
				
			||||||
 | 
					    with raises(Exception) as excinfo:
 | 
				
			||||||
 | 
					        class Part(relay.Node):
 | 
				
			||||||
 | 
					            x = graphene.StringField()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    assert 'get_node' in str(excinfo.value)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def test_node_should_have_connection():
 | 
				
			||||||
 | 
					    assert OtherNode.connection
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def test_node_should_have_id_field():
 | 
				
			||||||
 | 
					    assert 'id' in OtherNode._meta.fields_map
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def test_field_no_contributed_raises_error():
 | 
				
			||||||
 | 
					    with raises(Exception) as excinfo:
 | 
				
			||||||
 | 
					        class Ship(graphene.ObjectType):
 | 
				
			||||||
 | 
					            name = graphene.StringField()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        class Faction(relay.Node):
 | 
				
			||||||
 | 
					            name = graphene.StringField()
 | 
				
			||||||
 | 
					            ships = relay.ConnectionField(Ship)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    assert 'same type_name' in str(excinfo.value)
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user