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

TestClient does not use data as query parameters in a get request

Open iforvard opened this issue 3 years ago • 3 comments

Why does TestClient use the data parameter only for the post request. For a get request, it is not added as query parameters?

iforvard avatar Jun 29 '22 14:06 iforvard

@iforvard could you provide an example ?

vitalik avatar Jun 29 '22 14:06 vitalik

django test client convert data to QUERY_STRING django/test/client.py

    def get(self, path, data=None, secure=False, **extra):
        """Construct a GET request."""
        data = {} if data is None else data
        return self.generic(
            "GET",
            path,
            secure=secure,
            **{
                "QUERY_STRING": urlencode(data, doseq=True),
                **extra,
            },
        )

django ninja test client not using data https://github.com/vitalik/django-ninja/blob/cc35a8c15c42a855e55bd8d24972a11ecdefa1da/ninja/testing/client.py#L133

iforvard avatar Jun 30 '22 07:06 iforvard