Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update STAC data tests #1074

Merged
merged 1 commit into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions pycsw/core/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Authors: Tom Kralidis <[email protected]>
# Ricardo Garcia Silva <[email protected]>
#
# Copyright (c) 2023 Tom Kralidis
# Copyright (c) 2025 Tom Kralidis
# Copyright (c) 2016 James F. Dickens
# Copyright (c) 2017 Ricardo Garcia Silva
#
Expand Down Expand Up @@ -1760,7 +1760,7 @@ def _parse_oarec_record(context, repos, record):
_set(context, recobj, 'pycsw:InsertDate', util.get_today_and_now())
_set(context, recobj, 'pycsw:XML', '') # FIXME: transform into XML? or not, to validate
_set(context, recobj, 'pycsw:Metadata', json.dumps(record))
_set(context, recobj, 'pycsw:MetadataType', 'application/json')
_set(context, recobj, 'pycsw:MetadataType', 'application/geo+json')

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

Expand Down Expand Up @@ -1820,6 +1820,7 @@ def _parse_stac_resource(context, repos, record):
LOGGER.debug('Parsing STAC Item')
conformance = 'https://github.com/radiantearth/stac-spec/tree/master/item-spec/item-spec.md'
typename = 'stac:Item'
metadata_type = 'application/geo+json'
stype = 'item'
title = record['properties'].get('title')
abstract = record['properties'].get('description')
Expand All @@ -1829,6 +1830,7 @@ def _parse_stac_resource(context, repos, record):
LOGGER.debug('Parsing STAC Collection')
conformance = 'https://github.com/radiantearth/stac-spec/tree/master/collection-spec/collection-spec.md'
typename = 'stac:Collection'
metadata_type = 'application/json'
stype = 'collection'
title = record.get('title')
abstract = record.get('description')
Expand All @@ -1842,6 +1844,7 @@ def _parse_stac_resource(context, repos, record):
LOGGER.debug('Parsing STAC Catalog')
conformance = 'https://github.com/radiantearth/stac-spec/tree/master/catalog-spec/catalog-spec.md'
typename = 'stac:Catalog'
metadata_type = 'application/json'
stype = 'catalog'
title = record.get('title')
abstract = record.get('description')
Expand All @@ -1853,7 +1856,7 @@ def _parse_stac_resource(context, repos, record):
_set(context, recobj, 'pycsw:InsertDate', util.get_today_and_now())
_set(context, recobj, 'pycsw:XML', '') # FIXME: transform into XML? or not, to validate
_set(context, recobj, 'pycsw:Metadata', json.dumps(record))
_set(context, recobj, 'pycsw:MetadataType', 'application/json')
_set(context, recobj, 'pycsw:MetadataType', metadata_type)
_set(context, recobj, 'pycsw:AnyText', ' '.join([str(t) for t in util.get_anytext_from_obj(record)]))
_set(context, recobj, 'pycsw:Type', stype)
_set(context, recobj, 'pycsw:Title', title)
Expand Down
2 changes: 1 addition & 1 deletion pycsw/ogc/api/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Authors: Tom Kralidis <[email protected]>
# Angelos Tzotsos <[email protected]>
#
# Copyright (c) 2024 Tom Kralidis
# Copyright (c) 2025 Tom Kralidis
# Copyright (c) 2021 Angelos Tzotsos
#
# Permission is hereby granted, free of charge, to any person
Expand Down
9 changes: 5 additions & 4 deletions pycsw/ogc/api/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Authors: Tom Kralidis <[email protected]>
# Angelos Tzotsos <[email protected]>
#
# Copyright (c) 2024 Tom Kralidis
# Copyright (c) 2025 Tom Kralidis
# Copyright (c) 2021 Angelos Tzotsos
#
# Permission is hereby granted, free of charge, to any person
Expand Down Expand Up @@ -91,10 +91,10 @@ def json_serial(obj):
"""

if isinstance(obj, (datetime, date, time)):
if isinstance(obj, date):
if isinstance(obj, (datetime, time)):
return obj.strftime('%Y-%m-%dT%H:%M:%SZ')
else: # date
return obj.strftime('%Y-%m-%d')
else:
return obj.isoformat() + 'Z'
elif isinstance(obj, bytes):
try:
LOGGER.debug('Returning as UTF-8 decoded bytes')
Expand Down Expand Up @@ -248,5 +248,6 @@ def to_rfc3339(value: str) -> Union[tuple, None]:
dt_type = 'date'
else:
dt_type = 'date-time'
dt_type = 'date-time'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a duplicate?


return dt, dt_type
2 changes: 1 addition & 1 deletion pycsw/stac/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Authors: Tom Kralidis <[email protected]>
#
# Copyright (c) 2024 Tom Kralidis
# Copyright (c) 2025 Tom Kralidis
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
Expand Down
2 changes: 1 addition & 1 deletion tests/functionaltests/suites/stac_api/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def config():
}
},
'repository': {
'database': 'sqlite:///tests/functionaltests/suites/cite/data/cite.db',
'database': 'sqlite:///tests/functionaltests/suites/stac_api/data/records.db',
'table': 'records',
}
}
Expand Down
Loading