Exemple #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'
Exemple #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'
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'
Exemple #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
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'
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
Exemple #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
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'
def test_bot_atname_works(dispatcher):
    msg = {
        'text': FAKE_BOT_ATNAME + ' hello',
        'channel': 'C99999'
    }

    msg = dispatcher.filter_text(msg)
    assert msg['text'] == 'hello'
def test_direct_message_with_name(dispatcher):
    msg = {
        'text': FAKE_BOT_ATNAME + ' hello',
        'channel': 'D99999'
    }

    msg = dispatcher.filter_text(msg)
    assert msg['text'] == 'hello'
def test_direct_message(dispatcher):
    msg = {
        'text': 'hello',
        'channel': 'D99999'
    }

    msg = dispatcher.filter_text(msg)
    assert msg['text'] == 'hello'
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
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
Exemple #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'
Exemple #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'
Exemple #16
0
def test_direct_message(dispatcher):
    msg = {'text': 'hello', 'channel': 'D99999'}

    msg = dispatcher.filter_text(msg)
    assert msg['text'] == 'hello'
Exemple #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'