diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-09-19 14:24:13 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-09-19 14:24:13 +0200 |
| commit | 86188385cbdae1ee90c1dca7a7b9db2edef1ecd4 (patch) | |
| tree | cc01153f05e84ad6cd34556caecd3f4bc335d0bd /packages/meshbay-hub/tests/test_group_hosting.py | |
| parent | d2495a2c4b89fbbfc18cefec83ae96cabdd745e2 (diff) | |
| download | meshbay-86188385cbdae1ee90c1dca7a7b9db2edef1ecd4.tar.gz | |
style: ruff's own fixes, mechanically applied
`ruff check .` had gone unrun long enough to report 568 errors, which is the
same as having no linter: the next real finding would have been invisible in the
noise. This is the 521 it fixes by itself, in 173 files, and nothing else — the
98 it cannot fix are the next commit.
What actually changed: import sorting (225), imports nobody used (87, none of
them a re-export — no `__init__.py` is touched, which was the one way this could
have broken an import elsewhere), `datetime.timezone.utc` to `datetime.UTC` (69)
and `asyncio.TimeoutError` to `TimeoutError` (18), both plain aliases on the 3.12
this project requires, `Optional[X]` to `X | None` (24), and f-strings with
nothing to interpolate (19).
Checked rather than assumed: every module in the three packages still imports,
and the suite is 2893 passed — the same count, test for test, as the merge
before it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-hub/tests/test_group_hosting.py')
| -rw-r--r-- | packages/meshbay-hub/tests/test_group_hosting.py | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/packages/meshbay-hub/tests/test_group_hosting.py b/packages/meshbay-hub/tests/test_group_hosting.py index c571771..c6111f2 100644 --- a/packages/meshbay-hub/tests/test_group_hosting.py +++ b/packages/meshbay-hub/tests/test_group_hosting.py @@ -14,13 +14,12 @@ deleted every group during a hub restart. import base64 import hashlib -from datetime import datetime, timedelta, timezone +from datetime import UTC, datetime, timedelta import pytest -from sqlalchemy import select - from meshbay_hub.db.models import Group, GroupMember from meshbay_hub.tasks.cleanup import find_unhosted_groups, prune_unhosted_groups +from sqlalchemy import select def _auth_key(password: str, username: str) -> str: @@ -49,7 +48,7 @@ async def _group(client, owner, name, visibility="private", join_policy=None): async def _mark_hosted(db_session, group_id, when=None): g = await db_session.get(Group, group_id) - g.hosted_at = when or datetime.now(timezone.utc) + g.hosted_at = when or datetime.now(UTC) await db_session.commit() @@ -134,7 +133,7 @@ async def test_an_unhosted_group_past_the_grace_period_is_collected(client, db_s gid = (await _group(client, owner, "abandoned")).json()["group_id"] g = await db_session.get(Group, gid) - g.created_at = datetime.now(timezone.utc) - timedelta(days=8) + g.created_at = datetime.now(UTC) - timedelta(days=8) await db_session.commit() gone = await prune_unhosted_groups(db_session) @@ -149,8 +148,8 @@ async def test_an_old_group_that_was_hosted_is_never_collected(client, db_sessio gid = (await _group(client, owner, "long-lived")).json()["group_id"] g = await db_session.get(Group, gid) - g.created_at = datetime.now(timezone.utc) - timedelta(days=400) - g.hosted_at = datetime.now(timezone.utc) - timedelta(days=399) + g.created_at = datetime.now(UTC) - timedelta(days=400) + g.hosted_at = datetime.now(UTC) - timedelta(days=399) await db_session.commit() assert await find_unhosted_groups(db_session) == [] @@ -161,7 +160,7 @@ async def test_dry_run_reports_without_deleting(client, db_session): owner = await _user(client, "reaper4_test") gid = (await _group(client, owner, "still-here")).json()["group_id"] g = await db_session.get(Group, gid) - g.created_at = datetime.now(timezone.utc) - timedelta(days=30) + g.created_at = datetime.now(UTC) - timedelta(days=30) await db_session.commit() gone = await prune_unhosted_groups(db_session, dry_run=True) @@ -178,7 +177,7 @@ async def test_collecting_a_group_takes_its_memberships_with_it(client, db_sessi await client.post(f"/v1/groups/{gid}/members/tagalong", json={}, headers=owner) g = await db_session.get(Group, gid) - g.created_at = datetime.now(timezone.utc) - timedelta(days=9) + g.created_at = datetime.now(UTC) - timedelta(days=9) await db_session.commit() await prune_unhosted_groups(db_session) @@ -247,7 +246,7 @@ async def test_the_stamp_is_not_moved_by_a_later_reconnection(client, db_session owner = await _user(client, "stamped2") gid = (await _group(client, owner, "steady")).json()["group_id"] - first = datetime.now(timezone.utc) - timedelta(days=30) + first = datetime.now(UTC) - timedelta(days=30) await _mark_hosted([gid]) g = await db_session.get(Group, gid) g.hosted_at = first @@ -259,7 +258,7 @@ async def test_the_stamp_is_not_moved_by_a_later_reconnection(client, db_session await db_session.refresh(g) # SQLite hands back a naive datetime where PostgreSQL keeps the offset, so # the comparison is made on common ground rather than on the driver. - stored = g.hosted_at.replace(tzinfo=timezone.utc) if g.hosted_at.tzinfo is None \ + stored = g.hosted_at.replace(tzinfo=UTC) if g.hosted_at.tzinfo is None \ else g.hosted_at assert abs((stored - first).total_seconds()) < 1, "the stamp moved" |