Example #1
0
def test_on_part():
    channel1 = '#channel1'
    channel2 = '#channel2'
    user = user_info('nick', None, None)
    msg = 'msg'

    plugin = SedPlugin()
    cardinal = Mock()

    plugin.on_msg(cardinal, user, channel1, msg)
    plugin.on_msg(cardinal, user, channel2, msg)
    assert plugin.history[channel1] == {
        user.nick: msg
    }
    assert plugin.history[channel2] == {
        user.nick: msg
    }

    plugin.on_part(cardinal, user, channel1, 'message')
    assert plugin.history[channel1] == {}
    assert plugin.history[channel2] == {
        user.nick: msg
    }

    plugin.on_part(cardinal, user, channel2, 'message')
    assert plugin.history[channel2] == {}
Example #2
0
def test_subsitution_no_history():
    user = user_info('user', None, None)
    channel = '#channel'

    plugin = SedPlugin()

    # make sure this doesn't raise
    plugin.on_msg(Mock(), user, channel, 's/foo/bar/')
Example #3
0
def test_on_msg_failed_correction():
    user = user_info('user', None, None)
    channel = '#channel'

    plugin = SedPlugin()
    cardinal = Mock()

    plugin.history[channel][user.nick] = 'doesnt matter'

    # make sure this doesn't raise
    plugin.on_msg(cardinal, user, channel, 's/foo/bar/')
    cardinal.sendMsg.assert_not_called()
Example #4
0
def test_on_msg_failed_correction():
    user = user_info('user', None, None)
    channel = '#channel'

    plugin = SedPlugin()
    cardinal = Mock()

    plugin.history[channel][user.nick] = 'yo, foo matters'

    # make sure this doesn't raise
    plugin.on_msg(cardinal, user, channel, 's/foo/bar/')
    cardinal.sendMsg.assert_called_with(
        channel,
        "{} meant: yo bar matters".format(nick),
    )