From 7625362c49714508f65aaade15c5b3cb097b0a8c Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Wed, 22 Apr 2026 20:56:10 -0700 Subject: [PATCH] Fix date-dependent watchlist scanner tests failing on CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The three discovery-pool tests hardcoded release_date strings ("2026-04-01", "2026-04-16") that were checked against a rolling `datetime.now() - timedelta(days=7)` (or 21-60 day) cutoff in the scanner. Once the wall clock advanced past the cutoff window the releases were filtered out and the assertions failed — Python 3.11 Linux CI was already past 2026-04-23 UTC. Replace the hardcoded values with a module-level `_RECENT_RELEASE_DATE = now - 2 days` so the fixtures stay inside every cutoff window regardless of when the suite runs. --- tests/test_watchlist_scanner_scan.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/test_watchlist_scanner_scan.py b/tests/test_watchlist_scanner_scan.py index 1a077363..dcddd3df 100644 --- a/tests/test_watchlist_scanner_scan.py +++ b/tests/test_watchlist_scanner_scan.py @@ -1,5 +1,9 @@ import sys import types +from datetime import datetime, timedelta + + +_RECENT_RELEASE_DATE = (datetime.now() - timedelta(days=2)).strftime("%Y-%m-%d") if "spotipy" not in sys.modules: @@ -889,7 +893,7 @@ def test_cache_discovery_recent_albums_uses_primary_source_first(monkeypatch): id="dz-album-1", name="Recent Deezer Album", album_type="album", - release_date="2026-04-01", + release_date=_RECENT_RELEASE_DATE, image_url="https://example.com/deezer-album.jpg", ) @@ -941,7 +945,7 @@ def test_cache_discovery_recent_albums_falls_back_to_spotify_when_primary_has_no id="sp-album-1", name="Spotify Recent Album", album_type="album", - release_date="2026-04-01", + release_date=_RECENT_RELEASE_DATE, image_url="https://example.com/spotify-album.jpg", ) spotify_client = _FakeSourceClient( @@ -952,7 +956,7 @@ def test_cache_discovery_recent_albums_falls_back_to_spotify_when_primary_has_no "id": "sp-album-1", "name": "Spotify Recent Album", "images": [{"url": "https://example.com/spotify-album.jpg"}], - "release_date": "2026-04-01", + "release_date": _RECENT_RELEASE_DATE, "popularity": 50, "tracks": {"items": [{"id": "sp-track-1", "name": "Spotify Track", "artists": [{"name": "Fallback Artist"}]}]}, "artists": [{"id": "sp-artist"}], @@ -992,7 +996,7 @@ def test_update_discovery_pool_incremental_uses_source_priority(monkeypatch): release = types.SimpleNamespace( id="dz-release-1", name="Incremental Release", - release_date="2026-04-16", + release_date=_RECENT_RELEASE_DATE, album_type="album", image_url="https://example.com/deezer-release.jpg", ) @@ -1005,7 +1009,7 @@ def test_update_discovery_pool_incremental_uses_source_priority(monkeypatch): "id": "dz-release-1", "name": "Incremental Release", "images": [{"url": "https://example.com/deezer-release.jpg"}], - "release_date": "2026-04-16", + "release_date": _RECENT_RELEASE_DATE, "popularity": 10, "tracks": {"items": [{"id": "dz-track-1", "name": "Incremental Track", "artists": [{"name": "Incremental Artist"}], "duration_ms": 180000}]}, "artists": [{"id": "dz-artist"}], @@ -1019,7 +1023,7 @@ def test_update_discovery_pool_incremental_uses_source_priority(monkeypatch): "id": "sp-release-1", "name": "Spotify Incremental Release", "images": [{"url": "https://example.com/spotify-release.jpg"}], - "release_date": "2026-04-16", + "release_date": _RECENT_RELEASE_DATE, "popularity": 50, "tracks": {"items": [{"id": "sp-track-1", "name": "Spotify Incremental Track", "artists": [{"name": "Incremental Artist"}], "duration_ms": 180000}]}, "artists": [{"id": "sp-artist"}],