Skip to content

Commit

Permalink
Merge branch 'main' into wip/custom-groups-2
Browse files Browse the repository at this point in the history
  • Loading branch information
jnussbaum authored Oct 25, 2024
2 parents 12b4276 + eb132cf commit 91814cd
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions dsp_permissions_scripts/ap/ap_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from dsp_permissions_scripts.models.group_utils import get_prefixed_iri_from_full_iri
from dsp_permissions_scripts.utils.dsp_client import DspClient
from dsp_permissions_scripts.utils.get_logger import get_logger
from dsp_permissions_scripts.utils.project import get_project_iri_and_onto_iris_by_shortcode
from dsp_permissions_scripts.utils.project import get_proj_iri_and_onto_iris_by_shortcode

logger = get_logger(__name__)

Expand Down Expand Up @@ -54,7 +54,7 @@ def _get_all_aps_of_project(project_iri: str, dsp_client: DspClient) -> list[Ap]
def get_aps_of_project(shortcode: str, dsp_client: DspClient) -> list[Ap]:
"""Returns the Administrative Permissions for a project."""
logger.info("****** Retrieving all Administrative Permissions... ******")
project_iri, _ = get_project_iri_and_onto_iris_by_shortcode(shortcode, dsp_client)
project_iri, _ = get_proj_iri_and_onto_iris_by_shortcode(shortcode, dsp_client)
aps = _get_all_aps_of_project(project_iri, dsp_client)
logger.info(f"Retrieved {len(aps)} Administrative Permissions")
return aps
4 changes: 2 additions & 2 deletions dsp_permissions_scripts/ap/ap_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from dsp_permissions_scripts.models.group_utils import get_full_iri_from_prefixed_iri
from dsp_permissions_scripts.utils.dsp_client import DspClient
from dsp_permissions_scripts.utils.get_logger import get_logger
from dsp_permissions_scripts.utils.project import get_project_iri_and_onto_iris_by_shortcode
from dsp_permissions_scripts.utils.project import get_proj_iri_and_onto_iris_by_shortcode

logger = get_logger(__name__)

Expand Down Expand Up @@ -48,7 +48,7 @@ def create_new_ap_on_server(
hasPermissions: list[ApValue],
dsp_client: DspClient,
) -> Ap | None:
proj_iri, _ = get_project_iri_and_onto_iris_by_shortcode(shortcode, dsp_client)
proj_iri, _ = get_proj_iri_and_onto_iris_by_shortcode(shortcode, dsp_client)
payload = {
"forGroup": get_full_iri_from_prefixed_iri(forGroup.prefixed_iri, dsp_client),
"forProject": proj_iri,
Expand Down
4 changes: 2 additions & 2 deletions dsp_permissions_scripts/doap/doap_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from dsp_permissions_scripts.models.group_utils import get_prefixed_iri_from_full_iri
from dsp_permissions_scripts.utils.dsp_client import DspClient
from dsp_permissions_scripts.utils.get_logger import get_logger
from dsp_permissions_scripts.utils.project import get_project_iri_and_onto_iris_by_shortcode
from dsp_permissions_scripts.utils.project import get_proj_iri_and_onto_iris_by_shortcode
from dsp_permissions_scripts.utils.scope_serialization import create_scope_from_admin_route_object

logger = get_logger(__name__)
Expand Down Expand Up @@ -53,7 +53,7 @@ def get_doaps_of_project(shortcode: str, dsp_client: DspClient) -> list[Doap]:
By default, all DOAPs are returned, regardless of their target (target=all).
"""
logger.info("****** Retrieving all DOAPs... ******")
project_iri, _ = get_project_iri_and_onto_iris_by_shortcode(shortcode, dsp_client)
project_iri, _ = get_proj_iri_and_onto_iris_by_shortcode(shortcode, dsp_client)
doaps = _get_all_doaps_of_project(project_iri, dsp_client)
msg = f"Retrieved {len(doaps)} DOAPs"
logger.info(msg)
Expand Down
4 changes: 2 additions & 2 deletions dsp_permissions_scripts/doap/doap_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from dsp_permissions_scripts.models.scope import PermissionScope
from dsp_permissions_scripts.utils.dsp_client import DspClient
from dsp_permissions_scripts.utils.get_logger import get_logger
from dsp_permissions_scripts.utils.project import get_project_iri_and_onto_iris_by_shortcode
from dsp_permissions_scripts.utils.project import get_proj_iri_and_onto_iris_by_shortcode
from dsp_permissions_scripts.utils.scope_serialization import create_admin_route_object_from_scope

logger = get_logger(__name__)
Expand Down Expand Up @@ -47,7 +47,7 @@ def create_new_doap_on_server(
scope: PermissionScope,
dsp_client: DspClient,
) -> Doap | None:
proj_iri, _ = get_project_iri_and_onto_iris_by_shortcode(shortcode, dsp_client)
proj_iri, _ = get_proj_iri_and_onto_iris_by_shortcode(shortcode, dsp_client)
forGroup = None
if isinstance(target, NewGroupDoapTarget):
forGroup = get_full_iri_from_prefixed_iri(target.group.prefixed_iri, dsp_client)
Expand Down
4 changes: 2 additions & 2 deletions dsp_permissions_scripts/oap/oap_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from dsp_permissions_scripts.utils.get_logger import get_logger
from dsp_permissions_scripts.utils.helpers import dereference_prefix
from dsp_permissions_scripts.utils.project import get_all_resource_class_localnames_of_project
from dsp_permissions_scripts.utils.project import get_project_iri_and_onto_iris_by_shortcode
from dsp_permissions_scripts.utils.project import get_proj_iri_and_onto_iris_by_shortcode
from dsp_permissions_scripts.utils.scope_serialization import create_scope_from_string

logger = get_logger(__name__)
Expand Down Expand Up @@ -236,7 +236,7 @@ def get_all_oaps_of_project(
oap_config: OapRetrieveConfig,
) -> list[Oap]:
logger.info("******* Retrieving all OAPs... *******")
project_iri, onto_iris = get_project_iri_and_onto_iris_by_shortcode(shortcode, dsp_client)
project_iri, onto_iris = get_proj_iri_and_onto_iris_by_shortcode(shortcode, dsp_client)
resclass_localnames = get_all_resource_class_localnames_of_project(onto_iris, dsp_client, oap_config)
all_oaps: list[Oap] = []
for resclass_localname in resclass_localnames:
Expand Down
2 changes: 1 addition & 1 deletion dsp_permissions_scripts/utils/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get_all_resource_class_localnames_of_project(
return all_class_localnames


def get_project_iri_and_onto_iris_by_shortcode(shortcode: str, dsp_client: DspClient) -> tuple[str, list[str]]:
def get_proj_iri_and_onto_iris_by_shortcode(shortcode: str, dsp_client: DspClient) -> tuple[str, list[str]]:
try:
response = dsp_client.get(f"/admin/projects/shortcode/{shortcode}")
except ApiError as err:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_ap_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def create_new_ap_response() -> dict[str, Any]:


def test_create_new_ap_on_server(create_new_ap_request: dict[str, Any], create_new_ap_response: dict[str, Any]) -> None:
ap_set.get_project_iri_and_onto_iris_by_shortcode = Mock( # type: ignore[attr-defined]
ap_set.get_proj_iri_and_onto_iris_by_shortcode = Mock( # type: ignore[attr-defined]
return_value=("http://rdfh.ch/projects/QykAkmHJTPS7ervbGynSHw", None)
)
ap_set.create_ap_from_admin_route_object = Mock() # type: ignore[attr-defined]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_doap_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def create_new_doap_response() -> dict[str, Any]:
def test_create_new_doap_on_server(
create_new_doap_request: dict[str, Any], create_new_doap_response: dict[str, Any]
) -> None:
doap_set.get_project_iri_and_onto_iris_by_shortcode = Mock( # type: ignore[attr-defined]
doap_set.get_proj_iri_and_onto_iris_by_shortcode = Mock( # type: ignore[attr-defined]
return_value=("http://rdfh.ch/projects/P7Uo3YvDT7Kvv3EvLCl2tw", None)
)
doap_set.create_doap_from_admin_route_response = Mock() # type: ignore[attr-defined]
Expand Down

0 comments on commit 91814cd

Please sign in to comment.