def test_gets_order(conference, requests_mock): requests_mock.get(f"https://pretix/api/organizers/events/orders/ABC/", json={"code": "ABC"}) order = get_order(conference, "ABC") assert order["code"] == "ABC"
def test_return_none_when_404(conference, requests_mock): requests_mock.get( "https://pretix/api/organizers/base-pretix-organizer-id/events/base-pretix-event-id/orders/ABC/", status_code=404, ) assert get_order(conference, "ABC") is None
def get_order(conference: Conference, code: str) -> Optional[PretixOrder]: data = pretix.get_order(conference, code) if data: return PretixOrder.from_data(data)