mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
from typing import Optional
|
|
|
|
import pytest
|
|
|
|
from domain.abri.slots import slot_for_confirmed_time
|
|
|
|
|
|
@pytest.mark.parametrize("confirmed_time", [None, "", " "])
|
|
def test_a_booking_with_no_confirmed_time_is_an_all_day_appointment(
|
|
confirmed_time: Optional[str],
|
|
) -> None:
|
|
# Act
|
|
slot = slot_for_confirmed_time(confirmed_time)
|
|
|
|
# Assert
|
|
assert slot == "AD"
|
|
|
|
|
|
@pytest.mark.parametrize("confirmed_time", ["08:00", "09:30", "11:59"])
|
|
def test_a_confirmed_time_before_midday_books_the_morning_slot(
|
|
confirmed_time: str,
|
|
) -> None:
|
|
# Act
|
|
slot = slot_for_confirmed_time(confirmed_time)
|
|
|
|
# Assert
|
|
assert slot == "AM"
|
|
|
|
|
|
@pytest.mark.parametrize("confirmed_time", ["12:00", "13:15", "16:59"])
|
|
def test_a_confirmed_time_at_or_after_midday_books_the_afternoon_slot(
|
|
confirmed_time: str,
|
|
) -> None:
|
|
# Act
|
|
slot = slot_for_confirmed_time(confirmed_time)
|
|
|
|
# Assert
|
|
assert slot == "PM"
|
|
|
|
|
|
@pytest.mark.parametrize("confirmed_time", ["half nine", "25:00", "9.30am"])
|
|
def test_an_unparseable_confirmed_time_fails_loudly_rather_than_booking_all_day(
|
|
confirmed_time: str,
|
|
) -> None:
|
|
# Act / Assert
|
|
with pytest.raises(ValueError):
|
|
slot_for_confirmed_time(confirmed_time)
|