From 83afff2da59764ca740fcf8f8de13f54afa1a7ab Mon Sep 17 00:00:00 2001 From: Hans-Chrstian Date: Tue, 19 Nov 2024 17:18:57 +0100 Subject: [PATCH 1/3] fix: Move has version from distribution to dataset --- ckanext/dcat/schemas/dcat_ap_full.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ckanext/dcat/schemas/dcat_ap_full.yaml b/ckanext/dcat/schemas/dcat_ap_full.yaml index 82ee2dfd..47bc85fe 100644 --- a/ckanext/dcat/schemas/dcat_ap_full.yaml +++ b/ckanext/dcat/schemas/dcat_ap_full.yaml @@ -258,6 +258,13 @@ dataset_fields: validators: ignore_missing scheming_multiple_text help_text: The legislation that mandates the creation or management of the dataset. +- field_name: has_version + label: Has version + preset: multiple_text + validators: ignore_missing scheming_multiple_text + help_inline: true + help_text: This property refers to a related Dataset that is a version, edition, or adaptation of the described Dataset. + #- field_name: hvd_category # label: HVD Category # preset: multiple_text @@ -348,13 +355,6 @@ resource_fields: label: License help_text: License in which the resource is made available. If not provided will be inherited from the dataset. -- field_name: has_version - label: Has version - preset: multiple_text - validators: ignore_missing scheming_multiple_text - help_inline: true - help_text: This property refers to a related Dataset that is a version, edition, or adaptation of the described Dataset. - # Note: this falls back to the standard resource url field - field_name: access_url label: Access URL From 12c0265b5c64ec2d2e749c8cdca33e29f33b5b63 Mon Sep 17 00:00:00 2001 From: amercader Date: Thu, 21 Nov 2024 13:00:43 +0100 Subject: [PATCH 2/3] Update tests for changes in date parsing in rdflib Rdflib 7.1 introduced changes in [date parsing][1] that made some base profile tests fail. Basically the previous rdflib versions incomplete dates like 1904 were expanded to `1904-01-01`. Of course this is not a valid date and should be expressed using `gYear`: 1904 and we should be expecting `1904`. This should play nice with the time properties we are generating in CKAN as they already handle automatically `gYear`, `gYearMonth`, `date` and `dateTime`. Sites importing external DCAT representations that use the wrong encoding might need to check their parsers. [1] https://github.com/RDFLib/rdflib/pull/2929 --- ckanext/dcat/profiles/base.py | 3 -- .../tests/profiles/base/test_base_profile.py | 28 +++++++++---------- requirements.txt | 2 +- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/ckanext/dcat/profiles/base.py b/ckanext/dcat/profiles/base.py index 5cf15c55..efb30d29 100644 --- a/ckanext/dcat/profiles/base.py +++ b/ckanext/dcat/profiles/base.py @@ -433,9 +433,6 @@ def _time_interval(self, subject, predicate, dcat_ap_version=1): It checks for time intervals defined with DCAT, W3C Time hasBeginning & hasEnd and schema.org startDate & endDate. - Note that partial dates will be expanded to the first month / day - value, eg '1904' -> '1904-01-01'. - Returns a tuple with the start and end date values, both of which can be None if not found """ diff --git a/ckanext/dcat/tests/profiles/base/test_base_profile.py b/ckanext/dcat/tests/profiles/base/test_base_profile.py index aa8daf1e..f7b6da9f 100644 --- a/ckanext/dcat/tests/profiles/base/test_base_profile.py +++ b/ckanext/dcat/tests/profiles/base/test_base_profile.py @@ -510,7 +510,7 @@ def test_time_interval_w3c_time_inXSDDateTime(self): - 1904 + 1904 @@ -532,7 +532,7 @@ def test_time_interval_w3c_time_inXSDDateTime(self): start, end = p._time_interval(URIRef('http://example.org'), DCT.temporal) - assert start == '1904-01-01' + assert start == '1904' assert end == '2014-03-22' def test_time_interval_w3c_time_inXSDDateTimeStamp(self): @@ -548,7 +548,7 @@ def test_time_interval_w3c_time_inXSDDateTimeStamp(self): - 1904 + 1904 @@ -570,7 +570,7 @@ def test_time_interval_w3c_time_inXSDDateTimeStamp(self): start, end = p._time_interval(URIRef('http://example.org'), DCT.temporal) - assert start == '1904-01-01' + assert start == '1904' assert end == '2014-03-22' def test_time_interval_w3c_time_inXSDDate(self): @@ -586,7 +586,7 @@ def test_time_interval_w3c_time_inXSDDate(self): - 1904 + 1904 @@ -608,7 +608,7 @@ def test_time_interval_w3c_time_inXSDDate(self): start, end = p._time_interval(URIRef('http://example.org'), DCT.temporal) - assert start == '1904-01-01' + assert start == '1904' assert end == '2014-03-22' def test_time_interval_multiple_w3c_time(self): @@ -627,9 +627,9 @@ def test_time_interval_multiple_w3c_time(self): - 2005 - 1904 - 1974 + 2005 + 1904 + 1974 @@ -653,7 +653,7 @@ def test_time_interval_multiple_w3c_time(self): start, end = p._time_interval(URIRef('http://example.org'), DCT.temporal) - assert start == '1904-01-01' + assert start == '1904' assert end == '2014-03-22' def test_time_interval_dcat(self): @@ -706,7 +706,7 @@ def test_time_interval_all_dcat_ap_2_dcat_found(self): - 1904 + 1904 @@ -763,7 +763,7 @@ def test_time_interval_all_dcat_ap_1_schema_org_found(self): - 1904 + 1904 @@ -827,7 +827,7 @@ def test_time_interval_all_dcat_ap_2_w3c_time_found(self): - 1904 + 1904 @@ -849,7 +849,7 @@ def test_time_interval_all_dcat_ap_2_w3c_time_found(self): start, end = p._time_interval(URIRef('http://example.org'), DCT.temporal, dcat_ap_version=2) - assert start == '1904-01-01' + assert start == '1904' assert end == '2014-03-22' def test_publisher_foaf(self): diff --git a/requirements.txt b/requirements.txt index 28bad239..0eb6dabe 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -rdflib>=6.1.1,<7.1.0 +rdflib>=6.1.1,<7.2.0 geomet>=0.2.0 ckantoolkit>=0.0.7 future>=0.18.2 From 616a14fdaddbb507c12b6b9bf33d0992d3721ecd Mon Sep 17 00:00:00 2001 From: amercader Date: Mon, 25 Nov 2024 15:43:31 +0100 Subject: [PATCH 3/3] Run tests as root See https://github.com/ckan/ckan-docker-base/releases/tag/v20241125 --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1dffeb98..88d8deaa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,6 +32,7 @@ jobs: runs-on: ubuntu-latest container: image: ${{ matrix.ckan-image }} + options: --user root services: solr: image: ckan/ckan-solr:${{ matrix.ckan-version }}-solr9