[PATCH 1/4] Enforce ordering of bundles in REST test

Stephen Finucane stephen at that.guru
Fri Sep 8 04:18:32 AEST 2017


On Mon, 2017-09-04 at 01:14 +1000, Daniel Axtens wrote:
> This is required to make the tests pass on a recent version of
> postgres.
> 
> Signed-off-by: Daniel Axtens <dja at axtens.net>
> ---
>  patchwork/tests/test_rest_api.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/patchwork/tests/test_rest_api.py
> b/patchwork/tests/test_rest_api.py
> index abffd17fddec..d4a84bd8c5ad 100644
> --- a/patchwork/tests/test_rest_api.py
> +++ b/patchwork/tests/test_rest_api.py
> @@ -738,7 +738,7 @@ class TestBundleAPI(APITestCase):
>          # authenticated user
>          # should see the public and private bundle
>          self.client.force_authenticate(user=user)
> -        resp = self.client.get(self.api_url())
> +        resp = self.client.get(self.api_url() + '?order=id')

Maybe I'm misunderstanding things here, but doesn't this suggest users would
always need to add the 'order' filter just to get things working sanely on a
PostgreSQL-backed instance? If so that doesn't sound very useful, and it would
suggest that the test is doing its job.

It doesn't seem like there's a way to apply a default filter using the
'OrderingFilter' [1]. However, could we simply add a sort to the queryset
returned by 'patchwork.api.bundle.BundleFilter.get_queryset'?

>          self.assertEqual(status.HTTP_200_OK, resp.status_code)
>          self.assertEqual(2, len(resp.data))
>          for bundle_rsp, bundle_obj in zip(

Stephen

[1] http://www.django-rest-framework.org/api-guide/filtering/#orderingfilter


More information about the Patchwork mailing list