Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix django examples in README. #67

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ To use pytest define a simple fixture using the query helper below
import json
import pytest
from graphene_file_upload.django.testing import file_graphql_query
from django.core.files.uploadedfile import SimpleUploadedFile

@pytest.fixture
def client_query(client):
Expand All @@ -151,8 +152,9 @@ def client_query(client):
return func

# Test your query using the client_query fixture

def test_some_query(client_query):
test_file = SimpleUploadedFile(name='test.txt', content=file_text.encode('utf-8'))
test_file = SimpleUploadedFile(name='test.txt', content=b'')
Copy link
Contributor

@jackton1 jackton1 Nov 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above


response = client_query(
'''
Expand All @@ -178,10 +180,11 @@ Your endpoint is set through the `GRAPHQL_URL` attribute on `GraphQLFileUploadTe
import json

from graphene_file_upload.django.testing import GraphQLFileUploadTestCase
from django.core.files.uploadedfile import SimpleUploadedFile

class MutationTestCase(GraphQLFileUploadTestCase):
def test_some_mutation(self):
test_file = SimpleUploadedFile(name='test.txt', content=file_text.encode('utf-8'))
test_file = SimpleUploadedFile(name='test.txt', content=b'')
Copy link
Contributor

@jackton1 jackton1 Nov 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a default content of 'test', Since the default is an empty byte string


response = self.file_query(
'''
Expand All @@ -199,6 +202,9 @@ class MutationTestCase(GraphQLFileUploadTestCase):
self.assertResponseNoErrors(response)
```

**Note**: Remember that `GraphQLFileUploadTestCase` uses a default GraphQL endpoint of '/graphql/'. Pass a different url as a kwarg into self.file_query(...) if
your GraphQl endpoint is different.

### Contributing:

If you'd like to contribute, please run the test suite prior to sending a PR.
Expand Down