def test_schema_register_no_query_type(): schema = Schema(name='My own schema') @schema.register class MyType(ObjectType): type = String(resolver=lambda *_: 'Dog') with raises(Exception) as excinfo: schema.get_type('MyType') assert 'base query type' in str(excinfo.value)
def test_schema_register_no_query_type(): schema = Schema(name="My own schema") @schema.register class MyType(ObjectType): type = String(resolver=lambda *_: "Dog") with raises(Exception) as excinfo: schema.get_type("MyType") assert "base query type" in str(excinfo.value)
def test_filter_filterset_information_on_meta_related(): class ReporterFilterNode(DjangoNode): class Meta: model = Reporter filter_fields = ['first_name', 'articles'] filter_order_by = True class ArticleFilterNode(DjangoNode): class Meta: model = Article filter_fields = ['headline', 'reporter'] filter_order_by = True class Query(ObjectType): all_reporters = DjangoFilterConnectionField(ReporterFilterNode) all_articles = DjangoFilterConnectionField(ArticleFilterNode) reporter = NodeField(ReporterFilterNode) article = NodeField(ArticleFilterNode) schema = Schema(query=Query) schema.schema # Trigger the schema loading articles_field = schema.get_type( 'ReporterFilterNode')._meta.fields_map['articles'] assert_arguments(articles_field, 'headline', 'reporter') assert_orderable(articles_field)
def test_filter_filterset_information_on_meta_related(): class ReporterFilterNode(DjangoNode): class Meta: model = Reporter filter_fields = ['first_name', 'articles'] filter_order_by = True class ArticleFilterNode(DjangoNode): class Meta: model = Article filter_fields = ['headline', 'reporter'] filter_order_by = True class Query(ObjectType): all_reporters = DjangoFilterConnectionField(ReporterFilterNode) all_articles = DjangoFilterConnectionField(ArticleFilterNode) reporter = NodeField(ReporterFilterNode) article = NodeField(ArticleFilterNode) schema = Schema(query=Query) schema.schema # Trigger the schema loading articles_field = schema.get_type('ReporterFilterNode')._meta.fields_map['articles'] assert_arguments(articles_field, 'headline', 'reporter') assert_orderable(articles_field)
def test_schema_register(): schema = Schema(name="My own schema") @schema.register class MyType(ObjectType): type = StringField(resolve=lambda *_: "Dog") assert schema.get_type("MyType") == MyType
def test_schema_register(): schema = Schema(name='My own schema') @schema.register class MyType(ObjectType): type = String(resolver=lambda *_: 'Dog') schema.query = MyType assert schema.get_type('MyType') == MyType