Skip to content

Commit

Permalink
edit
Browse files Browse the repository at this point in the history
  • Loading branch information
jnussbaum committed Aug 5, 2024
1 parent 1a015a5 commit 89f6015
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 46 deletions.
2 changes: 1 addition & 1 deletion dsp_permissions_scripts/oap/oap_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def get_all_oaps_of_project(
logger.info("******* Retrieving all OAPs... *******")
project_iri, onto_iris = get_project_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 = []
all_oaps: list[Oap] = []
for resclass_localname in resclass_localnames:
oaps = _get_all_oaps_of_resclass(resclass_localname, project_iri, dsp_client, oap_config)
all_oaps.extend(oaps)
Expand Down
91 changes: 46 additions & 45 deletions tests/test_oap_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,52 +31,53 @@ def resource() -> dict[str, Any]:
}


def test_oap_get_multiple_values_per_prop() -> None:
resource = {
"@id": "http://rdfh.ch/0838/dBu563hjSN6RmJZp6NU3_Q",
"geoarch:hasDescriptionSiteProject": {
"knora-api:hasPermissions": "CR knora-admin:ProjectAdmin|V knora-admin:KnownUser,knora-admin:UnknownUser",
"@id": "http://rdfh.ch/0838/dBu563hjSN6RmJZp6NU3_Q/values/o0313dsSQTSPGua4NSWkeQ",
"@type": "knora-api:TextValue",
},
"geoarch:hasFurtherDisciplines": [
{
"knora-api:hasPermissions": "CR knora-admin:ProjectAdmin|M knora-admin:ProjectMember",
"@type": "knora-api:ListValue",
"@id": "http://rdfh.ch/0838/dBu563hjSN6RmJZp6NU3_Q/values/ZC-1hUiMR0mVXdaCBg1jsA",
},
{
"knora-api:hasPermissions": "CR knora-admin:ProjectAdmin|M knora-admin:ProjectMember",
"@type": "knora-api:ListValue",
"@id": "http://rdfh.ch/0838/dBu563hjSN6RmJZp6NU3_Q/values/FMJ3-eUARl-shQ6ZbUn9aw",
class Test_get_value_oaps:
def test_oap_get_multiple_values_per_prop(self) -> None:
resource = {
"@id": "http://rdfh.ch/0838/dBu563hjSN6RmJZp6NU3_Q",
"geoarch:hasDescriptionSiteProject": {
"knora-api:hasPermissions": "CR knora-admin:ProjectAdmin|V knora-admin:KnownUser",
"@id": "http://rdfh.ch/0838/dBu563hjSN6RmJZp6NU3_Q/values/o0313dsSQTSPGua4NSWkeQ",
"@type": "knora-api:TextValue",
},
],
}
expected = [
ValueOap(
scope=PermissionScope.create(CR=[group.PROJECT_ADMIN], V=[group.KNOWN_USER, group.UNKNOWN_USER]),
property="geoarch:hasDescriptionSiteProject",
value_type="knora-api:TextValue",
value_iri="http://rdfh.ch/0838/dBu563hjSN6RmJZp6NU3_Q/values/o0313dsSQTSPGua4NSWkeQ",
resource_iri="http://rdfh.ch/0838/dBu563hjSN6RmJZp6NU3_Q",
),
ValueOap(
scope=PermissionScope.create(CR=[group.PROJECT_ADMIN], M=[group.PROJECT_MEMBER]),
property="geoarch:hasFurtherDisciplines",
value_type="knora-api:ListValue",
value_iri="http://rdfh.ch/0838/dBu563hjSN6RmJZp6NU3_Q/values/ZC-1hUiMR0mVXdaCBg1jsA",
resource_iri="http://rdfh.ch/0838/dBu563hjSN6RmJZp6NU3_Q",
),
ValueOap(
scope=PermissionScope.create(CR=[group.PROJECT_ADMIN], M=[group.PROJECT_MEMBER]),
property="geoarch:hasFurtherDisciplines",
value_type="knora-api:ListValue",
value_iri="http://rdfh.ch/0838/dBu563hjSN6RmJZp6NU3_Q/values/FMJ3-eUARl-shQ6ZbUn9aw",
resource_iri="http://rdfh.ch/0838/dBu563hjSN6RmJZp6NU3_Q",
),
]
returned = _get_value_oaps(resource)
assert expected == returned
"geoarch:hasFurtherDisciplines": [
{
"knora-api:hasPermissions": "CR knora-admin:ProjectAdmin|M knora-admin:ProjectMember",
"@type": "knora-api:ListValue",
"@id": "http://rdfh.ch/0838/dBu563hjSN6RmJZp6NU3_Q/values/ZC-1hUiMR0mVXdaCBg1jsA",
},
{
"knora-api:hasPermissions": "CR knora-admin:ProjectAdmin|M knora-admin:ProjectMember",
"@type": "knora-api:ListValue",
"@id": "http://rdfh.ch/0838/dBu563hjSN6RmJZp6NU3_Q/values/FMJ3-eUARl-shQ6ZbUn9aw",
},
],
}
expected = [
ValueOap(
scope=PermissionScope.create(CR=[group.PROJECT_ADMIN], V=[group.KNOWN_USER]),
property="geoarch:hasDescriptionSiteProject",
value_type="knora-api:TextValue",
value_iri="http://rdfh.ch/0838/dBu563hjSN6RmJZp6NU3_Q/values/o0313dsSQTSPGua4NSWkeQ",
resource_iri="http://rdfh.ch/0838/dBu563hjSN6RmJZp6NU3_Q",
),
ValueOap(
scope=PermissionScope.create(CR=[group.PROJECT_ADMIN], M=[group.PROJECT_MEMBER]),
property="geoarch:hasFurtherDisciplines",
value_type="knora-api:ListValue",
value_iri="http://rdfh.ch/0838/dBu563hjSN6RmJZp6NU3_Q/values/ZC-1hUiMR0mVXdaCBg1jsA",
resource_iri="http://rdfh.ch/0838/dBu563hjSN6RmJZp6NU3_Q",
),
ValueOap(
scope=PermissionScope.create(CR=[group.PROJECT_ADMIN], M=[group.PROJECT_MEMBER]),
property="geoarch:hasFurtherDisciplines",
value_type="knora-api:ListValue",
value_iri="http://rdfh.ch/0838/dBu563hjSN6RmJZp6NU3_Q/values/FMJ3-eUARl-shQ6ZbUn9aw",
resource_iri="http://rdfh.ch/0838/dBu563hjSN6RmJZp6NU3_Q",
),
]
returned = _get_value_oaps(resource)
assert expected == returned


def test_get_oap_of_one_resource_all_classes_all_values(resource: dict[str, Any]) -> None:
Expand Down

0 comments on commit 89f6015

Please sign in to comment.