import pytest from datetime import date, timedelta from room_cal.actions.fetch_feed import fetch_feed from room_cal.actions.fetch_reservations import fetch_reservations from room_cal.service_api import ServiceAPI from room_cal.closed import Closed @pytest.mark.asyncio async def test_fetch_feed_fire(): """Run the Fire ical-feed fetch-feed over a past window and verify marked dates are Closed.""" start = date.today() - timedelta(days=90) end = date.today() - timedelta(days=1) result = await fetch_feed(start, end, feed_name='Fire') if not result.data: pytest.skip("No Fire events in the past 90 days — nothing to verify") closed = Closed() for d in result.data: result = await closed.get(d) assert result is not None, f"Expected Closed event on {d} after Fire sync" assert result.services, f"Empty closed_services on {d}" @pytest.mark.live async def test_fetch_reservations(): api = ServiceAPI() scan_start = date.today() - timedelta(days=90) scan_end = date.today() - timedelta(days=1) all_res = await api.get_reservations(scan_start, scan_end) if not all_res: pytest.skip("No past reservations found in the last 90 days") r = all_res[0] start = r['start_date'] end = min(r['end_date'], start + timedelta(days=2)) result = await fetch_reservations(start, end, api=api) for r in result.data: assert r['reservation_id'] assert r['service'] in ('airbnb', 'booking') assert r['checkin_date'] < r['checkout_date'] assert r['guest_name']