From dde58ae4b1800ecc072d7c8ea4c64704d9f5aff3 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Fri, 25 Sep 2015 23:48:53 -0700 Subject: [PATCH] Added some relay tests. --- tests/relay/test_relay.py | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tests/relay/test_relay.py diff --git a/tests/relay/test_relay.py b/tests/relay/test_relay.py new file mode 100644 index 00000000..c532949f --- /dev/null +++ b/tests/relay/test_relay.py @@ -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)