style: ruff nits in the my-bookings slice

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Padreug 2026-09-16 12:18:15 +02:00
commit 8557ce617e
2 changed files with 26 additions and 22 deletions

View file

@ -155,7 +155,8 @@ async def public_room_views(rooms: list[Room]) -> list[dict]:
async def list_guest_bookings(guest_pubkey: str) -> list[dict]: async def list_guest_bookings(guest_pubkey: str) -> list[dict]:
"""The caller's own bookings (identity established by the door: LNbits """The caller's own bookings (identity established by the door: LNbits
account pubkey over HTTP, signed sender_pubkey over RPC).""" account pubkey over HTTP, signed sender_pubkey over RPC)."""
return [guest_booking_dict(b) for b in await crud.get_bookings_for_guest(guest_pubkey)] rows = await crud.get_bookings_for_guest(guest_pubkey)
return [guest_booking_dict(b) for b in rows]
# A guest calendar asks for a year by default; cap the window so a bad client # A guest calendar asks for a year by default; cap the window so a bad client

View file

@ -4,6 +4,7 @@ guest's rows, and the Lightning/Nostr plumbing stays internal."""
import asyncio import asyncio
from types import SimpleNamespace from types import SimpleNamespace
from typing import Any
import pytest import pytest
from fastapi import HTTPException from fastapi import HTTPException
@ -14,27 +15,27 @@ from ..models import Booking, BookingStatus, guest_booking_dict
PK = "ab" * 32 PK = "ab" * 32
def _booking(i: int, **over) -> Booking: def _booking(i: int, **over: Any) -> Booking:
base = dict( base: dict[str, Any] = {
id=f"bk{i}", "id": f"bk{i}",
room_id="a", "room_id": "a",
guest_pubkey=PK, "guest_pubkey": PK,
guest_contact="me@example.com", "guest_contact": "me@example.com",
check_in=f"2026-10-{10 + i:02d}", "check_in": f"2026-10-{10 + i:02d}",
check_out=f"2026-10-{12 + i:02d}", "check_out": f"2026-10-{12 + i:02d}",
nights=2, "nights": 2,
num_guests=1, "num_guests": 1,
currency="EUR", "currency": "EUR",
price_fiat=200.0, "price_fiat": 200.0,
amount_sat=300000, "amount_sat": 300000,
deposit_sat=300000, "deposit_sat": 300000,
status=BookingStatus.confirmed, "status": BookingStatus.confirmed,
payment_hash=f"ph{i}", "payment_hash": f"ph{i}",
request_event_id="req", "request_event_id": "req",
reservation_event_id="res", "reservation_event_id": "res",
) }
base.update(over) base.update(over)
return Booking(**base) # type: ignore[arg-type] return Booking(**base)
def _patch_store(monkeypatch, rows): def _patch_store(monkeypatch, rows):
@ -69,7 +70,9 @@ def test_http_lists_only_the_callers_rows(monkeypatch):
def test_http_rejects_account_without_pubkey(monkeypatch): def test_http_rejects_account_without_pubkey(monkeypatch):
_patch_store(monkeypatch, []) _patch_store(monkeypatch, [])
with pytest.raises(HTTPException) as e: with pytest.raises(HTTPException) as e:
asyncio.run(views_api.api_my_bookings(user=SimpleNamespace(id="u1", pubkey=None))) asyncio.run(
views_api.api_my_bookings(user=SimpleNamespace(id="u1", pubkey=None))
)
assert e.value.status_code == 409 assert e.value.status_code == 409