Skip to content

Commit

Permalink
feat: Map full media_type onto resource, not just subtype
Browse files Browse the repository at this point in the history
  • Loading branch information
bellisk committed Dec 4, 2023
1 parent 236bd96 commit 138f989
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ckanext/dcatapchharvest/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,10 @@ def _get_iana_media_type(self, subject):
if isinstance(media_type_value_raw, dict):
log.debug("The media type object is a dictionary type.")
else:
pattern = r'[^/]+$' # Match characters that are not '/'
pattern = r'http://www.iana.org/assignments/(.+/.+)$'
media_type_value_re = re.search(pattern, media_type_value_raw)
if media_type_value_re:
media_type_value = media_type_value_re.group(0)
media_type_value = media_type_value_re.group(1)
else:
media_type_value = media_type_value_raw

Expand Down
2 changes: 1 addition & 1 deletion ckanext/dcatapchharvest/tests/fixtures/dataset.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"temporal_resolution":"P1D",
"rights": "http://dcat-ap.ch/vocabulary/licenses/terms_by_ask",
"license": "http://dcat-ap.ch/vocabulary/licenses/cc-by/4.0",
"media_type": "1d-interleaved-parityfec"
"media_type": "application/1d-interleaved-parityfec"
}
],
"extras": [
Expand Down
2 changes: 1 addition & 1 deletion ckanext/dcatapchharvest/tests/test_dcatap_ch_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def test_dataset_all_fields(self):
assert all(l in resource['description'] for l in ['de', 'fr', 'it', 'en']), "resource description contains all languages"
eq_(resource['description']['de'], u'')
eq_(resource['format'], u'html')
eq_(resource['media_type'], 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 CC Zero License (cc-zero)')
Expand Down

0 comments on commit 138f989

Please sign in to comment.