Skip to content

Commit

Permalink
Merge pull request #323 from ckan/upgrade-rdflib-dates
Browse files Browse the repository at this point in the history
Update tests for changes in date parsing in new rdflib versions
  • Loading branch information
amercader authored Nov 25, 2024
2 parents c3cceda + 616a14f commit 81a85cc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions ckanext/dcat/profiles/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down
28 changes: 14 additions & 14 deletions ckanext/dcat/tests/profiles/base/test_base_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def test_time_interval_w3c_time_inXSDDateTime(self):
<dct:PeriodOfTime>
<time:hasBeginning>
<time:Instant>
<time:inXSDDateTime rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1904</time:inXSDDateTime>
<time:inXSDDateTime rdf:datatype="http://www.w3.org/2001/XMLSchema#gYear">1904</time:inXSDDateTime>
</time:Instant>
</time:hasBeginning>
<time:hasEnd>
Expand All @@ -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):
Expand All @@ -548,7 +548,7 @@ def test_time_interval_w3c_time_inXSDDateTimeStamp(self):
<dct:PeriodOfTime>
<time:hasBeginning>
<time:Instant>
<time:inXSDDateTimeStamp rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1904</time:inXSDDateTimeStamp>
<time:inXSDDateTimeStamp rdf:datatype="http://www.w3.org/2001/XMLSchema#gYear">1904</time:inXSDDateTimeStamp>
</time:Instant>
</time:hasBeginning>
<time:hasEnd>
Expand All @@ -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):
Expand All @@ -586,7 +586,7 @@ def test_time_interval_w3c_time_inXSDDate(self):
<dct:PeriodOfTime>
<time:hasBeginning>
<time:Instant>
<time:inXSDDate rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1904</time:inXSDDate>
<time:inXSDDate rdf:datatype="http://www.w3.org/2001/XMLSchema#gYear">1904</time:inXSDDate>
</time:Instant>
</time:hasBeginning>
<time:hasEnd>
Expand All @@ -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):
Expand All @@ -627,9 +627,9 @@ def test_time_interval_multiple_w3c_time(self):
<dct:PeriodOfTime>
<time:hasBeginning>
<time:Instant>
<time:inXSDDateTime rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2005</time:inXSDDateTime>
<time:inXSDDateTimeStamp rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1904</time:inXSDDateTimeStamp>
<time:inXSDDate rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1974</time:inXSDDate>
<time:inXSDDateTime rdf:datatype="http://www.w3.org/2001/XMLSchema#gYear">2005</time:inXSDDateTime>
<time:inXSDDateTimeStamp rdf:datatype="http://www.w3.org/2001/XMLSchema#gYear">1904</time:inXSDDateTimeStamp>
<time:inXSDDate rdf:datatype="http://www.w3.org/2001/XMLSchema#gYear">1974</time:inXSDDate>
</time:Instant>
</time:hasBeginning>
<time:hasEnd>
Expand All @@ -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):
Expand Down Expand Up @@ -706,7 +706,7 @@ def test_time_interval_all_dcat_ap_2_dcat_found(self):
<dct:PeriodOfTime>
<time:hasBeginning>
<time:Instant>
<time:inXSDDateTime rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1904</time:inXSDDateTime>
<time:inXSDDateTime rdf:datatype="http://www.w3.org/2001/XMLSchema#gYear">1904</time:inXSDDateTime>
</time:Instant>
</time:hasBeginning>
<time:hasEnd>
Expand Down Expand Up @@ -763,7 +763,7 @@ def test_time_interval_all_dcat_ap_1_schema_org_found(self):
<dct:PeriodOfTime>
<time:hasBeginning>
<time:Instant>
<time:inXSDDateTime rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1904</time:inXSDDateTime>
<time:inXSDDateTime rdf:datatype="http://www.w3.org/2001/XMLSchema#gYear">1904</time:inXSDDateTime>
</time:Instant>
</time:hasBeginning>
<time:hasEnd>
Expand Down Expand Up @@ -827,7 +827,7 @@ def test_time_interval_all_dcat_ap_2_w3c_time_found(self):
<dct:PeriodOfTime>
<time:hasBeginning>
<time:Instant>
<time:inXSDDateTime rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1904</time:inXSDDateTime>
<time:inXSDDateTime rdf:datatype="http://www.w3.org/2001/XMLSchema#gYear">1904</time:inXSDDateTime>
</time:Instant>
</time:hasBeginning>
<time:hasEnd>
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 81a85cc

Please sign in to comment.