Skip to content

Commit

Permalink
Fix some pydantic 2.0 DeprecationWarnings (#289)
Browse files Browse the repository at this point in the history
**Description:**

The test suite is throwing many `DeprecationWarning`s and
`UserWarning`s.

This PR addresses only one class: a pydantic 2.0 `DeprecationWarning`
caused by `.dict()` calls in the test suite itself.

**PR Checklist:**

- [x] Code is formatted and linted (run `pre-commit run --all-files`)
- [x] Tests pass (run `make test`)
- [ ] Documentation has been updated to reflect changes, if applicable
- [ ] Changes are added to the changelog
  • Loading branch information
kurtmckee authored Aug 23, 2024
1 parent 6fb8278 commit 1396fce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions stac_fastapi/tests/clients/test_elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,11 @@ async def test_create_item(ctx, core_client, txn_client):
resp = await core_client.get_item(
ctx.item["id"], ctx.item["collection"], request=MockRequest
)
assert Item(**ctx.item).dict(
assert Item(**ctx.item).model_dump(
exclude={"links": ..., "properties": {"created", "updated"}}
) == Item(**resp).dict(exclude={"links": ..., "properties": {"created", "updated"}})
) == Item(**resp).model_dump(
exclude={"links": ..., "properties": {"created", "updated"}}
)


@pytest.mark.asyncio
Expand Down
2 changes: 1 addition & 1 deletion stac_fastapi/tests/resources/test_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ async def test_field_extension_exclude_default_includes(app_client, ctx):
async def test_search_intersects_and_bbox(app_client):
"""Test POST search intersects and bbox are mutually exclusive (core)"""
bbox = [-118, 34, -117, 35]
geoj = Polygon.from_bounds(*bbox).dict(exclude_none=True)
geoj = Polygon.from_bounds(*bbox).model_dump(exclude_none=True)
params = {"bbox": bbox, "intersects": geoj}
resp = await app_client.post("/search", json=params)
assert resp.status_code == 400
Expand Down

0 comments on commit 1396fce

Please sign in to comment.