Generalize testing.file_graphql_query #68
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Generalized django.testing.file_graphql_query to other frameworks than Django
Background
Although graphene_file_upload.django.testing.file_graphql_query is imported in the example of testing for flask, as metioned in issue #59 , file_graphql_query depends on Django for using django.testing.Client as default argument.
However, it seems almost all codes in file_graphql_query are not specialized for Django. The only point tightly coupled with Django is the argument structure of django.testing.Client.post method.
Test client of other frameworks, such as flask.testing.FlaskClient or fastapi.testclinet.TestClient, also has post method, but their argument is slightly different from Django's one.
Examples of differences are below.
It would be useful to modify file_graphql_query to be able to absorb framework's test client differences.
Implements
All logics in file_graphql_query which are not coupled with Django ara moved into, testingbase.py, and client argument is changed into client_post argument. client_post argument is a function that abstracts post method of each frameworks' test client post methods. It receives endpoint, data, files, and headers.
And testing.py for each frameworks(in /graphene_file_upload/django/testing and /graphene_file_upload/flask/testing) implements client_post using framework specific test client. I only implemented for only Django and Flask, but testingbase.file_graphql_query can be applicable for any other frameworks such as FastAPI.