Skip to content

Commit

Permalink
fix: Update tests tu use uri and not str as a value for license and r…
Browse files Browse the repository at this point in the history
…ights
  • Loading branch information
kovalch committed Jul 29, 2024
1 parent 7c1e510 commit c61cdd2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion ckanext/dcatapchharvest/dcat_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
DCT = Namespace("http://purl.org/dc/terms/")
EUTHEMES = \
Namespace("http://publications.europa.eu/resource/authority/data-theme/")
FOAF = Namespace("http://xmlns.com/foaf/0.1/") # noqa
FOAF = Namespace("http://xmlns.com/foaf/0.1/")
HYDRA = Namespace('http://www.w3.org/ns/hydra/core#')

SKOSXL = Namespace("http://www.w3.org/2008/05/skos-xl#")
Expand Down
8 changes: 6 additions & 2 deletions ckanext/dcatapchharvest/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,12 @@ def parse_dataset(self, dataset_dict, dataset_ref): # noqa
resource_dict[key] = value

# Rights & License save homepage uri
rights = self._license_rights_homepage_uri(distribution, DCT.rights)
license = self._license_rights_homepage_uri(distribution, DCT.license)
rights = self._license_rights_homepage_uri(
distribution, DCT.rights
)
license = self._license_rights_homepage_uri(
distribution, DCT.license
)

if rights is None and license is not None:
resource_dict['license'] = license
Expand Down
10 changes: 5 additions & 5 deletions ckanext/dcatapchharvest/tests/test_dcatap_ch_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def test_rights_license(self):
# Resources
eq_(len(dataset['resources']), 1)
resource = dataset['resources'][0]
eq_(resource['rights'], u'NonCommercialAllowed-CommercialAllowed-ReferenceRequired')
eq_(resource['license'], u'NonCommercialAllowed-CommercialWithPermission-ReferenceRequired')
eq_(unicode(resource['rights']), u'https://opendata.swiss/en/terms-of-use/#terms_by')
eq_(unicode(resource['license']), u'https://opendata.swiss/en/terms-of-use/#terms_by_ask')

def test_dataset_all_fields(self):

Expand Down Expand Up @@ -146,8 +146,8 @@ def test_dataset_all_fields(self):
eq_(resource['format'], u'html')
eq_(resource['media_type'], u'text/html')
eq_(resource['identifier'], u'346265-fr@bundesamt-fur-statistik-bfs')
eq_(resource['rights'], u'NonCommercialAllowed-CommercialAllowed-ReferenceRequired')
eq_(resource['license'], u'Creative Commons Zero 1.0 Universal (CC0 1.0)')
eq_(resource['license'], u'https://opendata.swiss/en/terms-of-use/#terms_by')
eq_(resource['rights'], u'http://www.opendefinition.org/licenses/cc-zero')
eq_(resource['language'], [u'fr'])
eq_(resource['issued'], u'1900-12-31T00:00:00')
eq_(resource['temporal_resolution'], u'P1D')
Expand Down Expand Up @@ -402,7 +402,7 @@ def test_multiple_rights_statements(self):
dataset = [d for d in p.datasets()][0]
resource = dataset["resources"][0]

eq_(resource['rights'], u"NonCommercialAllowed-CommercialWithPermission-ReferenceRequired")
eq_(unicode(resource['rights']), u"https://opendata.swiss/en/terms-of-use/#terms_by_ask")

def test_eu_themes_mapping(self):
contents = self._get_file_contents('catalog-themes.xml')
Expand Down
12 changes: 6 additions & 6 deletions ckanext/dcatapchharvest/tests/test_dcatap_ch_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,22 @@ def test_graph_from_dataset(self):
if resource_dict.get('rights') == 'Creative Commons Zero 1.0 Universal (CC0 1.0)':
assert self._triple(g, distribution, DCT.rights, URIRef("https://creativecommons.org/publicdomain/zero/1.0/"))

if resource_dict.get('license') == 'NonCommercialAllowed-CommercialAllowed-ReferenceNotRequired':
if resource_dict.get('license') == 'https://opendata.swiss/terms-of-use/#terms_open':
assert self._triple(g, distribution, DCT.license, URIRef("http://dcat-ap.ch/vocabulary/licenses/terms_open"))

# 28e75e40-e1a1-497b-a1b9-8c1834d60201
if resource_dict.get('rights') == "http://dcat-ap.ch/vocabulary/licenses/terms_by":
if resource_dict.get('rights') == "https://opendata.swiss/terms-of-use#terms_by":
assert self._triple(g, distribution, DCT.rights, URIRef("http://dcat-ap.ch/vocabulary/licenses/terms_by"))

if resource_dict.get('license') == "NonCommercialAllowed-CommercialAllowed-ReferenceRequired":
if resource_dict.get('license') == "https://opendata.swiss/terms-of-use#terms_by":
assert self._triple(g, distribution, DCT.license, URIRef("http://dcat-ap.ch/vocabulary/licenses/terms_by"))

# 0cfce6ba-28f4-4229-b733-f6492c650395
if resource_dict.get('rights') == "http://dcat-ap.ch/vocabulary/licenses/terms_by_ask":
if resource_dict.get('rights') == "https://opendata.swiss/terms-of-use#terms_by_ask":
assert self._triple(g, distribution, DCT.rights, URIRef("http://dcat-ap.ch/vocabulary/licenses/terms_by_ask"))

if resource_dict.get('license') == "https://creativecommons.org/licenses/by/4.0/":
assert self._triple(g, distribution, DCT.license, URIRef("https://creativecommons.org/licenses/by/4.0/"))
if resource_dict.get('rights') == " http://www.opendefinition.org/licenses/cc-by/":
assert self._triple(g, distribution, DCT.rights, URIRef("https://creativecommons.org/licenses/by/4.0/"))

if resource_dict.get('format') == "CSV":
assert self._triple(g, distribution, DCT['format'], URIRef("http://publications.europa.eu/resource/authority/file-type/CSV"))
Expand Down

0 comments on commit c61cdd2

Please sign in to comment.