def test_to_graph_should_return_link_to_spatial_coverage_with_location_triple(
) -> None:
    """It returns a spatial coverage graph isomorphic to spec."""
    dataset = Dataset()
    dataset.identifier = "http://example.com/datasets/1"
    # Create location:
    location = Location()
    location.identifier = "http://example.com/locations/1"
    location.centroid = "POINT(4.88412 52.37509)"
    # Add location to dataset:
    dataset.spatial_coverage = location

    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#> .
    @prefix geosparql: <http://www.opengis.net/ont/geosparql#> .

    <http://example.com/datasets/1> a dcat:Dataset ;
        dct:spatial <http://example.com/locations/1> ;
    .

    <http://example.com/locations/1> a dct:Location ;
            dcat:centroid "POINT(4.88412 52.37509)"^^geosparql:asWKT ;
    .
    """
    g1 = Graph().parse(data=dataset.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 test_to_graph_should_return_link_to_spatial_coverage() -> None:
    """It returns a spatial coverage graph isomorphic to spec."""
    dataset = Dataset()
    dataset.identifier = "http://example.com/datasets/1"
    # Add link to location:
    location = "http://publications.europa.eu/resource/authority/country/NOR"
    dataset.spatial_coverage = location

    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#> .
    @prefix geosparql: <http://www.opengis.net/ont/geosparql#> .

    <http://example.com/datasets/1> a dcat:Dataset ;
        dct:spatial <http://publications.europa.eu/resource/authority/country/NOR> ;
    .
    """
    g1 = Graph().parse(data=dataset.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"])