Ejemplo n.º 1
0
def test_unix_remote_device(device_connection, unix_remote_output):
    unix_remote = get_device(name="UNIX_REMOTE",
                             connection=device_connection,
                             device_output=unix_remote_output,
                             test_file_path=__file__)

    iterate_over_device_states(device=unix_remote)
Ejemplo n.º 2
0
def test_at_remote_device(device_connection, at_remote_output):
    at_remote = get_device(name="AT_REMOTE",
                           connection=device_connection,
                           device_output=at_remote_output,
                           test_file_path=__file__)

    iterate_over_device_states(device=at_remote)
Ejemplo n.º 3
0
def test_unix_remote_proxy_pc_device_multiple_prompts(
        device_connection, unix_remote_proxy_pc_output):
    unix_remote_proxy_pc_changed_output = copy_dict(
        unix_remote_proxy_pc_output, deep_copy=True)
    combined_line = "moler_bash#"
    for src_state in unix_remote_proxy_pc_output.keys():
        for cmd_string in unix_remote_proxy_pc_output[src_state].keys():
            combined_line = "{} {}".format(
                combined_line,
                unix_remote_proxy_pc_output[src_state][cmd_string])
    for src_state in unix_remote_proxy_pc_changed_output.keys():
        for cmd_string in unix_remote_proxy_pc_changed_output[src_state].keys(
        ):
            unix_remote_proxy_pc_changed_output[src_state][
                cmd_string] = combined_line

    unix_remote_proxy_pc = get_device(
        name="UNIX_REMOTE_PROXY_PC",
        connection=device_connection,
        device_output=unix_remote_proxy_pc_changed_output,
        test_file_path=__file__)
    assert unix_remote_proxy_pc._check_all_prompts_on_line is True
    assert unix_remote_proxy_pc._prompts_event.check_against_all_prompts is True

    with pytest.raises(MolerException) as exception:
        iterate_over_device_states(device=unix_remote_proxy_pc,
                                   max_no_of_threads=0)
    assert "More than 1 prompt match the same line" in str(exception.value)
Ejemplo n.º 4
0
def test_unix_remote_proxy_pc_device_goto_state_bg(
        device_connection, unix_remote_proxy_pc_output):
    unix_remote_proxy_pc = get_device(
        name="UNIX_REMOTE_PROXY_PC",
        connection=device_connection,
        device_output=unix_remote_proxy_pc_output,
        test_file_path=__file__)
    unix_remote_proxy_pc._goto_state_in_production_mode = True
    dst_state = "UNIX_REMOTE_ROOT"
    src_state = "UNIX_LOCAL"
    unix_remote_proxy_pc.goto_state(state=src_state)
    assert unix_remote_proxy_pc.current_state == src_state
    start_time = time.time()
    unix_remote_proxy_pc.goto_state_bg(state=dst_state)
    assert unix_remote_proxy_pc.current_state != dst_state
    while dst_state != unix_remote_proxy_pc.current_state and (
            time.time() - start_time) < 10:
        MolerTest.sleep(0.01)
    execution_time_bg = time.time() - start_time
    assert unix_remote_proxy_pc.current_state == dst_state

    unix_remote_proxy_pc.goto_state(state=src_state)
    assert unix_remote_proxy_pc.current_state == src_state
    start_time = time.time()
    unix_remote_proxy_pc.goto_state(state=dst_state)
    execution_time_fg = time.time() - start_time
    assert unix_remote_proxy_pc.current_state == dst_state
    time_diff = abs(execution_time_bg - execution_time_fg)
    assert time_diff < min(execution_time_fg, execution_time_bg) / 2
Ejemplo n.º 5
0
def test_juniper_ex_proxy_pc_device(device_connection,
                                    juniper_ex_proxy_pc_output):
    juniper_ex_proxy_pc = get_device(name="JUNIPER_EX_PROXY_PC",
                                     connection=device_connection,
                                     device_output=juniper_ex_proxy_pc_output,
                                     test_file_path=__file__)
    iterate_over_device_states(device=juniper_ex_proxy_pc)
Ejemplo n.º 6
0
def test_unix_local_device(device_connection, unix_local_output):
    unix_local = get_device(name="UNIX_LOCAL",
                            connection=device_connection,
                            device_output=unix_local_output,
                            test_file_path=__file__)

    iterate_over_device_states(device=unix_local)
Ejemplo n.º 7
0
def test_unix_remote_device(device_connection, unix_remote_output):
    unix_remote = get_device(name="UNIX_REMOTE",
                             connection=device_connection,
                             device_output=unix_remote_output,
                             test_file_path=__file__)
    iterate_over_device_states(device=unix_remote)
    assert None is not unix_remote._cmdnames_available_in_state[
        'UNIX_LOCAL_ROOT']
Ejemplo n.º 8
0
def test_unix_remote_proxy_pc_device(device_connection,
                                     unix_remote_proxy_pc_output):
    unix_remote_proxy_pc = get_device(
        name="UNIX_REMOTE_PROXY_PC",
        connection=device_connection,
        device_output=unix_remote_proxy_pc_output,
        test_file_path=__file__)

    iterate_over_device_states(device=unix_remote_proxy_pc)
Ejemplo n.º 9
0
def test_unix_remote_proxy_pc_device(device_connection,
                                     unix_remote_proxy_pc_output):
    unix_remote_proxy_pc = get_device(
        name="UNIX_REMOTE_PROXY_PC",
        connection=device_connection,
        device_output=unix_remote_proxy_pc_output,
        test_file_path=__file__)

    assert None is unix_remote_proxy_pc._cmdnames_available_in_state[
        'UNIX_LOCAL_ROOT']
    iterate_over_device_states(device=unix_remote_proxy_pc)
    assert None is not unix_remote_proxy_pc._cmdnames_available_in_state[
        'UNIX_LOCAL_ROOT']
Ejemplo n.º 10
0
def test_unix_remote_proxy_pc_device_goto_state_bg_await(
        device_connection, unix_remote_proxy_pc_output):
    unix_remote_proxy_pc = get_device(
        name="UNIX_REMOTE_PROXY_PC",
        connection=device_connection,
        device_output=unix_remote_proxy_pc_output,
        test_file_path=__file__)
    unix_remote_proxy_pc._goto_state_in_production_mode = True
    dst_state = "UNIX_REMOTE_ROOT"
    src_state = "UNIX_LOCAL"
    unix_remote_proxy_pc.goto_state(state=src_state)
    assert unix_remote_proxy_pc.current_state == src_state
    unix_remote_proxy_pc.goto_state_bg(state=dst_state)
    assert unix_remote_proxy_pc.current_state != dst_state
    unix_remote_proxy_pc.await_goto_state()
    assert unix_remote_proxy_pc.current_state == dst_state
Ejemplo n.º 11
0
def test_unix_remote_proxy_pc_device_goto_state_bg_await_excption(
        device_connection, unix_remote_proxy_pc_output):
    unix_remote_proxy_pc = get_device(
        name="UNIX_REMOTE_PROXY_PC",
        connection=device_connection,
        device_output=unix_remote_proxy_pc_output,
        test_file_path=__file__)
    unix_remote_proxy_pc._goto_state_in_production_mode = True
    dst_state = "UNIX_REMOTE_ROOT"
    src_state = "UNIX_LOCAL"
    unix_remote_proxy_pc.goto_state(state=src_state)
    assert unix_remote_proxy_pc.current_state == src_state
    unix_remote_proxy_pc.goto_state_bg(state=dst_state)
    assert unix_remote_proxy_pc.current_state != dst_state
    with pytest.raises(DeviceChangeStateFailure) as de:
        unix_remote_proxy_pc.await_goto_state(timeout=0.001)
    assert 'seconds there are still states to go' in str(de.value)
    unix_remote_proxy_pc.await_goto_state()
    assert unix_remote_proxy_pc.current_state == dst_state
Ejemplo n.º 12
0
def test_pdu_device(device_connection, pdu_output):
    pdu = get_device(name="PDU", connection=device_connection, device_output=pdu_output,
                     test_file_path=__file__)

    iterate_over_device_states(device=pdu)
Ejemplo n.º 13
0
def test_scpi_device(device_connection, scpi_output):
    scpi = get_device(name="SCPI", connection=device_connection, device_output=scpi_output,
                      test_file_path=__file__)

    iterate_over_device_states(device=scpi)
Ejemplo n.º 14
0
def test_scpi_proxy_pc_device(device_connection, scpi_proxy_pc_output):
    scpi_proxy_pc = get_device(name="SCPI_PROXY_PC", connection=device_connection,
                               device_output=scpi_proxy_pc_output, test_file_path=__file__)

    iterate_over_device_states(device=scpi_proxy_pc)
Ejemplo n.º 15
0
def test_juniper_ex_device(device_connection, juniper_ex_output):
    juniper_ex = get_device(name="JUNIPER_EX",
                            connection=device_connection,
                            device_output=juniper_ex_output,
                            test_file_path=__file__)
    iterate_over_device_states(device=juniper_ex)