diff --git a/tests/test_patreon_ingester.py b/tests/test_patreon_ingester.py index 2363a6a..774722b 100644 --- a/tests/test_patreon_ingester.py +++ b/tests/test_patreon_ingester.py @@ -1156,14 +1156,16 @@ def _iso(days_ago): return (datetime.now(UTC) - timedelta(days=days_ago)).isoformat() -def _seed_seen(sync_engine, source_id, media): - factory = sessionmaker(sync_engine, expire_on_commit=False) - with factory() as s: - for m in media: - s.add(PatreonSeenMedia( - source_id=source_id, filehash=_ledger_key(m), post_id=m.post_id, - )) - s.commit() +def _seed_all_seen(sync_engine, source_id, media): + """Several media through the module's existing one-key `_seed_seen`. + + A distinct NAME, not a second definition: the first version of this shadowed + `_seed_seen` from the bottom of the file, and the two #830 recapture tests + that pass it a `post_id=` kwarg broke on a TypeError. A helper defined below + the tests that use it is invisible at the point of use. + """ + for m in media: + _seed_seen(sync_engine, source_id, _ledger_key(m), post_id=m.post_id) @pytest.mark.asyncio @@ -1174,7 +1176,7 @@ async def test_a_run_of_seen_items_does_not_stop_a_tick_inside_the_window( around at the second and never looked at the third, which is exactly where an edited post lives.""" seen = [_media(f"p{i}", 1) for i in range(1, 4)] - _seed_seen(sync_engine, source_id, seen) + _seed_all_seen(sync_engine, source_id, seen) client = _FakeClient( [(None, [(m.post_id, [m]) for m in seen])], @@ -1201,7 +1203,7 @@ async def test_the_early_out_still_fires_once_the_walk_is_below_the_horizon( did. Asserted beside the test above because the window is only correct if BOTH conditions are required; either one alone is a different feature.""" seen = [_media(f"p{i}", 1) for i in range(1, 4)] - _seed_seen(sync_engine, source_id, seen) + _seed_all_seen(sync_engine, source_id, seen) client = _FakeClient( [(None, [(m.post_id, [m]) for m in seen])], @@ -1226,7 +1228,7 @@ async def test_a_window_of_zero_is_the_behaviour_that_shipped_before_it( """The off switch. Recent posts, a window of 0 → the walk stops on the count alone, so an operator who wants the old cheap tick has one.""" seen = [_media(f"p{i}", 1) for i in range(1, 4)] - _seed_seen(sync_engine, source_id, seen) + _seed_all_seen(sync_engine, source_id, seen) client = _FakeClient( [(None, [(m.post_id, [m]) for m in seen])], @@ -1252,7 +1254,7 @@ async def test_a_backfill_ignores_the_window_because_it_never_early_outs( every body — a horizon there would be a third answer to a two-answer question.""" seen = [_media(f"p{i}", 1) for i in range(1, 4)] - _seed_seen(sync_engine, source_id, seen) + _seed_all_seen(sync_engine, source_id, seen) client = _FakeClient( [(None, [(m.post_id, [m]) for m in seen])], @@ -1407,7 +1409,7 @@ async def test_a_post_whose_date_will_not_parse_falls_back_to_the_count( into the window. It reads as "not provably recent", which leaves that post on the behaviour it had before the window existed.""" seen = [_media(f"p{i}", 1) for i in range(1, 4)] - _seed_seen(sync_engine, source_id, seen) + _seed_all_seen(sync_engine, source_id, seen) client = _FakeClient( [(None, [(m.post_id, [m]) for m in seen])],