Exemplo n.º 1
0
def test_slack_inst_should_handle_messages_w_exception(mock_webclient, slack):
    messages = {'dummyuser': [{'user': '******', 'text': 'help toomany'}]}
    slack.handle_messages(messages)
    text = 'TypeError: help_message() takes 1 positional argument ' \
           'but 2 were given\n'
    expected_output = {'channel': 'CH234', 'text': AnyStringWith(text)}
    mock_webclient.chat_postMessage.assert_called_with(**expected_output)
Exemplo n.º 2
0
def test_slack_instance_should_handle_messages(mock_webclient, slack):
    messages = {'dummyuser': [{'user': '******', 'text': 'help'}]}
    slack.handle_messages(messages)
    expected_text = 'Results: \nAvailable commands: `plot`, ' \
                    '`msmt`, `measurement`, `notify`, `help`, `task`'
    expected_output = {'channel': 'CH234', 'text': expected_text}

    mock_webclient.chat_postMessage.assert_called_with(**expected_output)
Exemplo n.º 3
0
def test_slack_inst_should_handle_messages_w_unkn_cmd(mock_webclient, slack):
    messages = {'dummyuser': [{'user': '******', 'text': 'comm'}]}
    slack.handle_messages(messages)
    text = 'Command comm not understood. Try `help`'
    expected_output = {'channel': 'CH234', 'text': text}
    mock_webclient.chat_postMessage.assert_called_with(**expected_output)
Exemplo n.º 4
0
def test_slack_inst_should_handle_messages_w_parameter(mock_webclient, slack):
    slack.commands.update({'comm': Parameter(name='param')})
    messages = {'dummyuser': [{'user': '******', 'text': 'comm'}]}
    slack.handle_messages(messages)
    expected_output = {'channel': 'CH234', 'text': 'Executing comm'}
    mock_webclient.chat_postMessage.assert_called_with(**expected_output)
Exemplo n.º 5
0
def test_slack_inst_should_handle_messages_w_args_kw(mock_webclient, slack):
    text = 'task finished key=1'
    messages = {'dummyuser': [{'user': '******', 'text': text}]}
    slack.handle_messages(messages)
    expected_output = {'channel': 'CH234', 'text': 'Added task "finished"'}
    mock_webclient.chat_postMessage.assert_called_with(**expected_output)