import pytest

from matterlab_valves import RunzeSelectionValve


@pytest.mark.real
def test_runze_selection_real_read(hardware_com_port, hardware_num_port, hardware_address):
    valve = RunzeSelectionValve(
        com_port=hardware_com_port,
        address=hardware_address,
        num_port=hardware_num_port,
        ports={"home": 1},
    )

    assert valve.num_port == hardware_num_port


@pytest.mark.real
def test_runze_selection_real_switch(hardware_com_port, hardware_num_port, hardware_address):
    valve = RunzeSelectionValve(
        com_port=hardware_com_port,
        address=hardware_address,
        num_port=hardware_num_port,
        ports={"home": 1},
    )

    valve.port = 2
    assert valve.port == 2

    valve.switch_port("home")
    assert valve.port == 1
