99from objects .core .tests .factories import ObjectRecordFactory , ObjectTypeFactory
1010from objects .token .constants import PermissionModes
1111from objects .token .tests .factories import PermissionFactory
12- from objects .utils .test import TokenAuthMixin
12+ from objects .utils .test import ClearCachesMixin , TokenAuthMixin
1313
1414from ..constants import GEO_WRITE_KWARGS
1515from ..utils import mock_objecttype , mock_objecttype_version , mock_service_oas_get
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" )
0 commit comments