Esempio n. 1
0
def test_instruction_list():
    bot = SlackBot(None, 'foo', None)
    instructions = bot._instruction_list([Unhandled()])
    assert instructions.startswith(SlackBot.INSTRUCTIONS.strip())
    assert '"@foo: help"' in instructions
    assert '"@foo: version"' in instructions
    assert instructions.endswith('a dummy handler')
Esempio n. 2
0
def test_instruction_list():
    bot = SlackBot(None, 'foo', None)
    def filter_():
        """foo"""
    def dispatch():
        """bar"""
    instructions = bot._instruction_list({filter_: dispatch})
    assert instructions.endswith('foo bar')
    assert instructions.startswith(SlackBot.INSTRUCTIONS.strip())
    assert '"@foo: help"' in instructions and '"@foo: version"' in instructions
Esempio n. 3
0
async def test_handle_help_message(randint):
    bot = SlackBot('foo', None, None)
    mock_msg = mock.Mock(data=json.dumps(
        dict(channel='bar', text='<@foo>: help', type='message'), ), )
    expected = dict(
        channel='bar',
        id=randint.return_value,
        text=bot._instruction_list({}),
        type='message',
    )
    response = await bot.handle_message(mock_msg, {})
    assert json.loads(response) == expected
Esempio n. 4
0
def test_instruction_list():
    bot = SlackBot(None, 'foo', None)

    def filter_():
        """foo"""

    def dispatch():
        """bar"""

    instructions = bot._instruction_list({filter_: dispatch})
    assert instructions.endswith('foo bar')
    assert instructions.startswith(SlackBot.INSTRUCTIONS.strip())
    assert '"@foo: help"' in instructions and '"@foo: version"' in instructions
Esempio n. 5
0
async def test_handle_help_message(randint):
    bot = SlackBot('foo', None, None)
    mock_msg = mock.Mock(
        data=json.dumps(
            dict(channel='bar', text='<@foo>: help', type='message'),
        ),
    )
    expected = dict(
        channel='bar',
        id=randint.return_value,
        text=bot._instruction_list({}),
        type='message',
    )
    response = await bot.handle_message(mock_msg, {})
    assert json.loads(response) == expected
Esempio n. 6
0
async def test_handle_help_message(randint):
    bot = SlackBot('foo', None, None)
    mock_msg = mock.Mock(
        data=json.dumps(
            dict(channel='bar', text='<@foo>: help', type='message'),
        ),
    )
    expected = dict(
        channel='bar',
        id=randint.return_value,
        text=bot._instruction_list([]),
        type='message',
    )
    mock_socket = mock.MagicMock()
    bot.socket = mock_socket
    await bot.handle_message(mock_msg, [])
    assert json.loads(mock_socket.send_str.call_args[0][0]) == expected