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

[pre-commit.ci] pre-commit autoupdate #538

Merged
merged 3 commits into from
Nov 27, 2024
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: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ repos:
- id: black

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.4
rev: v0.8.0
hooks:
- id: ruff
args:
Expand Down
4 changes: 2 additions & 2 deletions optimade_gateway/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
"GatewayResourceAttributes",
"GatewaysResponse",
"GatewaysResponseSingle",
"QueriesResponse",
"QueriesResponseSingle",
"QueryCreate",
"QueryResource",
"QueryState",
"QueriesResponse",
"QueriesResponseSingle",
"Search",
)
2 changes: 1 addition & 1 deletion optimade_gateway/routers/databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ async def get_database(
include_fields,
) = await collection.afind(params=params)

if fields or include_fields and result is not None:
if fields or (include_fields and result is not None):
result = handle_response_fields(result, fields, include_fields)

result = result[0] if isinstance(result, list) and data_returned else None
Expand Down
12 changes: 7 additions & 5 deletions tests/routers/test_databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ async def test_post_databases(client: AsyncGatewayClient) -> None:
datum = response.data
assert datum, response

for field in data:
for field, field_value in data.items():
value = getattr(response.data.attributes, field)
if isinstance(value, AnyUrl):
assert str(value) == data[field], (
assert str(value) == field_value, (
f"Response: {response.data.attributes.model_dump()!r}\n\n"
f"Test data: {data!r}"
)
else:
assert value == data[field], (
assert value == field_value, (
f"Response: {response.data.attributes.model_dump()!r}\n\n"
f"Test data: {data!r}"
)
Expand All @@ -88,8 +88,10 @@ async def test_post_databases(client: AsyncGatewayClient) -> None:
mongo_filter = {"_id": ObjectId(datum.id)}
assert await MONGO_DB["databases"].count_documents(mongo_filter) == 1
db_datum = await MONGO_DB["databases"].find_one(mongo_filter)
for field in data:
assert db_datum[field] == data[field]
for field, field_value in data.items():
assert (
db_datum[field] == field_value
), f"Response: {db_datum!r}\n\nTest data: {data!r}"


async def test_get_single_database(
Expand Down
4 changes: 2 additions & 2 deletions tests/routers/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ async def test_post_queries(
mongo_filter = {"_id": ObjectId(datum.id)}
assert await MONGO_DB["queries"].count_documents(mongo_filter) == 1
db_datum = await MONGO_DB["queries"].find_one(mongo_filter)
for key in data:
assert db_datum[key] == data[key]
for key, value in data.items():
assert db_datum[key] == value, f"Response: {db_datum!r}\n\nTest data: {data!r}"

await asyncio.sleep(1) # Ensure mock URL is queried

Expand Down