Пример #1
0
def test_in_list_command_not_ok(message):
    func = mock.MagicMock()
    c = Command(command_type=CommandType.IN_LIST,
                value=["a", "b", "c"],
                action=func)
    parser = Parser()
    parser.add_command(c)

    parser.process_message(message)

    assert not func.called
Пример #2
0
def test_call_first_command():
    func = mock.MagicMock()
    c1 = Command(command_type=CommandType.EQUAL, value="a", action=func.foo)
    c2 = Command(command_type=CommandType.START_WITH,
                 value="a",
                 action=func.bar)
    parser = Parser()
    parser.add_command(c1)
    parser.add_command(c2)

    parser.process_message("a")

    assert func.foo.called
    assert not func.bar.called