import pytest

from slack_today_i_did.generic_bot import GenericSlackBot

MOCK_PERSON = 'dave'
MOCK_CHANNEL = '#general'


@pytest.fixture
def bot():
    return GenericSlackBot('')


def test_help_without_arg(mocker, bot, message_context):
    mocked_channel_message = mocker.patch.object(bot, 'send_channel_message')

    with message_context(bot, sender=MOCK_PERSON):
        bot.parse_direct_message({
            'user': MOCK_PERSON,
            'channel': MOCK_CHANNEL,
            'text': 'help'
        })

    assert MOCK_CHANNEL == mocked_channel_message.call_args[0][0]
    assert "Main functions:" in mocked_channel_message.call_args[0][1]
    assert mocked_channel_message.call_count == 1


def test_help_on_func(mocker, bot, message_context):
    mocked_channel_message = mocker.patch.object(bot, 'send_channel_message')

    with message_context(bot, sender=MOCK_PERSON):
        bot.parse_direct_message({
            'user': MOCK_PERSON,
            'channel': MOCK_CHANNEL,
            'text': 'help help'
        })

    assert MOCK_CHANNEL == mocked_channel_message.call_args[0][0]
    assert "I'll tell you about it" in mocked_channel_message.call_args[0][1]
    assert mocked_channel_message.call_count == 1

@@ -1202,28 +1202,1164 @@
 nel_message.call_count == 1%0A
+%0A%0Adef test_help_on_mispelled_func(mocker, bot, message_context):%0A    mocked_channel_message = mocker.patch.object(bot, 'send_channel_message')%0A%0A    with message_context(bot, sender=MOCK_PERSON):%0A        bot.parse_direct_message(%7B%0A            'user': MOCK_PERSON,%0A            'channel': MOCK_CHANNEL,%0A            'text': 'help helc'%0A        %7D)%0A%0A    assert MOCK_CHANNEL == mocked_channel_message.call_args%5B0%5D%5B0%5D%0A    assert %22I did find the following functions%22 in mocked_channel_message.call_args%5B0%5D%5B1%5D%0A    assert mocked_channel_message.call_count == 1%0A%0A%0Adef test_help_on_mispelled_something(mocker, bot, message_context):%0A    mocked_channel_message = mocker.patch.object(bot, 'send_channel_message')%0A%0A    with message_context(bot, sender=MOCK_PERSON):%0A        bot.parse_direct_message(%7B%0A            'user': MOCK_PERSON,%0A            'channel': MOCK_CHANNEL,%0A            'text': 'help hdebf8u3ijr9jndsiix'%0A        %7D)%0A%0A    assert MOCK_CHANNEL == mocked_channel_message.call_args%5B0%5D%5B0%5D%0A    assert %22I don't know what you mean and have no suggestions%22 in mocked_channel_message.call_args%5B0%5D%5B1%5D%0A    assert mocked_channel_message.call_count == 1%0A

add more tests for help suggestions (#22)