def _add_mandatory_distribution_props(distribution: Distribution, resource: Mapping) -> None: distribution.formats = [create_format(resource["format"])] distribution.access_URL = URI(resource["path"]) distribution.identifier = URI(resource["path"]) distribution.license = URI( "http://creativecommons.org/licenses/by/4.0/deed.no")
def create_html_distribution(dp_metadata: dict): html_distribution = Distribution() html_distribution.title = {"nb": dp_metadata["title"]} html_distribution.formats = ["text/html"] html_distribution.description = {"nb": dp_metadata["description"]} html_distribution.identifier = URI( os.environ["DATASET_CONCEPT_IDENTIFIER"] + dp_metadata["id"]) html_distribution.license = URI( "http://creativecommons.org/licenses/by/4.0/deed.no") html_distribution.access_URL = URI( os.environ["DATASET_CONCEPT_IDENTIFIER"] + dp_metadata["id"]) return html_distribution
def test_to_graph_should_return_license() -> None: """It returns a license graph isomorphic to spec.""" distribution = Distribution() distribution.identifier = "http://example.com/distributions/1" distribution.license = "http://example.com/licenses/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/distributions/1> a dcat:Distribution ; dct:license <http://example.com/licenses/1> . """ g1 = Graph().parse(data=distribution.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