def test_to_graph_should_return_access_rights() -> None: """It returns a access_rights graph isomorphic to spec.""" access_rights = ["PUBLIC", "RESTRICTED", "NON-PUBLIC"] for _r in access_rights: resource = Dataset() resource.identifier = "http://example.com/datasets/1" resource.access_rights = ( f"http://publications.europa.eu/resource/authority/access-right/{_r}" ) src = ( "@prefix dct: <http://purl.org/dc/terms/> ." "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ." "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> ." "@prefix dcat: <http://www.w3.org/ns/dcat#> .\n" "<http://example.com/datasets/1> a dcat:Dataset ;" "\tdct:accessRights\t" "<http://publications.europa.eu/resource/authority/access-right/" f"{_r}> ." ) g1 = Graph().parse(data=resource.to_rdf(), format="turtle") g2 = Graph().parse(data=src, format="turtle") _isomorphic = isomorphic(g1, g2) if not _isomorphic: _dump_diff(g1, g2) pass assert _isomorphic
def _add_mandatory_dataset_props(dataset: Dataset, es_hit: Mapping) -> None: dataset.title = {"nb": utils.remove_new_line(es_hit["title"])} dataset.identifier = URI(os.environ["DATASET_CONCEPT_IDENTIFIER"] + es_hit["id"]) dataset.description = {"nb": es_hit["description"]} dataset.publisher = URI(os.environ["PUBLISHER"]) dataset.language = utils.create_language(es_hit["language"]) dataset.access_rights = utils.create_access_rights(es_hit["accessRights"]) dataset.spatial_coverage = utils.create_location(es_hit["spatial"])