Пример #1
0
def test_bot_name_works(dispatcher):
    msg = {'channel': 'C99999'}

    msg['text'] = FAKE_BOT_NAME + ': hello'
    msg = dispatcher.filter_text(msg)
    assert msg['text'] == 'hello'
    msg['text'] = FAKE_BOT_NAME + ':hello'
    msg = dispatcher.filter_text(msg)
    assert msg['text'] == 'hello'
Пример #2
0
def test_aliases(setup_aliases, dispatcher):
    msg = {'channel': 'C99999'}

    for a in TEST_ALIASES:
        msg['text'] = a + ' hello'
        msg = dispatcher.filter_text(msg)
        assert msg['text'] == 'hello'
        msg['text'] = a + 'hello'
        msg = dispatcher.filter_text(msg)
        assert msg['text'] == 'hello'
Пример #3
0
def test_bot_name_works(dispatcher):
    msg = {
        'channel': 'C99999'
    }

    msg['text'] = FAKE_BOT_NAME + ': hello'
    msg = dispatcher.filter_text(msg)
    assert msg['text'] == 'hello'
    msg['text'] = FAKE_BOT_NAME + ':hello'
    msg = dispatcher.filter_text(msg)
    assert msg['text'] == 'hello'
Пример #4
0
def test_no_aliases_doesnt_work(dispatcher):
    msg = {'channel': 'G99999'}
    for a in TEST_ALIASES:
        text = a + ' hello'
        msg['text'] = text
        assert dispatcher.filter_text(msg) is None
        assert msg['text'] == text
        text = a + 'hello'
        msg['text'] = text
        assert dispatcher.filter_text(msg) is None
        assert msg['text'] == text
Пример #5
0
def test_aliases(setup_aliases, dispatcher):
    msg = {
        'channel': 'C99999'
    }

    for a in TEST_ALIASES:
        msg['text'] = a + ' hello'
        msg = dispatcher.filter_text(msg)
        assert msg['text'] == 'hello'
        msg['text'] = a + 'hello'
        msg = dispatcher.filter_text(msg)
        assert msg['text'] == 'hello'
Пример #6
0
def test_no_aliases_doesnt_work(dispatcher):
    msg = {
        'channel': 'G99999'
    }
    for a in TEST_ALIASES:
        text = a + ' hello'
        msg['text'] = text
        assert dispatcher.filter_text(msg) is None
        assert msg['text'] == text
        text = a + 'hello'
        msg['text'] = text
        assert dispatcher.filter_text(msg) is None
        assert msg['text'] == text
Пример #7
0
def test_nondirectmsg_works(dispatcher):

    # the ID of someone that is not the bot
    other_id = '<@U1111>'
    msg = {'text': other_id + ' hello', 'channel': 'C99999'}

    assert dispatcher.filter_text(msg) is None
Пример #8
0
def test_botname_works_with_aliases_present(setup_aliases, dispatcher):
    msg = {
        'text': FAKE_BOT_ATNAME + ' hello',
        'channel': 'G99999'
    }

    msg = dispatcher.filter_text(msg)
    assert msg['text'] == 'hello'
Пример #9
0
def test_bot_atname_works(dispatcher):
    msg = {
        'text': FAKE_BOT_ATNAME + ' hello',
        'channel': 'C99999'
    }

    msg = dispatcher.filter_text(msg)
    assert msg['text'] == 'hello'
Пример #10
0
def test_direct_message_with_name(dispatcher):
    msg = {
        'text': FAKE_BOT_ATNAME + ' hello',
        'channel': 'D99999'
    }

    msg = dispatcher.filter_text(msg)
    assert msg['text'] == 'hello'
Пример #11
0
def test_direct_message(dispatcher):
    msg = {
        'text': 'hello',
        'channel': 'D99999'
    }

    msg = dispatcher.filter_text(msg)
    assert msg['text'] == 'hello'
Пример #12
0
def test_nondirectmsg_works(dispatcher):

    # the ID of someone that is not the bot
    other_id = '<@U1111>'
    msg = {
        'text': other_id + ' hello',
        'channel': 'C99999'
    }

    assert dispatcher.filter_text(msg) is None
Пример #13
0
def test_none_text(dispatcher):
    # Test for #138: If new msg text is None, fallback to empty str
    msg = {'text': None, 'channel': 'C99999'}
    # Should not raise a TypeError
    msg = dispatcher.filter_text(msg)
    assert msg is None
Пример #14
0
def test_bot_atname_works(dispatcher):
    msg = {'text': FAKE_BOT_ATNAME + ' hello', 'channel': 'C99999'}

    msg = dispatcher.filter_text(msg)
    assert msg['text'] == 'hello'
Пример #15
0
def test_direct_message_with_name(dispatcher):
    msg = {'text': FAKE_BOT_ATNAME + ' hello', 'channel': 'D99999'}

    msg = dispatcher.filter_text(msg)
    assert msg['text'] == 'hello'
Пример #16
0
def test_direct_message(dispatcher):
    msg = {'text': 'hello', 'channel': 'D99999'}

    msg = dispatcher.filter_text(msg)
    assert msg['text'] == 'hello'
Пример #17
0
def test_botname_works_with_aliases_present(setup_aliases, dispatcher):
    msg = {'text': FAKE_BOT_ATNAME + ' hello', 'channel': 'G99999'}

    msg = dispatcher.filter_text(msg)
    assert msg['text'] == 'hello'