import pytest

from matterlab_valves import ValcoSelectionValve


@pytest.mark.real
def test_valco_selection_real_read(hardware_com_port, hardware_num_port):
    valve = ValcoSelectionValve(
        com_port=hardware_com_port,
        num_port=hardware_num_port,
        ports={"home": 1},
    )

    assert valve.num_port == hardware_num_port
    assert isinstance(valve.port, int)


@pytest.mark.real
def test_valco_selection_real_switch(hardware_com_port, hardware_num_port):
    valve = ValcoSelectionValve(
        com_port=hardware_com_port,
        num_port=hardware_num_port,
        ports={"home": 1},
    )

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

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