From 3fe2cecb3cdf6692b809d6269909eef7d03a1b3f Mon Sep 17 00:00:00 2001 From: Rae Knowler Date: Mon, 20 Nov 2023 16:16:55 +0100 Subject: [PATCH] fix: Fix getting EU theme urls from the mapping The EU theme mapping returns a list of URIRefs of themes for each DCAT theme, but each list only contains one entry. --- ckanext/dcatapchharvest/profiles.py | 4 +-- .../tests/fixtures/catalog-themes.xml | 35 +++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 ckanext/dcatapchharvest/tests/fixtures/catalog-themes.xml diff --git a/ckanext/dcatapchharvest/profiles.py b/ckanext/dcatapchharvest/profiles.py index 3a266ec..401ba80 100644 --- a/ckanext/dcatapchharvest/profiles.py +++ b/ckanext/dcatapchharvest/profiles.py @@ -436,14 +436,14 @@ def _get_groups(self, subject): new_theme_url = dcat_theme_url.replace( OGD_THEMES_URI, CHTHEMES_URI) eu_theme_url = unicode( - eu_theme_mapping[URIRef(new_theme_url)]) + eu_theme_mapping[URIRef(new_theme_url)][0]) # Case 2: We get a dcat-ap.ch theme (the same as the # opendata.swiss themes, but different base url). Get # the correct EU theme from the theme mapping. elif dcat_theme_url.startswith(CHTHEMES_URI): eu_theme_url = unicode( - eu_theme_mapping[URIRef(dcat_theme_url)]) + eu_theme_mapping[URIRef(dcat_theme_url)][0]) # Case 3: We get an EU theme and don't need to look it up in # the mapping. diff --git a/ckanext/dcatapchharvest/tests/fixtures/catalog-themes.xml b/ckanext/dcatapchharvest/tests/fixtures/catalog-themes.xml new file mode 100644 index 0000000..44e87bd --- /dev/null +++ b/ckanext/dcatapchharvest/tests/fixtures/catalog-themes.xml @@ -0,0 +1,35 @@ + + + + BFS - OGD Collection + BFS - OGD Collection + + + 346252@bundesamt-fur-statistik-bfs + 1990-12-31T23:00:00Z + 1991-02-19T23:00:00Z + + + + + 346252@bundesamt-fur-statistik-bfs + 1992-12-31 + 1993-02-19 + + + + + 346252@bundesamt-fur-statistik-bfs + 1994-12 + 1995-02 + + + + + 346252@bundesamt-fur-statistik-bfs + 1996 + 1997 + + + +