diff --git a/src/objects/token/admin.py b/src/objects/token/admin.py index 3d659f77..3d7d82b6 100644 --- a/src/objects/token/admin.py +++ b/src/objects/token/admin.py @@ -52,6 +52,7 @@ def get_data_field_choices(self): except requests.JSONDecodeError: continue + # TODO: remove check once API V1 is removed if "results" in response_data: response_data = response_data["results"] diff --git a/src/objects/token/tests/test_admin.py b/src/objects/token/tests/test_admin.py index 7899bc8f..0db3ea0d 100644 --- a/src/objects/token/tests/test_admin.py +++ b/src/objects/token/tests/test_admin.py @@ -40,18 +40,24 @@ def test_with_object_types_api_v1(self): header_key="Authorization", header_value="Token 5cebbb33ffa725b6ed5e9e98300061218ba98d71", ) - ObjectTypeFactory( + object_type = ObjectTypeFactory( service=v1_service, uuid="71a2452a-66c3-4030-b5ec-a06035102e9e" ) response = self.client.get(self.url) - print(response) self.assertEqual(response.status_code, 200) + form = response.context["adminform"].form + choices = list(form.fields["object_type"].choices) + + self.assertEqual( + choices[1][0].value, + object_type.id, + ) self.assertEqual( - self.cassette.requests[1].uri, - "http://127.0.0.1:8008/api/v1/objecttypes/71a2452a-66c3-4030-b5ec-a06035102e9e/versions", + choices[1][1], + f"{v1_service.label}: {object_type._name}", ) @tag("#449") @@ -66,14 +72,21 @@ def test_with_object_types_api_v2(self): header_key="Authorization", header_value="Token 5cebbb33ffa725b6ed5e9e98300061218ba98d71", ) - ObjectTypeFactory( + object_type = ObjectTypeFactory( service=v2_service, uuid="71a2452a-66c3-4030-b5ec-a06035102e9e" ) response = self.client.get(self.url) self.assertEqual(response.status_code, 200) + form = response.context["adminform"].form + choices = list(form.fields["object_type"].choices) + + self.assertEqual( + choices[1][0].value, + object_type.id, + ) self.assertEqual( - self.cassette.requests[1].uri, - "http://127.0.0.1:8008/api/v2/objecttypes/71a2452a-66c3-4030-b5ec-a06035102e9e/versions", + choices[1][1], + f"{v2_service.label}: {object_type._name}", )