import pytest

from matterlab_valves import JKem4in1Valve


@pytest.mark.real
def test_jkem_4in1_real_read(hardware_com_port, hardware_valve_num):
    valve = JKem4in1Valve(
        com_port=hardware_com_port,
        valve_num=hardware_valve_num,
        ports={"1": 1, "2": 2},
    )

    current_port = valve.port

    assert isinstance(current_port, int)
    assert 1 <= current_port <= valve.num_port


@pytest.mark.real
def test_jkem_4in1_real_switch(hardware_com_port, hardware_valve_num):
    valve = JKem4in1Valve(
        com_port=hardware_com_port,
        valve_num=hardware_valve_num,
        ports={"1": 1, "2": 2},
    )

    valve.port = 1
    assert valve.port == 1

    valve.switch_port("2")
    assert valve.port == 2
