Skip to content

Commit

Permalink
✅[#449] change permission tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Coperh committed Sep 27, 2024
1 parent c465f53 commit 6baedab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/objects/token/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
19 changes: 12 additions & 7 deletions src/objects/token/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,20 @@ 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(
self.cassette.requests[1].uri,
"http://127.0.0.1:8008/api/v1/objecttypes/71a2452a-66c3-4030-b5ec-a06035102e9e/versions",
choices[1][0].value,
object_type.id,
)

@tag("#449")
Expand All @@ -66,14 +68,17 @@ 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(
self.cassette.requests[1].uri,
"http://127.0.0.1:8008/api/v2/objecttypes/71a2452a-66c3-4030-b5ec-a06035102e9e/versions",
choices[1][0].value,
object_type.id,
)

0 comments on commit 6baedab

Please sign in to comment.