示例#1
0
def test_powerswitch_connection_check(zk2, remote_client):
    """
    Tests that the power switch connection check can fail and that SUT_RECOVER_PERFORM is triggered.

    Blocks the power switch request until the test case is in the correct state before registering
    messagebus dispatchers.
    """
    with GudeMock() as server:
        server.set_error()
        block = Event()
        server.set_block(block, timeout=1)

        process = zk2(
            [
                'sut', 'runcommand', 'testfinder', 'remote', 'powerswitch', 'powerswitchcc', 'gude',
                'connectioncheck'
            ],
            '--remote-enabled true '
            '--remote-port {remote_port} '
            'run --suts-ids box --suts-box@ip localhost '
            '--suts-box@powerswitch gude '
            '--suts-box@gude-ip localhost:{port} '
            '--suts-box@gude-port 4 '
            'powerswitch.systest.data.suites.test_minimal'.format(
                remote_port=remote_client.port, port=server.port),
            wait=False)
        try:

            with remote_client.client() as client:
                client.define_endpoints_and_messages({SYSTEST: [SUT_RECOVERY_PERFORM]})
                with client.local_message_queue([SUT_RECOVERY_PERFORM], entities=['box']) as queue:
                    block.set()
                    queue.get(timeout=1)
        finally:
            process.wait()
示例#2
0
def test_gude_state_with_json_flag(gude):
    with GudeMock() as server:
        result = gude('state', server.port, json=True)
        assert json.loads(result.stdout) == {
            '4': {
                'state': 'ON',
                'changed': False
            }
        }
示例#3
0
def test_gude_state_changed(gude):
    with GudeMock() as server:
        result = gude('off', server.port, json=True)
        assert json.loads(result.stdout) == {
            '4': {
                'state': 'OFF',
                'changed': True
            }
        }
示例#4
0
def test_powermeter_power_error(zk2):
    with GudeMock() as server:
        server.set_error()
        result = zk2(['powermeter', 'gude'],
                     'powermeter --suts-ids box '
                     '--suts-box@powermeter gude '
                     '--suts-box@gude-ip localhost:{port} '
                     '--suts-box@gude-port 4 '
                     '--json'.format(port=server.port),
                     expected_exit_code=1)
        json.loads(result.stdout)
示例#5
0
def test_gude_state_set_to_off(gude):
    with GudeMock() as server:
        result = gude('off', server.port)
        assert 'OFF' in result.stdout
示例#6
0
def test_gude_state_set_to_on(gude):
    with GudeMock() as server:
        server.states = [False] * 8
        result = gude('on', server.port)
        assert 'ON' in result.stdout
示例#7
0
def test_gude_state_off(gude):
    with GudeMock() as server:
        server.states = [False] * 8
        result = gude('state', server.port)
        assert 'OFF' in result.stdout
示例#8
0
def test_powerswitch_state_is_off(powerswitch):
    with GudeMock() as server:
        server.set_states([False] * 8)
        result = powerswitch('state', server.port)
        assert 'OFF' in result.stdout
示例#9
0
def test_powermeter_power_error(powermeter):
    with GudeMock() as server:
        server.set_error()
        powermeter(server.port, expected_exit_code=1)
示例#10
0
def test_gude_state_error(gude):
    with GudeMock() as server:
        server.set_error()
        gude('state', server.port, expected_exit_code=1)
示例#11
0
def test_powerswitch_state_changed(powerswitch):
    with GudeMock() as server:
        result = powerswitch('off', server.port, json=True)
        assert json.loads(result.stdout)['box']['changed']
示例#12
0
def test_powerswitch_state_json_format(powerswitch):
    with GudeMock() as server:
        result = powerswitch('state', server.port, json=True)
        json.loads(result.stdout)
示例#13
0
def test_powerswitch_set_state_to_off_error(powerswitch):
    with GudeMock() as server:
        server.set_error()
        powerswitch('off', server.port, expected_exit_code=1)
示例#14
0
def test_set_power_state_off(powerswitch):
    with GudeMock() as server:
        result = powerswitch('off', server.port)
        assert 'OFF' in result.stdout
示例#15
0
def test_set_power_state_on(powerswitch):
    with GudeMock() as server:
        server.set_states([False] * 8)
        result = powerswitch('on', server.port)
        assert 'ON' in result.stdout
示例#16
0
def test_gude_state_for_all_ports_with_different_states(gude):
    with GudeMock() as server:
        server.states = [True, False, True, True, False, False, True, True]
        result = gude('state', server.port, port_arg='')
        assert result.stdout.count('ON') == 5
        assert result.stdout.count('OFF') == 3
示例#17
0
def test_gude_state_set_for_multiple_ports(gude):
    with GudeMock() as server:
        result = gude('state', server.port, port_arg='--port 4 --port 6')
        assert result.stdout.count('ON') == 2
示例#18
0
def test_gude_power(gude):
    with GudeMock() as server:
        server.set_default_sensor_value(42)
        result = gude('power', server.port)
        assert '42 W' in result.stdout
示例#19
0
def test_gude_power_json(gude):
    with GudeMock() as server:
        server.set_default_sensor_value(42)
        result = gude('power', server.port, json=True)
        assert json.loads(result.stdout) == {'4': {'power': 42}}
示例#20
0
def test_gude_power_error(gude):
    with GudeMock() as server:
        server.set_error()
        gude('power', server.port, expected_exit_code=1)
示例#21
0
def test_powermeter_power(powermeter):
    with GudeMock() as server:
        server.set_default_sensor_value(42)
        result = powermeter(server.port)
        assert '42.0 W' in result.stdout
示例#22
0
def test_gude_state_on(gude):
    with GudeMock() as server:
        result = gude('state', server.port)
        assert 'ON' in result.stdout
示例#23
0
def test_powermeter_state_json_format(powermeter):
    with GudeMock() as server:
        result = powermeter(server.port, json=True)
        json.loads(result.stdout)
示例#24
0
def test_powerswitch_state_is_on(powerswitch):
    with GudeMock() as server:
        result = powerswitch('state', server.port)
        assert 'ON' in result.stdout