mbrochh / django-graphql-apollo-react-demo

Code for a workshop about my Django, GraphQL, ReactJS, Apollo-stack
332 stars 78 forks source link

add example for how to test functions on the Type classes #4

Open mbrochh opened 7 years ago

mbrochh commented 7 years ago

Something like this:

        from graphene.test import Client
        c = Client(root_schema)
        resp = c.execute('''
            {
                allSizesForProduct(productPk: 1) {
                    pk, inCm
                }
            }
        ''')
        res = resp['data']['allSizesForProduct'][0]
        self.assertEqual(res['pk'], 1, msg=(
            'Should return the pk of the item'))