Ejemplo n.º 1
0
def test_stfu_speak_only_speaks_once():
    stfu.silenced = set(['#bots'])
    resp = stfu.stfu(stub(nickname='helga'), '#bots', 'me', 'helga speak', 'speak', [])
    assert resp in map(lambda x: x.format(nick='me'), stfu.unsilence_acks)

    resp = stfu.stfu(stub(nickname='helga'), '#bots', 'me', 'helga speak', 'speak', [])
    assert resp is None
Ejemplo n.º 2
0
def test_stfu_speak_only_speaks_once():
    stfu.silenced = set(['#bots'])
    resp = stfu.stfu(stub(nickname='helga'), '#bots', 'me', 'helga speak',
                     'speak', [])
    assert resp in map(lambda x: x.format(nick='me'), stfu.unsilence_acks)

    resp = stfu.stfu(stub(nickname='helga'), '#bots', 'me', 'helga speak',
                     'speak', [])
    assert resp is None
Ejemplo n.º 3
0
def test_stfu_handles_invalid_args(reactor):
    client = stub(nickname='helga')
    test_args = [
        ['for'],
        ['for', 'blah'],
        ['for', None],
    ]

    for args in test_args:
        stfu.stfu(client, '#bots', 'me', 'helga stfu for 30', 'stfu', args)
        assert not reactor.callLater.called
Ejemplo n.º 4
0
def test_stfu_handles_invalid_args(reactor):
    client = stub(nickname='helga')
    test_args = [
        ['for'],
        ['for', 'blah'],
        ['for', None],
    ]

    for args in test_args:
        stfu.stfu(client, '#bots', 'me', 'helga stfu for 30', 'stfu', args)
        assert not reactor.callLater.called
Ejemplo n.º 5
0
def test_stfu_preprocess_does_nothing():
    stfu.silenced = set()
    client = stub(nickname='helga')
    chan, nick, msg = stfu.stfu(client, '#bots', 'me', 'foo')
    assert msg == 'foo'
Ejemplo n.º 6
0
def test_stfu_unsilences_channel():
    stfu.silenced = set(['#bots'])
    resp = stfu.stfu(stub(nickname='helga'), '#bots', 'me', 'helga speak', 'speak', [])
    assert resp in map(lambda x: x.format(nick='me'), stfu.unsilence_acks)
    assert '#bots' not in stfu.silenced
Ejemplo n.º 7
0
def test_stfu_for_some_time(reactor):
    client = stub(nickname='helga')
    stfu.stfu(client, '#bots', 'me', 'helga stfu for 30', 'stfu', ['for', '30'])
    reactor.callLater.assertCalledWith(30*60, stfu.auto_unsilence, client, '#bots', 30*60)
Ejemplo n.º 8
0
def test_stfu_snark_on_private_message():
    stfu.silenced = set()
    resp = stfu.stfu(stub(nickname='helga'), 'me', 'me', 'helga stfu', 'stfu', [])
    assert resp in map(lambda x: x.format(nick='me'), stfu.snarks)
Ejemplo n.º 9
0
def test_stfu_preprocess_blanks_message_when_silenced():
    stfu.silenced = set(['#bots'])
    client = stub(nickname='helga')
    chan, nick, msg = stfu.stfu(client, '#bots', 'me', 'foo')
    assert msg == ''
Ejemplo n.º 10
0
def test_stfu_with_unicode():
    client = stub(nickname=u'☃')
    chan, nick, msg = stfu.stfu(client, '#bots', 'me', u'helga speak ☃')
    assert chan == '#bots'
    assert nick == 'me'
    assert msg == u'helga speak ☃'
Ejemplo n.º 11
0
def test_stfu_preprocess_does_nothing():
    stfu.silenced = set()
    client = stub(nickname='helga')
    chan, nick, msg = stfu.stfu(client, '#bots', 'me', 'foo')
    assert msg == 'foo'
Ejemplo n.º 12
0
def test_stfu_unsilences_channel():
    stfu.silenced = set(['#bots'])
    resp = stfu.stfu(stub(nickname='helga'), '#bots', 'me', 'helga speak',
                     'speak', [])
    assert resp in map(lambda x: x.format(nick='me'), stfu.unsilence_acks)
    assert '#bots' not in stfu.silenced
Ejemplo n.º 13
0
def test_stfu_for_some_time(reactor):
    client = stub(nickname='helga')
    stfu.stfu(client, '#bots', 'me', 'helga stfu for 30', 'stfu',
              ['for', '30'])
    reactor.callLater.assert_called_with(30 * 60, stfu.auto_unsilence, client,
                                         '#bots', 30 * 60)
Ejemplo n.º 14
0
def test_stfu_snark_on_private_message():
    stfu.silenced = set()
    resp = stfu.stfu(stub(nickname='helga'), 'me', 'me', 'helga stfu', 'stfu',
                     [])
    assert resp in map(lambda x: x.format(nick='me'), stfu.snarks)
Ejemplo n.º 15
0
def test_stfu_preprocess_blanks_message_when_silenced():
    stfu.silenced = set(['#bots'])
    client = stub(nickname='helga')
    chan, nick, msg = stfu.stfu(client, '#bots', 'me', 'foo')
    assert msg == ''
Ejemplo n.º 16
0
def test_stfu_with_unicode():
    client = stub(nickname=u'☃')
    chan, nick, msg = stfu.stfu(client, '#bots', 'me', u'helga speak ☃')
    assert chan == '#bots'
    assert nick == 'me'
    assert msg == u'helga speak ☃'