diff --git a/dsp_permissions_scripts/models/permission.py b/dsp_permissions_scripts/models/permission.py index a98a6947..8f590f97 100644 --- a/dsp_permissions_scripts/models/permission.py +++ b/dsp_permissions_scripts/models/permission.py @@ -33,7 +33,7 @@ class Doap(BaseModel): target: DoapTarget scope: PermissionScope - iri: str + doap_iri: str class DoapTargetType(Enum): diff --git a/dsp_permissions_scripts/utils/permissions.py b/dsp_permissions_scripts/utils/permissions.py index ca6d79df..d811536f 100644 --- a/dsp_permissions_scripts/utils/permissions.py +++ b/dsp_permissions_scripts/utils/permissions.py @@ -77,7 +77,7 @@ def set_doaps_of_groups( print("Old DOAP:\n=========") print(d.model_dump_json(indent=2)) new_doap = update_doap_scope( - doap_iri=d.iri, + doap_iri=d.doap_iri, scope=scope, host=host, token=token, @@ -101,7 +101,7 @@ def __get_doap(permission: dict[str, Any]) -> Doap: property=permission["forProperty"], ), scope=scope, - iri=permission["iri"], + doap_iri=permission["iri"], ) return doap diff --git a/dsp_permissions_scripts/utils/project.py b/dsp_permissions_scripts/utils/project.py index e74b742a..73af6246 100644 --- a/dsp_permissions_scripts/utils/project.py +++ b/dsp_permissions_scripts/utils/project.py @@ -23,15 +23,15 @@ def get_all_resource_iris_of_project( token: str, ) -> list[str]: all_resource_iris = [] - resclasses = __get_all_resource_class_iris_of_project( + resclass_iris = __get_all_resource_class_iris_of_project( project_iri=project_iri, host=host, token=token, ) - for resclass in resclasses: + for resclass_iri in resclass_iris: resource_iris = __get_all_resource_iris_of_resclass( host=host, - resclass=resclass, + resclass_iri=resclass_iri, project_iri=project_iri, token=token, ) @@ -99,7 +99,7 @@ def __dereference_prefix(identifier: str, context: dict[str, str]) -> str: def __get_all_resource_iris_of_resclass( host: str, - resclass: str, + resclass_iri: str, project_iri: str, token: str, ) -> list[str]: @@ -112,7 +112,7 @@ def __get_all_resource_iris_of_resclass( more, iris = __get_next_page( protocol=protocol, host=host, - resclass=resclass, + resclass_iri=resclass_iri, page=page, headers=headers, ) @@ -124,7 +124,7 @@ def __get_all_resource_iris_of_resclass( def __get_next_page( protocol: str, host: str, - resclass: str, + resclass_iri: str, page: int, headers: dict[str, str], ) -> tuple[bool, list[str]]: @@ -137,7 +137,7 @@ def __get_next_page( and an empty response content with status code 200 if there are no resources remaining. This means that the page must be incremented until the response contains 0 or 1 resource. """ - url = f"{protocol}://{host}/v2/resources?resourceClass={quote_plus(resclass)}&page={page}" + url = f"{protocol}://{host}/v2/resources?resourceClass={quote_plus(resclass_iri)}&page={page}" response = requests.get(url, headers=headers, timeout=5) assert response.status_code == 200 result = response.json() diff --git a/tests/test_scope_serialization.py b/tests/test_scope_serialization.py index 920949aa..858981d8 100644 --- a/tests/test_scope_serialization.py +++ b/tests/test_scope_serialization.py @@ -1,5 +1,5 @@ -from typing import Any import unittest +from typing import Any from dsp_permissions_scripts.models.groups import BuiltinGroup from dsp_permissions_scripts.models.scope import PermissionScope @@ -101,9 +101,10 @@ def _resolve_prefixes_of_admin_route_object(self, admin_route_object: list[dict[ "knora-admin:", "http://www.knora.org/ontology/knora-admin#" ) return admin_route_object - + def _resolve_prefixes_of_perm_string(self, perm_string: str) -> str: return perm_string.replace("knora-admin:", "http://www.knora.org/ontology/knora-admin#") + if __name__ == "__main__": unittest.main()