Exemplo n.º 1
0
def test_parse_command(monkeypatch):
    monkeypatch.setattr("chitanda.util.config", TEST_PARSE_CONFIG)
    cmd = Mock(__name__="cmd", call=Mock(return_value=123))
    bot = Mock(commands={"cmd": cmd})

    message = Message(bot, "TestListener", 2, 3, ".cmd", 5)
    assert 123 == message.call_command()
    assert cmd.call.call_args[0][0].contents == ""
Exemplo n.º 2
0
def test_parse_command_no_trigger_match(monkeypatch):
    monkeypatch.setattr('chitanda.util.config', TEST_PARSE_CONFIG)
    bot = Mock(commands={'henlo ': 1})
    message = Message(bot, 'TestListener', 2, 3, 'henlo', 5)
    with pytest.raises(NoCommandFound):
        message.call_command()