diff --git a/dsp_permissions_scripts/ap/ap_get.py b/dsp_permissions_scripts/ap/ap_get.py index 6a3fe236..b2c9d346 100644 --- a/dsp_permissions_scripts/ap/ap_get.py +++ b/dsp_permissions_scripts/ap/ap_get.py @@ -47,7 +47,7 @@ def _get_all_aps_of_project( protocol = get_protocol(host) url = f"{protocol}://{host}/admin/permissions/ap/{project_iri}" response = requests.get(url, headers=headers, timeout=5) - assert response.status_code == 200, f"Error message from DSP-API: {response.text}" + assert response.status_code == 200, f"Status {response.status_code}. Error message from DSP-API: {response.text}" aps: list[dict[str, Any]] = response.json()["administrative_permissions"] ap_objects = [create_ap_from_admin_route_object(ap) for ap in aps] return ap_objects diff --git a/dsp_permissions_scripts/ap/ap_set.py b/dsp_permissions_scripts/ap/ap_set.py index e0516e56..27d1a8c4 100644 --- a/dsp_permissions_scripts/ap/ap_set.py +++ b/dsp_permissions_scripts/ap/ap_set.py @@ -34,7 +34,7 @@ def _delete_single_ap( protocol = get_protocol(host) url = f"{protocol}://{host}/admin/permissions/{ap_iri}" response = requests.delete(url, headers=headers, timeout=5) - assert response.status_code == 200, f"Error message from DSP-API: {response.text}" + assert response.status_code == 200, f"Status {response.status_code}. Error message from DSP-API: {response.text}" logger.info(f"Deleted Administrative Permission {ap.iri} on host {host}") @@ -52,7 +52,7 @@ def _update_ap( url = f"{protocol}://{host}/admin/permissions/{iri}/hasPermissions" payload = {"hasPermissions": create_admin_route_object_from_ap(ap)["hasPermissions"]} response = requests.put(url, headers=headers, json=payload, timeout=5) - assert response.status_code == 200, f"Error message from DSP-API: {response.text}" + assert response.status_code == 200, f"Status {response.status_code}. Error message from DSP-API: {response.text}" ap_updated: dict[str, Any] = response.json()["administrative_permission"] ap_object_updated = create_ap_from_admin_route_object(ap_updated) return ap_object_updated diff --git a/dsp_permissions_scripts/doap/doap_get.py b/dsp_permissions_scripts/doap/doap_get.py index 40569448..6a05563c 100644 --- a/dsp_permissions_scripts/doap/doap_get.py +++ b/dsp_permissions_scripts/doap/doap_get.py @@ -47,7 +47,7 @@ def _get_all_doaps_of_project( protocol = get_protocol(host) url = f"{protocol}://{host}/admin/permissions/doap/{project_iri}" response = requests.get(url, headers=headers, timeout=5) - assert response.status_code == 200, f"Error message from DSP-API: {response.text}" + assert response.status_code == 200, f"Status {response.status_code}. Error message from DSP-API: {response.text}" doaps: list[dict[str, Any]] = response.json()["default_object_access_permissions"] doap_objects = [create_doap_from_admin_route_response(doap) for doap in doaps] return doap_objects diff --git a/dsp_permissions_scripts/doap/doap_set.py b/dsp_permissions_scripts/doap/doap_set.py index d5651a7b..911fb873 100644 --- a/dsp_permissions_scripts/doap/doap_set.py +++ b/dsp_permissions_scripts/doap/doap_set.py @@ -30,7 +30,7 @@ def _update_doap_scope( url = f"{protocol}://{host}/admin/permissions/{iri}/hasPermissions" payload = {"hasPermissions": create_admin_route_object_from_scope(scope)} response = requests.put(url, headers=headers, json=payload, timeout=5) - assert response.status_code == 200, f"Error message from DSP-API: {response.text}" + assert response.status_code == 200, f"Status {response.status_code}. Error message from DSP-API: {response.text}" new_doap = create_doap_from_admin_route_response(response.json()["default_object_access_permission"]) return new_doap diff --git a/dsp_permissions_scripts/oap/oap_get_set.py b/dsp_permissions_scripts/oap/oap_get_set.py index 666f9582..63482b9f 100644 --- a/dsp_permissions_scripts/oap/oap_get_set.py +++ b/dsp_permissions_scripts/oap/oap_get_set.py @@ -50,7 +50,7 @@ def _get_resource( url = f"{protocol}://{host}/v2/resources/{iri}" headers = {"Authorization": f"Bearer {token}"} response = requests.get(url, headers=headers, timeout=5) - assert response.status_code == 200, f"Error message from DSP-API: {response.text}" + assert response.status_code == 200, f"Status {response.status_code}. Error message from DSP-API: {response.text}" data: dict[str, Any] = response.json() return data @@ -143,7 +143,7 @@ def _update_permissions_for_resource( url = f"{protocol}://{host}/v2/resources" headers = {"Authorization": f"Bearer {token}"} response = requests.put(url, headers=headers, json=payload, timeout=5) - assert response.status_code == 200, f"Error message from DSP-API: {response.text}" + assert response.status_code == 200, f"Status {response.status_code}. Error message from DSP-API: {response.text}" logger.info(f"Updated permissions of resource {resource_iri}") diff --git a/dsp_permissions_scripts/utils/authentication.py b/dsp_permissions_scripts/utils/authentication.py index 418977ff..44d60fe8 100644 --- a/dsp_permissions_scripts/utils/authentication.py +++ b/dsp_permissions_scripts/utils/authentication.py @@ -10,7 +10,7 @@ def _get_token(host: str, email: str, pw: str) -> str: protocol = get_protocol(host) url = f"{protocol}://{host}/v2/authentication" response = requests.post(url, json={"email": email, "password": pw}, timeout=5) - assert response.status_code == 200, f"Error message from DSP-API: {response.text}" + assert response.status_code == 200, f"Status {response.status_code}. Error message from DSP-API: {response.text}" token: str = response.json()["token"] return token diff --git a/dsp_permissions_scripts/utils/project.py b/dsp_permissions_scripts/utils/project.py index 7bd68ad2..b0b12e04 100644 --- a/dsp_permissions_scripts/utils/project.py +++ b/dsp_permissions_scripts/utils/project.py @@ -43,7 +43,7 @@ def _get_onto_iris_of_project( url = f"{protocol}://{host}/v2/ontologies/metadata" headers = {"Authorization": f"Bearer {token}"} response = requests.get(url, headers=headers, timeout=5) - assert response.status_code == 200, f"Error message from DSP-API: {response.text}" + assert response.status_code == 200, f"Status {response.status_code}. Error message from DSP-API: {response.text}" all_ontologies = response.json().get("@graph") project_onto_iris = [o["@id"] for o in all_ontologies if o["knora-api:attachedToProject"]["@id"] == project_iri] return project_onto_iris @@ -58,7 +58,7 @@ def _get_class_iris_of_onto( url = f"{protocol}://{host}/v2/ontologies/allentities/{quote_plus(onto_iri)}" headers = {"Authorization": f"Bearer {token}"} response = requests.get(url, headers=headers, timeout=5) - assert response.status_code == 200, f"Error message from DSP-API: {response.text}" + assert response.status_code == 200, f"Status {response.status_code}. Error message from DSP-API: {response.text}" all_entities = response.json()["@graph"] context = response.json()["@context"] class_ids = [c["@id"] for c in all_entities if c.get("knora-api:isResourceClass")] @@ -113,7 +113,7 @@ def _get_next_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, f"Error message from DSP-API: {response.text}" + assert response.status_code == 200, f"Status {response.status_code}. Error message from DSP-API: {response.text}" result = response.json() if "@graph" in result: # result contains several resources: return them, then continue with next page @@ -138,7 +138,7 @@ def get_project_iri_by_shortcode(shortcode: str, host: str) -> str: protocol = get_protocol(host) url = f"{protocol}://{host}/admin/projects/shortcode/{shortcode}" response = requests.get(url, timeout=5) - assert response.status_code == 200, f"Error message from DSP-API: {response.text}" + assert response.status_code == 200, f"Status {response.status_code}. Error message from DSP-API: {response.text}" iri: str = response.json()["project"]["id"] return iri