Skip to content

Commit 3682fe0

Browse files
committed
Test of inherited class
1 parent 2cb3d4b commit 3682fe0

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

graphene_django/tests/test_views.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,24 @@ def test_allows_post_with_get_operation_name(client):
386386
}
387387

388388

389+
@pytest.mark.urls('graphene_django.tests.urls_inherited')
390+
def test_inherited_class_with_attributes_works(client):
391+
inherited_url = '/graphql/inherited/'
392+
# Check schema and pretty attributes work
393+
response = client.post(url_string(inherited_url, query='{test}'))
394+
assert response.content.decode() == (
395+
'{\n'
396+
' "data": {\n'
397+
' "test": "Hello World"\n'
398+
' }\n'
399+
'}'
400+
)
401+
402+
# Check graphiql works
403+
response = client.get(url_string(inherited_url), HTTP_ACCEPT='text/html')
404+
assert response.status_code == 200
405+
406+
389407
@pytest.mark.urls('graphene_django.tests.urls_pretty')
390408
def test_supports_pretty_printing(client):
391409
response = client.get(url_string(query='{test}'))
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from django.conf.urls import url
2+
3+
from ..views import GraphQLView
4+
from .schema_view import schema
5+
6+
class CustomGraphQLView(GraphQLView):
7+
schema = schema
8+
graphiql = True
9+
pretty = True
10+
11+
12+
urlpatterns = [
13+
url(r'^graphql/inherited/$', CustomGraphQLView.as_view()),
14+
]

0 commit comments

Comments
 (0)