From ad1bd97aace094736c1dc73f65b63eb65ae3f921 Mon Sep 17 00:00:00 2001 From: BoulderBadgeDad Date: Fri, 5 Jun 2026 12:51:01 -0700 Subject: [PATCH] Fix MB-worker alias test fixtures missing self.db MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The #799 uniqueness-guard added a source_id_conflict(self.db, ...) call to the MusicBrainz worker's artist path. Two TestWorkerAliasEnrichment fixtures build the worker via __new__ and set only .database, not .db, so the new call raised AttributeError and the artist was marked 'error'. Mirror the third fixture (which already sets worker.db). Production always sets self.db in __init__ — test-only gap exposed by the new code path. --- tests/matching/test_artist_alias_service.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/matching/test_artist_alias_service.py b/tests/matching/test_artist_alias_service.py index a895f942..293c874f 100644 --- a/tests/matching/test_artist_alias_service.py +++ b/tests/matching/test_artist_alias_service.py @@ -270,6 +270,7 @@ class TestWorkerAliasEnrichment: worker = MusicBrainzWorker.__new__(MusicBrainzWorker) worker.database = temp_db + worker.db = temp_db # worker code uses self.db (e.g. source_id_conflict) worker.mb_service = MagicMock() worker.mb_service.match_artist.return_value = { 'mbid': '60d2ea34-1912-425f-bf9c-fc544e4448cd', 'name': 'Hiroyuki Sawano', @@ -300,6 +301,7 @@ class TestWorkerAliasEnrichment: worker = MusicBrainzWorker.__new__(MusicBrainzWorker) worker.database = temp_db + worker.db = temp_db # worker code uses self.db (e.g. source_id_conflict) worker.mb_service = MagicMock() worker.mb_service.match_artist.return_value = None worker.stats = {'matched': 0, 'not_found': 0, 'errors': 0} @@ -392,6 +394,7 @@ class TestWorkerAliasEnrichment: worker = MusicBrainzWorker.__new__(MusicBrainzWorker) worker.database = temp_db + worker.db = temp_db # worker code uses self.db (e.g. source_id_conflict) worker.mb_service = MagicMock() worker.mb_service.match_artist.return_value = {'mbid': 'mb-x', 'name': 'X'} worker.mb_service.fetch_artist_aliases.side_effect = Exception("boom")