mirror of
https://github.com/Sea-Haven-Industries/afterhours-shift-manager.git
synced 2026-09-30 07:53:11 +00:00
56 lines
1.8 KiB
Python
56 lines
1.8 KiB
Python
|
|
"""Tests for slack-bot _handle_pick."""
|
||
|
|
|
||
|
|
from freezegun import freeze_time
|
||
|
|
|
||
|
|
MON = "2026-06-01 12:00:00"
|
||
|
|
|
||
|
|
|
||
|
|
@freeze_time(MON)
|
||
|
|
def test_pick_open_shift_today(
|
||
|
|
slackbot_app, schedule, seed, respond, client, routing_spy, text_of
|
||
|
|
):
|
||
|
|
seed.roster("114", "Alice", slack_user_id="U_ALICE")
|
||
|
|
# Monday night is unassigned (available) → pickable.
|
||
|
|
slackbot_app._handle_pick(
|
||
|
|
respond, schedule, "U_ALICE", "pick today", "C1", client, None
|
||
|
|
)
|
||
|
|
assert schedule.get_override("2026-06-01")["extension"] == "114"
|
||
|
|
assert "picked up" in text_of(respond).lower()
|
||
|
|
routing_spy.assert_called_once_with("114")
|
||
|
|
|
||
|
|
|
||
|
|
@freeze_time(MON)
|
||
|
|
def test_pick_already_covered(
|
||
|
|
slackbot_app, schedule, seed, respond, client, routing_spy, text_of
|
||
|
|
):
|
||
|
|
seed.roster("114", "Alice", slack_user_id="U_ALICE")
|
||
|
|
seed.weekly("Monday", "115", "Bob") # already covered
|
||
|
|
slackbot_app._handle_pick(
|
||
|
|
respond, schedule, "U_ALICE", "pick today", "C1", client, None
|
||
|
|
)
|
||
|
|
assert "already covered" in text_of(respond).lower()
|
||
|
|
routing_spy.assert_not_called()
|
||
|
|
|
||
|
|
|
||
|
|
@freeze_time(MON)
|
||
|
|
def test_pick_past_date(slackbot_app, schedule, seed, respond, client, text_of):
|
||
|
|
seed.roster("114", "Alice", slack_user_id="U_ALICE")
|
||
|
|
slackbot_app._handle_pick(
|
||
|
|
respond, schedule, "U_ALICE", "pick 2026-05-01", "C1", client, None
|
||
|
|
)
|
||
|
|
assert "past" in text_of(respond).lower()
|
||
|
|
|
||
|
|
|
||
|
|
@freeze_time(MON)
|
||
|
|
def test_pick_unregistered(slackbot_app, schedule, respond, client, text_of):
|
||
|
|
slackbot_app._handle_pick(
|
||
|
|
respond, schedule, "U_NOBODY", "pick today", "C1", client, None
|
||
|
|
)
|
||
|
|
assert "not registered" in text_of(respond).lower()
|
||
|
|
|
||
|
|
|
||
|
|
@freeze_time(MON)
|
||
|
|
def test_pick_usage(slackbot_app, schedule, respond, client, text_of):
|
||
|
|
slackbot_app._handle_pick(respond, schedule, "U_ALICE", "pick", "C1", client, None)
|
||
|
|
assert "Usage" in text_of(respond)
|