Skip to content

Only use add method when the value is not ellipsis #339

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

Merged
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
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

### Fixed
* Bumped uvicorn version to 0.17 (from >=0.12, <=0.14) to resolve security vulnerability related to websockets dependency version ([#343](https://github.com/stac-utils/stac-fastapi/pull/343))
* `AttributeError` and/or missing properties when requesting the complete `properties`-field in searches. Added test. ([#339](https://github.com/stac-utils/stac-fastapi/pull/339))


## [2.3.0]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def _get_field_dict(fields: Optional[Set[str]]) -> Dict:
if parent not in field_dict:
field_dict[parent] = {key}
else:
field_dict[parent].add(key)
if field_dict[parent] is not ...:
field_dict[parent].add(key)
else:
field_dict[field] = ... # type:ignore
return field_dict
Expand Down
20 changes: 20 additions & 0 deletions stac_fastapi/sqlalchemy/tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,23 @@ def test_search_line_string_intersects(
assert resp.status_code == 200
resp_json = resp.json()
assert len(resp_json["features"]) == 1


def test_app_fields_extension_return_all_properties(
load_test_data, app_client, postgres_transactions
):
item = load_test_data("test_item.json")
postgres_transactions.create_item(item, request=MockStarletteRequest)

resp = app_client.get(
"/search", params={"collections": ["test-collection"], "fields": "properties"}
)
assert resp.status_code == 200
resp_json = resp.json()
feature = resp_json["features"][0]
assert len(feature["properties"]) >= len(item["properties"])
for expected_prop, expected_value in item["properties"].items():
if expected_prop in ("datetime", "created", "updated"):
assert feature["properties"][expected_prop][0:19] == expected_value[0:19]
else:
assert feature["properties"][expected_prop] == expected_value