async def test_should_create_new_poll_when_no_poll_from_today_exists() -> None: # Arrange pollmanager_mock = get_pollmanger(get_poll(1)) command = mensa.Etm(pollmanager=pollmanager_mock, master=MagicMock()) # Act await command.handle('etm', '', MagicMock()) # Assert pollmanager_mock.create.assert_called_once()
async def test_should_create_new_poll_with_12_30_for_etlm() -> None: # Arrange pollmanager_mock = get_pollmanger(get_poll(1)) command = mensa.Etm(pollmanager=pollmanager_mock, master=MagicMock()) # Act await command.handle('etlm', '', MagicMock()) # Assert actual = pollmanager_mock.create.call_args[0][-1] assert actual == ['12:30']
async def test_should_create_new_poll_when_no_prev_poll_exists() -> None: # Arrange pollmanager_mock = MagicMock() pollmanager_mock.create = CoroutineMock() command = mensa.Etm(pollmanager=pollmanager_mock, master=MagicMock()) # Act await command.handle('etm', '', MagicMock()) # Assert pollmanager_mock.create.assert_called_once()
async def test_should_split_poll_options_for_new_poll() -> None: # Arrange pollmanager_mock = get_pollmanger(get_poll(1)) command = mensa.Etm(pollmanager=pollmanager_mock, master=MagicMock()) # Act await command.handle('etm', '"12:00" "13:00"', MagicMock()) # Assert actual = pollmanager_mock.create.call_args[0][-1] assert actual == ['12:00', '13:00']
async def test_should_add_default_time_for_etlm() -> None: # Arrange poll_mock = get_poll(0) pollmanager_mock = get_pollmanger(poll_mock) command = mensa.Etm(pollmanager=pollmanager_mock, master=MagicMock()) # Act await command.handle('etlm', '', MagicMock()) # Assert actual = poll_mock.add_option.call_args expected = call('12:30') assert expected == actual
async def test_should_split_poll_options_for_existing_poll() -> None: # Arrange poll_mock = get_poll(0) pollmanager_mock = get_pollmanger(poll_mock) command = mensa.Etm(pollmanager=pollmanager_mock, master=MagicMock()) # Act await command.handle('etm', '"12:00" "13:00"', MagicMock()) # Assert actual = poll_mock.add_option.call_args_list expected = [call('12:00'), call('13:00')] assert expected == actual
async def test_should_normalize_poll_options_for_existing_poll() -> None: # Arrange poll_mock = get_poll(0) pollmanager_mock = get_pollmanger(poll_mock) command = mensa.Etm(pollmanager=pollmanager_mock, master=MagicMock()) # Act await command.handle('etm', '1200', MagicMock()) # Assert actual = poll_mock.add_option.call_args expected = call('12:00') assert expected == actual
async def test_should_add_new_option_to_existing_poll() -> None: # Arrange poll_mock = get_poll(0) pollmanager_mock = get_pollmanger(poll_mock) command = mensa.Etm(pollmanager=pollmanager_mock, master=MagicMock()) # Act await command.handle('etm', '11:30', MagicMock()) # Assert poll_mock.add_option.assert_called_once() actual = poll_mock.add_option.call_args expected = call('11:30') assert expected == actual