diff --git a/README.md b/README.md index dae2330..e25ae40 100644 --- a/README.md +++ b/README.md @@ -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): @@ -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'') response = client_query( ''' @@ -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'') response = self.file_query( ''' @@ -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.