Skip to content

Commit

Permalink
⬆️ Bump to Django 3.2, update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos committed Jan 17, 2024
1 parent 163f381 commit d96386f
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 36 deletions.
2 changes: 1 addition & 1 deletion requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ python-decouple # processing of envvar configs
jsonschema

# Framework libraries
django < 3
django~=3.2
django-admin-index
django-axes
django-choices
Expand Down
6 changes: 5 additions & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#
# pip-compile --no-emit-index-url requirements/base.in
#
asgiref==3.7.2
# via django
attrs==20.3.0
# via
# glom
Expand Down Expand Up @@ -72,7 +74,7 @@ django-solo==1.1.5
# mozilla-django-oidc-db
# vng-api-common
# zgw-consumers
django==2.2.28
django==3.2.23
# via
# -r requirements/base.in
# django-axes
Expand Down Expand Up @@ -235,6 +237,8 @@ sqlparse==0.4.2
# via django
text-unidecode==1.3
# via faker
typing-extensions==4.9.0
# via asgiref
uritemplate==3.0.1
# via
# coreapi
Expand Down
13 changes: 9 additions & 4 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#
# pip-compile --no-emit-index-url --output-file=requirements/ci.txt requirements/base.txt requirements/test-tools.in
#
asgiref==3.7.2
# via
# -r requirements/base.txt
# django
attrs==20.3.0
# via
# -r requirements/base.txt
Expand Down Expand Up @@ -57,8 +61,6 @@ django-better-admin-arrayfield==1.4.2
# via
# -r requirements/base.txt
# mozilla-django-oidc-db
django-capture-on-commit-callbacks==1.5.0
# via -r requirements/test-tools.in
django-choices==1.7.2
# via
# -r requirements/base.txt
Expand Down Expand Up @@ -112,11 +114,10 @@ django-solo==1.1.5
# zgw-consumers
django-webtest==1.9.7
# via -r requirements/test-tools.in
django==2.2.28
django==3.2.23
# via
# -r requirements/base.txt
# django-axes
# django-capture-on-commit-callbacks
# django-choices
# django-filter
# django-formtools
Expand Down Expand Up @@ -355,6 +356,10 @@ text-unidecode==1.3
# via
# -r requirements/base.txt
# faker
typing-extensions==4.9.0
# via
# -r requirements/base.txt
# asgiref
uritemplate==3.0.1
# via
# -r requirements/base.txt
Expand Down
14 changes: 9 additions & 5 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#
alabaster==0.7.12
# via sphinx
asgiref==3.7.2
# via
# -r requirements/ci.txt
# django
attrs==20.3.0
# via
# -r requirements/ci.txt
Expand Down Expand Up @@ -77,8 +81,6 @@ django-better-admin-arrayfield==1.4.2
# via
# -r requirements/ci.txt
# mozilla-django-oidc-db
django-capture-on-commit-callbacks==1.5.0
# via -r requirements/ci.txt
django-choices==1.7.2
# via
# -r requirements/ci.txt
Expand Down Expand Up @@ -136,11 +138,10 @@ django-solo==1.1.5
# zgw-consumers
django-webtest==1.9.7
# via -r requirements/ci.txt
django==2.2.28
django==3.2.23
# via
# -r requirements/ci.txt
# django-axes
# django-capture-on-commit-callbacks
# django-choices
# django-debug-toolbar
# django-extensions
Expand Down Expand Up @@ -458,7 +459,10 @@ toml==0.10.2
tomli==2.0.1
# via black
typing-extensions==4.9.0
# via black
# via
# -r requirements/ci.txt
# asgiref
# black
uritemplate==3.0.1
# via
# -r requirements/ci.txt
Expand Down
1 change: 0 additions & 1 deletion requirements/test-tools.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Dependencies only relevant for (unit) testing
coverage < 5.0
django_capture_on_commit_callbacks
django-webtest
factory-boy
freezegun
Expand Down
2 changes: 2 additions & 0 deletions src/objects/conf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
}
}

DEFAULT_AUTO_FIELD = "django.db.models.AutoField"

# Application definition

INSTALLED_APPS = [
Expand Down
14 changes: 7 additions & 7 deletions src/objects/tests/v1/test_auth_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_retrieve_without_query(self):
},
)
self.assertEqual(
set(response._headers["x-unauthorized-fields"][1].split(",")),
set(response.headers["x-unauthorized-fields"].split(",")),
{
"uuid",
"record__data__name",
Expand Down Expand Up @@ -91,7 +91,7 @@ def test_retrieve_with_query_fields(self):
"record": {"data": {"name": record.data["name"]}},
},
)
self.assertNotIn("x-unauthorized-fields", response._headers)
self.assertNotIn("x-unauthorized-fields", response.headers)

def test_retrieve_incorrect_auth_fields(self):
PermissionFactory.create(
Expand Down Expand Up @@ -139,7 +139,7 @@ def test_retrieve_query_fields_not_allowed(self):
},
)
self.assertEqual(
response._headers["x-unauthorized-fields"][1], "record__data__desc"
response.headers["x-unauthorized-fields"], "record__data__desc"
)

def test_retrieve_no_allowed_fields(self):
Expand All @@ -160,7 +160,7 @@ def test_retrieve_no_allowed_fields(self):

self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.json(), {})
self.assertIn("x-unauthorized-fields", response._headers)
self.assertIn("x-unauthorized-fields", response.headers)


class ListAuthFieldsTests(TokenAuthMixin, APITestCase):
Expand Down Expand Up @@ -236,7 +236,7 @@ def test_list_without_query_different_object_types(self):
],
)
self.assertEqual(
response._headers["x-unauthorized-fields"][1],
response.headers["x-unauthorized-fields"],
f"{self.other_object_type.url}(1)=type; {self.object_type.url}(1)=uuid",
)

Expand Down Expand Up @@ -283,7 +283,7 @@ def test_list_with_query_fields(self):
},
],
)
self.assertNotIn("x-unauthorized-fields", response._headers)
self.assertNotIn("x-unauthorized-fields", response.headers)

def test_list_incorrect_auth_fields(self):
PermissionFactory.create(
Expand Down Expand Up @@ -376,7 +376,7 @@ def test_list_no_allowed_fields(self):

self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.json(), [{}, {}])
self.assertIn("x-unauthorized-fields", response._headers)
self.assertIn("x-unauthorized-fields", response.headers)


class SearchAuthFieldsTests(TokenAuthMixin, APITestCase):
Expand Down
9 changes: 4 additions & 5 deletions src/objects/tests/v1/test_notifications_send.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from django.test import override_settings

import requests_mock
from django_capture_on_commit_callbacks import capture_on_commit_callbacks
from freezegun import freeze_time
from rest_framework import status
from rest_framework.test import APITestCase
Expand Down Expand Up @@ -89,7 +88,7 @@ def test_send_notif_create_object(self, mocker, mock_client):
},
}

with capture_on_commit_callbacks(execute=True):
with self.captureOnCommitCallbacks(execute=True):
response = self.client.post(url, data, **GEO_WRITE_KWARGS)

self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.data)
Expand Down Expand Up @@ -141,7 +140,7 @@ def test_send_notif_update_object(self, mocker, mock_client):
},
}

with capture_on_commit_callbacks(execute=True):
with self.captureOnCommitCallbacks(execute=True):
response = self.client.put(url, data, **GEO_WRITE_KWARGS)

self.assertEqual(response.status_code, status.HTTP_200_OK, response.data)
Expand Down Expand Up @@ -193,7 +192,7 @@ def test_send_notif_partial_update_object(self, mocker, mock_client):
},
}

with capture_on_commit_callbacks(execute=True):
with self.captureOnCommitCallbacks(execute=True):
response = self.client.patch(url, data, **GEO_WRITE_KWARGS)

self.assertEqual(response.status_code, status.HTTP_200_OK, response.data)
Expand Down Expand Up @@ -232,7 +231,7 @@ def test_send_notif_delete_object(self, mocker, mock_client):
url = reverse("object-detail", args=[obj.uuid])
full_url = f"http://testserver{url}"

with capture_on_commit_callbacks(execute=True):
with self.captureOnCommitCallbacks(execute=True):
response = self.client.delete(url, **GEO_WRITE_KWARGS)

self.assertEqual(
Expand Down
14 changes: 7 additions & 7 deletions src/objects/tests/v2/test_auth_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_retrieve_without_query(self):
},
)
self.assertEqual(
set(response._headers["x-unauthorized-fields"][1].split(",")),
set(response.headers["x-unauthorized-fields"].split(",")),
{
"uuid",
"record__data__name",
Expand Down Expand Up @@ -91,7 +91,7 @@ def test_retrieve_with_query_fields(self):
"record": {"data": {"name": record.data["name"]}},
},
)
self.assertNotIn("x-unauthorized-fields", response._headers)
self.assertNotIn("x-unauthorized-fields", response.headers)

def test_retrieve_incorrect_auth_fields(self):
PermissionFactory.create(
Expand Down Expand Up @@ -139,7 +139,7 @@ def test_retrieve_query_fields_not_allowed(self):
},
)
self.assertEqual(
response._headers["x-unauthorized-fields"][1], "record__data__desc"
response.headers["x-unauthorized-fields"], "record__data__desc"
)

def test_retrieve_no_allowed_fields(self):
Expand All @@ -160,7 +160,7 @@ def test_retrieve_no_allowed_fields(self):

self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.json(), {})
self.assertIn("x-unauthorized-fields", response._headers)
self.assertIn("x-unauthorized-fields", response.headers)


class ListAuthFieldsTests(TokenAuthMixin, APITestCase):
Expand Down Expand Up @@ -236,7 +236,7 @@ def test_list_without_query_different_object_types(self):
],
)
self.assertEqual(
response._headers["x-unauthorized-fields"][1],
response.headers["x-unauthorized-fields"],
f"{self.other_object_type.url}(1)=type; {self.object_type.url}(1)=uuid",
)

Expand Down Expand Up @@ -283,7 +283,7 @@ def test_list_with_query_fields(self):
},
],
)
self.assertNotIn("x-unauthorized-fields", response._headers)
self.assertNotIn("x-unauthorized-fields", response.headers)

def test_list_incorrect_auth_fields(self):
PermissionFactory.create(
Expand Down Expand Up @@ -378,7 +378,7 @@ def test_list_no_allowed_fields(self):

self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.json()["results"], [{}, {}])
self.assertIn("x-unauthorized-fields", response._headers)
self.assertIn("x-unauthorized-fields", response.headers)


class SearchAuthFieldsTests(TokenAuthMixin, APITestCase):
Expand Down
9 changes: 4 additions & 5 deletions src/objects/tests/v2/test_notifications_send.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from django.test import override_settings

import requests_mock
from django_capture_on_commit_callbacks import capture_on_commit_callbacks
from freezegun import freeze_time
from rest_framework import status
from rest_framework.test import APITestCase
Expand Down Expand Up @@ -89,7 +88,7 @@ def test_send_notif_create_object(self, mocker, mock_client):
},
}

with capture_on_commit_callbacks(execute=True):
with self.captureOnCommitCallbacks(execute=True):
response = self.client.post(url, data, **GEO_WRITE_KWARGS)

self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.data)
Expand Down Expand Up @@ -141,7 +140,7 @@ def test_send_notif_update_object(self, mocker, mock_client):
},
}

with capture_on_commit_callbacks(execute=True):
with self.captureOnCommitCallbacks(execute=True):
response = self.client.put(url, data, **GEO_WRITE_KWARGS)

self.assertEqual(response.status_code, status.HTTP_200_OK, response.data)
Expand Down Expand Up @@ -193,7 +192,7 @@ def test_send_notif_partial_update_object(self, mocker, mock_client):
},
}

with capture_on_commit_callbacks(execute=True):
with self.captureOnCommitCallbacks(execute=True):
response = self.client.patch(url, data, **GEO_WRITE_KWARGS)

self.assertEqual(response.status_code, status.HTTP_200_OK, response.data)
Expand Down Expand Up @@ -232,7 +231,7 @@ def test_send_notif_delete_object(self, mocker, mock_client):
url = reverse("object-detail", args=[obj.uuid])
full_url = f"http://testserver{url}"

with capture_on_commit_callbacks(execute=True):
with self.captureOnCommitCallbacks(execute=True):
response = self.client.delete(url, **GEO_WRITE_KWARGS)

self.assertEqual(
Expand Down

0 comments on commit d96386f

Please sign in to comment.