コード例 #1
0
def _add_optional_dataset_props(dataset: Dataset, es_hit: Mapping) -> None:
    dataset.contactpoint = utils.create_contact(es_hit)
    dataset.creator = URI(os.environ["PUBLISHER"])
    dataset.frequency = URI(es_hit.get("periodicity", ""))
    dataset.license = URI(es_hit["license"]["url"])
    dataset.temporal_coverage = utils.create_temporal_coverage(
        es_hit["temporal"])
コード例 #2
0
def test_to_graph_should_return_creator() -> None:
    """It returns a creator graph isomorphic to spec."""
    resource = Dataset()
    resource.identifier = "http://example.com/datasets/1"
    resource.creator = "http://example.com/creator/1"

    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#> .

    <http://example.com/datasets/1> a dcat:Dataset ;
        dct:creator   <http://example.com/creator/1> ;
        .
    """
    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