Skip to content

Commit 35ecc51

Browse files
✅ [#550] Fix tests
1 parent 5f742ac commit 35ecc51

File tree

6 files changed

+27
-20
lines changed

6 files changed

+27
-20
lines changed

requirements/base.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ asgiref==3.7.2
1616
# django-cors-headers
1717
asn1crypto==1.5.1
1818
# via webauthn
19-
attrs==25.3.0
19+
attrs==20.3.0
2020
# via
2121
# glom
2222
# jsonschema

requirements/ci.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ asn1crypto==1.5.1
3131
# -c requirements/base.txt
3232
# -r requirements/base.txt
3333
# webauthn
34-
attrs==25.3.0
34+
attrs==20.3.0
3535
# via
3636
# -c requirements/base.txt
3737
# -r requirements/base.txt
@@ -515,7 +515,7 @@ phonenumberslite==8.13.30
515515
# -c requirements/base.txt
516516
# -r requirements/base.txt
517517
# django-two-factor-auth
518-
platformdirs==4.3.7
518+
platformdirs==4.3.3
519519
# via black
520520
pluggy==1.5.0
521521
# via pytest

requirements/dev.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ asn1crypto==1.5.1
3636
# -c requirements/ci.txt
3737
# -r requirements/ci.txt
3838
# webauthn
39-
attrs==25.3.0
39+
attrs==20.3.0
4040
# via
4141
# -c requirements/ci.txt
4242
# -r requirements/ci.txt
@@ -614,7 +614,7 @@ pip==24.3.1
614614
# via pip-tools
615615
pip-tools==7.4.1
616616
# via -r requirements/dev.in
617-
platformdirs==4.3.7
617+
platformdirs==4.3.3
618618
# via
619619
# -c requirements/ci.txt
620620
# -r requirements/ci.txt

src/objects/tests/v2/test_jsonschema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from objects.core.tests.factories import ObjectTypeFactory
99
from objects.token.constants import PermissionModes
1010
from objects.token.tests.factories import PermissionFactory
11-
from objects.utils.test import TokenAuthMixin
11+
from objects.utils.test import ClearCachesMixin, TokenAuthMixin
1212

1313
from ..constants import GEO_WRITE_KWARGS
1414
from ..utils import mock_objecttype, mock_objecttype_version, mock_service_oas_get
@@ -18,7 +18,7 @@
1818

1919

2020
@requests_mock.Mocker()
21-
class JsonSchemaTests(TokenAuthMixin, APITestCase):
21+
class JsonSchemaTests(TokenAuthMixin, ClearCachesMixin, APITestCase):
2222
"""GH issue - https://github.com/maykinmedia/objects-api/issues/330"""
2323

2424
@classmethod

src/objects/tests/v2/test_validation.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from objects.core.tests.factories import ObjectRecordFactory, ObjectTypeFactory
1010
from objects.token.constants import PermissionModes
1111
from objects.token.tests.factories import PermissionFactory
12-
from objects.utils.test import TokenAuthMixin
12+
from objects.utils.test import ClearCachesMixin, TokenAuthMixin
1313

1414
from ..constants import GEO_WRITE_KWARGS
1515
from ..utils import mock_objecttype, mock_objecttype_version, mock_service_oas_get
@@ -19,7 +19,7 @@
1919

2020

2121
@requests_mock.Mocker()
22-
class ObjectTypeValidationTests(TokenAuthMixin, APITestCase):
22+
class ObjectTypeValidationTests(TokenAuthMixin, ClearCachesMixin, APITestCase):
2323
@classmethod
2424
def setUpTestData(cls):
2525
super().setUpTestData()
@@ -101,9 +101,7 @@ def test_create_object_no_version(self, m):
101101
self.assertEqual(Object.objects.count(), 0)
102102

103103
data = response.json()
104-
self.assertEqual(
105-
data["non_field_errors"], ["Object type doesn't have retrievable data."]
106-
)
104+
self.assertEqual(data["type"], ["Object type doesn't have retrievable data."])
107105

108106
def test_create_object_objecttype_request_error(self, m):
109107
mock_service_oas_get(m, OBJECT_TYPES_API, "objecttypes")
@@ -125,9 +123,7 @@ def test_create_object_objecttype_request_error(self, m):
125123
self.assertEqual(Object.objects.count(), 0)
126124

127125
data = response.json()
128-
self.assertEqual(
129-
data["non_field_errors"], ["Object type version can not be retrieved."]
130-
)
126+
self.assertEqual(data["type"], ["Object type version can not be retrieved."])
131127

132128
def test_create_object_objecttype_with_no_jsonSchema(self, m):
133129
mock_service_oas_get(m, OBJECT_TYPES_API, "objecttypes")
@@ -154,9 +150,9 @@ def test_create_object_objecttype_with_no_jsonSchema(self, m):
154150

155151
data = response.json()
156152
self.assertEqual(
157-
data["non_field_errors"],
153+
data["type"],
158154
[
159-
f"{self.object_type.url}/versions/10 does not appear to be a valid objecttype."
155+
f"{self.object_type.versions_url} does not appear to be a valid objecttype."
160156
],
161157
)
162158

@@ -183,9 +179,7 @@ def test_create_object_schema_invalid(self, m):
183179
self.assertEqual(Object.objects.count(), 0)
184180

185181
data = response.json()
186-
self.assertEqual(
187-
data["non_field_errors"], ["'diameter' is a required property"]
188-
)
182+
self.assertEqual(data["data"], ["'diameter' is a required property"])
189183

190184
def test_create_object_without_record_invalid(self, m):
191185
mock_service_oas_get(m, OBJECT_TYPES_API, "objecttypes")

src/objects/utils/test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from django.core.cache import caches
2+
13
from objects.token.tests.factories import TokenAuthFactory
24

35

@@ -14,3 +16,14 @@ def setUp(self):
1416
super().setUp()
1517

1618
self.client.credentials(HTTP_AUTHORIZATION=f"Token {self.token_auth.token}")
19+
20+
21+
class ClearCachesMixin:
22+
def setUp(self):
23+
super().setUp()
24+
self._clear_caches()
25+
self.addCleanup(self._clear_caches)
26+
27+
def _clear_caches(self):
28+
for cache in caches.all():
29+
cache.clear()

0 commit comments

Comments
 (0)