Skip to content

Commit e9cc853

Browse files
authored
update STAC API testing (#1074)
1 parent 755be2c commit e9cc853

File tree

37 files changed

+26876
-44
lines changed

37 files changed

+26876
-44
lines changed

pycsw/core/metadata.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Authors: Tom Kralidis <[email protected]>
55
# Ricardo Garcia Silva <[email protected]>
66
#
7-
# Copyright (c) 2023 Tom Kralidis
7+
# Copyright (c) 2025 Tom Kralidis
88
# Copyright (c) 2016 James F. Dickens
99
# Copyright (c) 2017 Ricardo Garcia Silva
1010
#
@@ -1760,7 +1760,7 @@ def _parse_oarec_record(context, repos, record):
17601760
_set(context, recobj, 'pycsw:InsertDate', util.get_today_and_now())
17611761
_set(context, recobj, 'pycsw:XML', '') # FIXME: transform into XML? or not, to validate
17621762
_set(context, recobj, 'pycsw:Metadata', json.dumps(record))
1763-
_set(context, recobj, 'pycsw:MetadataType', 'application/json')
1763+
_set(context, recobj, 'pycsw:MetadataType', 'application/geo+json')
17641764

17651765
_set(context, recobj, 'pycsw:AnyText', ' '.join([str(t) for t in util.get_anytext_from_obj(record)]))
17661766

@@ -1820,6 +1820,7 @@ def _parse_stac_resource(context, repos, record):
18201820
LOGGER.debug('Parsing STAC Item')
18211821
conformance = 'https://github.com/radiantearth/stac-spec/tree/master/item-spec/item-spec.md'
18221822
typename = 'stac:Item'
1823+
metadata_type = 'application/geo+json'
18231824
stype = 'item'
18241825
title = record['properties'].get('title')
18251826
abstract = record['properties'].get('description')
@@ -1829,6 +1830,7 @@ def _parse_stac_resource(context, repos, record):
18291830
LOGGER.debug('Parsing STAC Collection')
18301831
conformance = 'https://github.com/radiantearth/stac-spec/tree/master/collection-spec/collection-spec.md'
18311832
typename = 'stac:Collection'
1833+
metadata_type = 'application/json'
18321834
stype = 'collection'
18331835
title = record.get('title')
18341836
abstract = record.get('description')
@@ -1842,6 +1844,7 @@ def _parse_stac_resource(context, repos, record):
18421844
LOGGER.debug('Parsing STAC Catalog')
18431845
conformance = 'https://github.com/radiantearth/stac-spec/tree/master/catalog-spec/catalog-spec.md'
18441846
typename = 'stac:Catalog'
1847+
metadata_type = 'application/json'
18451848
stype = 'catalog'
18461849
title = record.get('title')
18471850
abstract = record.get('description')
@@ -1853,7 +1856,7 @@ def _parse_stac_resource(context, repos, record):
18531856
_set(context, recobj, 'pycsw:InsertDate', util.get_today_and_now())
18541857
_set(context, recobj, 'pycsw:XML', '') # FIXME: transform into XML? or not, to validate
18551858
_set(context, recobj, 'pycsw:Metadata', json.dumps(record))
1856-
_set(context, recobj, 'pycsw:MetadataType', 'application/json')
1859+
_set(context, recobj, 'pycsw:MetadataType', metadata_type)
18571860
_set(context, recobj, 'pycsw:AnyText', ' '.join([str(t) for t in util.get_anytext_from_obj(record)]))
18581861
_set(context, recobj, 'pycsw:Type', stype)
18591862
_set(context, recobj, 'pycsw:Title', title)

pycsw/ogc/api/records.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Authors: Tom Kralidis <[email protected]>
44
# Angelos Tzotsos <[email protected]>
55
#
6-
# Copyright (c) 2024 Tom Kralidis
6+
# Copyright (c) 2025 Tom Kralidis
77
# Copyright (c) 2021 Angelos Tzotsos
88
#
99
# Permission is hereby granted, free of charge, to any person

pycsw/ogc/api/util.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Authors: Tom Kralidis <[email protected]>
55
# Angelos Tzotsos <[email protected]>
66
#
7-
# Copyright (c) 2024 Tom Kralidis
7+
# Copyright (c) 2025 Tom Kralidis
88
# Copyright (c) 2021 Angelos Tzotsos
99
#
1010
# Permission is hereby granted, free of charge, to any person
@@ -91,10 +91,10 @@ def json_serial(obj):
9191
"""
9292

9393
if isinstance(obj, (datetime, date, time)):
94-
if isinstance(obj, date):
94+
if isinstance(obj, (datetime, time)):
95+
return obj.strftime('%Y-%m-%dT%H:%M:%SZ')
96+
else: # date
9597
return obj.strftime('%Y-%m-%d')
96-
else:
97-
return obj.isoformat() + 'Z'
9898
elif isinstance(obj, bytes):
9999
try:
100100
LOGGER.debug('Returning as UTF-8 decoded bytes')
@@ -248,5 +248,6 @@ def to_rfc3339(value: str) -> Union[tuple, None]:
248248
dt_type = 'date'
249249
else:
250250
dt_type = 'date-time'
251+
dt_type = 'date-time'
251252

252253
return dt, dt_type

pycsw/stac/api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Authors: Tom Kralidis <[email protected]>
44
#
5-
# Copyright (c) 2024 Tom Kralidis
5+
# Copyright (c) 2025 Tom Kralidis
66
#
77
# Permission is hereby granted, free of charge, to any person
88
# obtaining a copy of this software and associated documentation

tests/functionaltests/suites/stac_api/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def config():
106106
}
107107
},
108108
'repository': {
109-
'database': 'sqlite:///tests/functionaltests/suites/cite/data/cite.db',
109+
'database': 'sqlite:///tests/functionaltests/suites/stac_api/data/records.db',
110110
'table': 'records',
111111
}
112112
}

0 commit comments

Comments
 (0)