graphene-django icon indicating copy to clipboard operation
graphene-django copied to clipboard

Add section on automated testing to cookbook tutorial

Open joyhchen opened this issue 8 years ago • 2 comments

The official Django tutorial covers writing automated tests. I know there is a section on testing in the Graphene docs, but I think it would help if this was adapted to the cookbook tutorial. I'm wondering if this is something open for discussion or if the plan is to keep the introductory tutorial as short as possible.

joyhchen avatar Jul 13 '18 16:07 joyhchen

@joychen I think they will be like standard django tests only. Just pass the query or mutation string as data.

from django.urls import reverse
from django.test import Client as BaseClient


class Client(BaseClient):
    url = reverse("graphql")

    def query(self, query):
        response = self.get(path=self.url, data={"query": query})
return response

anudeepsamaiya avatar Apr 09 '19 06:04 anudeepsamaiya

Agreed, there's some room for improvement here @joyhchen. We've made some strides on the docs end and we're going to continue to harmonize it with the cookbook example. I'm going to close this because it is in good-enough-for-now territory but do know we'll continue to improve the docs.

dopeboy avatar May 08 '19 06:05 dopeboy