feat: operator settings, guest booking list, card checkout #22
2 changed files with 26 additions and 22 deletions
style: ruff nits in the my-bookings slice
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
commit
8557ce617e
|
|
@ -155,7 +155,8 @@ async def public_room_views(rooms: list[Room]) -> list[dict]:
|
|||
async def list_guest_bookings(guest_pubkey: str) -> list[dict]:
|
||||
"""The caller's own bookings (identity established by the door: LNbits
|
||||
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
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ guest's rows, and the Lightning/Nostr plumbing stays internal."""
|
|||
|
||||
import asyncio
|
||||
from types import SimpleNamespace
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
from fastapi import HTTPException
|
||||
|
|
@ -14,27 +15,27 @@ from ..models import Booking, BookingStatus, guest_booking_dict
|
|||
PK = "ab" * 32
|
||||
|
||||
|
||||
def _booking(i: int, **over) -> Booking:
|
||||
base = dict(
|
||||
id=f"bk{i}",
|
||||
room_id="a",
|
||||
guest_pubkey=PK,
|
||||
guest_contact="me@example.com",
|
||||
check_in=f"2026-10-{10 + i:02d}",
|
||||
check_out=f"2026-10-{12 + i:02d}",
|
||||
nights=2,
|
||||
num_guests=1,
|
||||
currency="EUR",
|
||||
price_fiat=200.0,
|
||||
amount_sat=300000,
|
||||
deposit_sat=300000,
|
||||
status=BookingStatus.confirmed,
|
||||
payment_hash=f"ph{i}",
|
||||
request_event_id="req",
|
||||
reservation_event_id="res",
|
||||
)
|
||||
def _booking(i: int, **over: Any) -> Booking:
|
||||
base: dict[str, Any] = {
|
||||
"id": f"bk{i}",
|
||||
"room_id": "a",
|
||||
"guest_pubkey": PK,
|
||||
"guest_contact": "me@example.com",
|
||||
"check_in": f"2026-10-{10 + i:02d}",
|
||||
"check_out": f"2026-10-{12 + i:02d}",
|
||||
"nights": 2,
|
||||
"num_guests": 1,
|
||||
"currency": "EUR",
|
||||
"price_fiat": 200.0,
|
||||
"amount_sat": 300000,
|
||||
"deposit_sat": 300000,
|
||||
"status": BookingStatus.confirmed,
|
||||
"payment_hash": f"ph{i}",
|
||||
"request_event_id": "req",
|
||||
"reservation_event_id": "res",
|
||||
}
|
||||
base.update(over)
|
||||
return Booking(**base) # type: ignore[arg-type]
|
||||
return Booking(**base)
|
||||
|
||||
|
||||
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):
|
||||
_patch_store(monkeypatch, [])
|
||||
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
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue