from datetime import date, timedelta import pytest from room_cal.service_api import ServiceAPI async def test_price_roundtrip(): api = ServiceAPI() # Find an available (not booked) date with prices set on all services. scan_start = date.today() + timedelta(days=1) scan_end = scan_start + timedelta(days=90) target = None d = scan_start while d <= scan_end: if await api.get_available(d): prices = await api.get_prices(d) if all(p is not None for p in prices.values()): target = d originals = dict(prices) break d += timedelta(days=1) if target is None: pytest.skip("No available priced date found in the next 90 days") await api.set_prices(target, {k: v - 1 for k, v in originals.items()}) updated = await api.get_prices(target) for key, original in originals.items(): assert updated[key] == pytest.approx(original - 1.00) await api.set_prices(target, originals) restored = await api.get_prices(target) for key, original in originals.items(): assert restored[key] == pytest.approx(original)