Skip to content

Commit

Permalink
[#464] Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmursa-dev committed Jan 2, 2025
1 parent fb2cce6 commit f8cced2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 26 deletions.
25 changes: 0 additions & 25 deletions src/objects/tests/admin/test_token_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,31 +70,6 @@ def setUp(self):
self.object_type = ObjectTypeFactory.create(service__api_root=OBJECT_TYPES_API)
self.token_auth = TokenAuthFactory.create()

def test_change_permission_data_field_choices_disabled(self, m):
url = reverse_lazy("admin:token_permission_change")
# use_fields disabled
permission = PermissionFactory.create(
object_type=self.object_type,
mode=PermissionModes.read_only,
token_auth=self.token_auth,
)

url = reverse_lazy("admin:token_permission_change", args=(permission.id,))

# mock objecttypes api
mock_service_oas_get(m, OBJECT_TYPES_API, "objecttypes")
m.get(f"{OBJECT_TYPES_API}objecttypes", json=[])
m.get(self.object_type.url, json=mock_objecttype(self.object_type.url))
version1 = mock_objecttype_version(
self.object_type.url, attrs={"jsonSchema": {}}
)
version2 = mock_objecttype_version(self.object_type.url, attrs={"version": 2})
m.get(f"{self.object_type.url}/versions", json=[version1, version2])

response = self.app.get(url)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.context["data_field_choices"], {})

def test_change_permission_data_field_choices_enabled(self, m):
url = reverse_lazy("admin:token_permission_change")
# use_fields enabled
Expand Down
2 changes: 1 addition & 1 deletion src/objects/token/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def get_extra_context(self, request, object_id):
objecttypes_available = can_connect_to_objecttypes()
data_field_choices = {}
obj = self.get_object(request, unquote(object_id)) if object_id else None
if objecttypes_available and obj and obj.object_type and obj.use_fields:
if objecttypes_available and obj and obj.object_type:
data_field_choices = self.get_data_field_choices(obj.object_type.id)

return {
Expand Down

0 comments on commit f8cced2

Please sign in to comment.