예제 #1
0
def _add_optional_props(api: DataService, es_hit: Mapping) -> None:
    api.description = {
        "nb":
        es_hit["content"].get("clean_description",
                              es_hit["content"]["description"])
    }
    try:
        api.endpointURL = es_hit["content"]["url"]
    except KeyError:
        pass

    if es_hit["content"].get("swagger", es_hit["content"].get("api_dec")):
        api.endpointDescription = es_hit["content"].get(
            "swagger", es_hit["content"].get("api_dec"))
def test_to_graph_should_return_endpointURL_as_graph() -> None:
    """It returns a endpointURL graph isomorphic to spec."""
    dataService = DataService()
    dataService.identifier = "http://example.com/dataservices/1"
    dataService.endpointURL = "http://example.com/endpoints/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/dataservices/1> a dcat:DataService ;
        dcat:endpointURL   <http://example.com/endpoints/1>
        .
    """
    g1 = Graph().parse(data=dataService.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
예제 #3
0
def _add_optional_props(api: DataService, es_hit: Mapping) -> None:
    api.publisher = URI(os.environ["PUBLISHER"])
    api.description = {"nb": es_hit["content"]["description"]}
    api.endpointURL = es_hit["content"]["url"]
    api.endpointDescription = es_hit["content"]["swagger"]