From f8614d437ddef416f074c017dcb653794a7c6449 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Fri, 11 Sep 2026 08:02:08 -0400 Subject: [PATCH] fix: a self-contradicting test fixture, and import order (E4 follow-up) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two failures on 51e78a3, neither in the shipped logic. **The integration failure was a TEST bug, not a code bug.** `test_a_weak_name_needs_the_declaration` set `display_name` to something deliberately weak but left `_membership`'s DEFAULT vanity, which matched the artist slug exactly. So the name signal was legitimately 1.0 and the matcher was right to propose — my assertion of 0 was asserting the wrong scenario. Both identity fields now have to be weak for the test to mean what it says, and the arithmetic was checked before pushing: 0.39 without the declaration, 0.74 with it. Worth keeping: a fixture whose fields disagree with each other will pass or fail for reasons unrelated to the property under test, and this one was one default away from silently testing nothing. **The lint failure was import order** — `artist_membership_service` sorts before `credential_*` and I inserted it after. Second isort slip this session from patching an import block with a script rather than reading it back; the repo has a rule about exactly this (#102). Everything else passed on that SHA: 1256 tests, the frontend suite, and migration 0096. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01LNXXULQDjVZmbuNa2G9mD9 --- backend/app/tasks/maintenance.py | 2 +- tests/test_artist_membership_suggestions.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/backend/app/tasks/maintenance.py b/backend/app/tasks/maintenance.py index fbf94bf..2af679c 100644 --- a/backend/app/tasks/maintenance.py +++ b/backend/app/tasks/maintenance.py @@ -1244,9 +1244,9 @@ def sync_memberships() -> str: """ import asyncio + from ..services.artist_membership_service import rescan as membership_rescan from ..services.credential_crypto import CredentialCrypto from ..services.credential_service import CredentialService - from ..services.artist_membership_service import rescan as membership_rescan from ..services.membership_roster import sync_platform from ..services.patreon_client import PatreonClient from ._async_session import async_session_factory diff --git a/tests/test_artist_membership_suggestions.py b/tests/test_artist_membership_suggestions.py index fd2eeb0..2a9bbe6 100644 --- a/tests/test_artist_membership_suggestions.py +++ b/tests/test_artist_membership_suggestions.py @@ -181,13 +181,21 @@ async def test_an_artist_with_no_sources_at_all_is_never_proposed(db): @pytest.mark.asyncio async def test_a_weak_name_needs_the_declaration(db): artist = await _artist_with_discord(db, "Maewix", "maewix") - m = await _membership(db, display_name="Maewix Studios Official") + # BOTH identity fields must be weak, or the test contradicts itself: the + # first draft left the default vanity exactly matching the artist slug, so + # the name signal was legitimately 1.0 and the code was right to propose. + # CI caught it — a test bug, not a code bug. + m = await _membership( + db, display_name="Maewix Studios Official", + details={"campaign": {"vanity": "maewixstudios"}}, + url="https://www.patreon.com/maewixstudios", + ) await db.commit() assert await ArtistMembershipService(db).match_membership(m.id) == 0 db.add(Post( artist_id=artist.id, source_id=None, external_post_id="p1", - description='my patreon', + description='mine', post_date=datetime.now(UTC), )) await db.commit()