ansible / django-ansible-base

Apache License 2.0
18 stars 49 forks source link

Several unordered querysets #178

Open AlanCoding opened 9 months ago

AlanCoding commented 9 months ago

This is warned about in test results

2024-03-01T04:04:54.0593164Z   /home/runner/work/django-ansible-base/django-ansible-base/.tox/py311/lib/python3.11/site-packages/rest_framework/pagination.py:200: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: <class 'ansible_base.authentication.models.authenticator.Authenticator'> QuerySet.
2024-03-01T04:04:54.0594929Z     paginator = self.django_paginator_class(queryset, page_size)
2024-03-01T04:04:54.0595253Z 
2024-03-01T04:04:54.0595599Z test_app/tests/jwt_consumer/common/test_auth.py::TestJWTCommonAuth::test_parse_jwt_happy_path
2024-03-01T04:04:54.0596873Z   /home/runner/work/django-ansible-base/django-ansible-base/ansible_base/jwt_consumer/common/auth.py:60: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead
2024-03-01T04:04:54.0597913Z     logger.warn(f"New user {user.username} created from JWT auth")
2024-03-01T04:04:54.0598241Z 
2024-03-01T04:04:54.0598540Z test_app/tests/resource_registry/test_resource_types_api.py::test_resource_type_list
2024-03-01T04:04:54.0600441Z   /home/runner/work/django-ansible-base/django-ansible-base/.tox/py311/lib/python3.11/site-packages/rest_framework/pagination.py:200: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: <class 'ansible_base.resource_registry.models.resource.ResourceType'> QuerySet.
2024-03-01T04:04:54.0602251Z     paginator = self.django_paginator_class(queryset, page_size)
2024-03-01T04:04:54.0602578Z 
2024-03-01T04:04:54.0602842Z test_app/tests/resource_registry/test_resources_api.py::test_resources_list
2024-03-01T04:04:54.0604670Z   /home/runner/work/django-ansible-base/django-ansible-base/.tox/py311/lib/python3.11/site-packages/rest_framework/pagination.py:200: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: <class 'ansible_base.resource_registry.models.resource.Resource'> QuerySet.
2024-03-01T04:04:54.0606245Z     paginator = self.django_paginator_class(queryset, page_size)

These are views vendored by DAB, so this is a DAB issue. These need to have ordering added.

AlanCoding commented 9 months ago

Considering:

https://stackoverflow.com/questions/54831333/how-do-i-make-pytest-crash-on-a-warning

pytest -W error::RuntimeWarning

Right? Less tech debt. Don't let it in to begin with.