"""Portfolio smoke check: run inside the thesis collector image against a NEW review database.

Mount thesis xml-files at /fixtures. No network feed is contacted. The two fetches
exercise the actual archive/register/parse/persist path and duplicate handling.
"""
from datetime import datetime, timezone
from pathlib import Path

from collector import collector
from collector.fetcher import FetchedPayload
from config.feeds import MEASUREMENT_FEEDS
from database.db import initialize_database

initialize_database()
feed = next(feed for feed in MEASUREMENT_FEEDS if feed.road == "A1")
payload = Path("/fixtures/trafficstatus_a1.xml").read_bytes()
collector.fetch_feed = lambda _: FetchedPayload(feed, payload, datetime.now(timezone.utc))
first = collector.collect_feed(feed)
second = collector.collect_feed(feed)
assert first.error is None and not first.duplicate, "Use a fresh review database for the initial fixture import"
assert second.error is None and second.duplicate
assert first.snapshot_id == second.snapshot_id
print("PASS: fixture archived and parsed; second fetch reused the same snapshot without parsing.")
print("This is the historical A1 XML example, not live traffic or the evaluation dataset.")
