コード例 #1
0
ファイル: test_bot.py プロジェクト: Chovin/aslack
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')
コード例 #2
0
ファイル: test_slack_bot.py プロジェクト: davr/aslack
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
コード例 #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
コード例 #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
コード例 #5
0
ファイル: test_slack_bot.py プロジェクト: davr/aslack
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
コード例 #6
0
ファイル: test_bot.py プロジェクト: Chovin/aslack
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