예제 #1
0
def test_buffer_connection_returns_threadconnection_with_moler_conn():
    from moler.io.raw.memory import ThreadedFifoBuffer
    from moler.observable_connection import ObservableConnection
    from moler.util.cmds_events_doc import _buffer_connection

    buff_conn = _buffer_connection()
    assert isinstance(buff_conn, ThreadedFifoBuffer) is True
    assert isinstance(buff_conn.moler_connection, ObservableConnection) is True
예제 #2
0
def test_create_command_raise_exception_when_object_takes_no_params(fake_cmd):
    from moler.util.cmds_events_doc import _create_command, _buffer_connection

    with raises(Exception) as exc:
        _create_command(fake_cmd, _buffer_connection().moler_connection, {})

    assert "via FakeCommand() : object() takes no parameters" or "via FakeCommand() : this constructor takes no arguments" in str(
        exc.value)
예제 #3
0
def test_create_command_success(nice_cmd):
    from moler.util.cmds_events_doc import _create_command, _buffer_connection

    result = _create_command(nice_cmd,
                             _buffer_connection().moler_connection,
                             {'nice': 'nice'})
    assert isinstance(result[0], nice_cmd)
    assert result[1] == 'NiceCommand(nice=nice)'
예제 #4
0
def test_run_command_parsing_test_success(nice_cmd):
    # ToDo: not finished
    from moler.util.cmds_events_doc import _run_command_parsing_test, _buffer_connection, _get_doc_variant, _create_command
    buffer_io = _buffer_connection()
    variant = '_ver_nice'
    test_data = {
        variant: {'COMMAND_OUTPUT': 'nice', 'COMMAND_KWARGS': {'nice': 'nice'}, 'COMMAND_RESULT': {'nice': 'nice'}}}

    cmd_output, cmd_kwargs, cmd_result = _get_doc_variant(test_data, variant, "COMMAND")
    moler_cmd, creation_str = _create_command(nice_cmd, buffer_io.moler_connection, cmd_kwargs)
    _run_command_parsing_test(nice_cmd, creation_str, buffer_io, cmd_output, cmd_result, variant, Command, "COMMAND")