Просмотр исходного кода

Fix chat 400: add probe() to Airbnb and Booking clients

Python 3.14 runtime_checkable isinstance checks all inherited protocol
attrs; _AirbnbClient and _BookingClient were missing probe() from
ServiceClient, so chat_client() always raised TypeError → HTTP 400.
ZiB 4 месяцев назад
Родитель
Сommit
d31bc6c0c1
2 измененных файлов с 10 добавлено и 0 удалено
  1. 5 0
      room_cal/service_api/_airbnb.py
  2. 5 0
      room_cal/service_api/_booking.py

+ 5 - 0
room_cal/service_api/_airbnb.py

@@ -509,6 +509,11 @@ class _AirbnbClient:
     )
     )
     return AirbnbData(suggested_prices=suggested_prices, calendar_events=calendar_events)
     return AirbnbData(suggested_prices=suggested_prices, calendar_events=calendar_events)
 
 
+  async def probe(self) -> None:
+    from datetime import date
+    today = date.today().isoformat()
+    await self.get_calendar(today, today)
+
   async def get_calendar_events(self) -> list[CalendarEvent]:
   async def get_calendar_events(self) -> list[CalendarEvent]:
     """Local events and holidays Airbnb shows on the host calendar (holidays, major events, etc.)."""
     """Local events and holidays Airbnb shows on the host calendar (holidays, major events, etc.)."""
     if is_stale('airbnb'):
     if is_stale('airbnb'):

+ 5 - 0
room_cal/service_api/_booking.py

@@ -537,6 +537,11 @@ class _BookingClient:
       self._cache.update(month_result)
       self._cache.update(month_result)
     return {d: info for d, info in self._cache.items() if date_from <= d <= date_to}
     return {d: info for d, info in self._cache.items() if date_from <= d <= date_to}
 
 
+  async def probe(self) -> None:
+    from datetime import date
+    today = date.today().isoformat()
+    await self.get_calendar(today, today)
+
   async def get_reservations(self, date_from: str, date_to: str) -> list[Reservation]:
   async def get_reservations(self, date_from: str, date_to: str) -> list[Reservation]:
     if is_stale('booking'):
     if is_stale('booking'):
       raise BookingAuthError(f'Booking.com credentials are stale — run: {_AUTH_HINT}')
       raise BookingAuthError(f'Booking.com credentials are stale — run: {_AUTH_HINT}')