Skip to content

Commit

Permalink
Update according to updated ruff rules
Browse files Browse the repository at this point in the history
  • Loading branch information
CasperWA committed Nov 27, 2024
1 parent c9f812c commit ec6c39b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
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

0 comments on commit ec6c39b

Please sign in to comment.