Ejemplo n.º 1
0
def test_sout():
    mock = HcsMock()
    hcs = HcsCom(port=mock)
    hcs.switch_output(OutputStatus.on)
    assert mock.output_status == OutputStatus.on
    hcs.switch_output(OutputStatus.off)
    assert mock.output_status == OutputStatus.off
Ejemplo n.º 2
0
def test_active_preset_set():
    mock = HcsMock()
    hcs = HcsCom(port=mock)
    curr = 10
    hcs.set_output_current_preset(curr)
    assert mock.active_preset[1] == curr
    volt = 24
    hcs.set_output_voltage_preset(volt)
    assert mock.active_preset[0] == volt
Ejemplo n.º 3
0
def test_display_set():
    mock = HcsMock()
    hcs = HcsCom(port=mock)
    volt = 12
    hcs.set_voltage(volt)
    assert mock.display_values[0] == volt
    curr = 5
    hcs.set_current(curr)
    assert mock.display_values[1] == curr
Ejemplo n.º 4
0
def test_display_set_format_four_digits():
    mock = HcsMock()
    mock.set_format(FORMAT_FOUR_DIGITS)
    hcs = HcsCom(port=mock)
    assert hcs.value_format == FORMAT_FOUR_DIGITS
    volt = 12
    hcs.set_voltage(volt)
    assert mock.display_values[0] == volt
    curr = 5
    hcs.set_current(curr)
    assert mock.display_values[1] == curr
Ejemplo n.º 5
0
def test_preset_selection():
    mock = HcsMock()
    hcs = HcsCom(port=mock)
    test_preset = (11.0, 22.0)
    mock.presets[1] = test_preset
    hcs.load_preset(1)
    assert mock.display_values == test_preset
    assert hcs.get_presets() == test_preset
    assert hcs.get_display_status()[:-1] == test_preset
    assert hcs.get_output_voltage_preset() == test_preset[0]
    assert hcs.get_output_current_preset() == test_preset[1]
    presets = hcs.get_presets_from_memory()
    for idx, preset in enumerate(mock.presets):
        for num1, num2 in zip(preset, presets.get(idx)):
            assert num1 == num2
    hcs.set_presets_to_memory()
    presets = hcs.get_presets_from_memory()
    for idx, preset in enumerate(mock.presets):
        for num1, num2 in zip(preset, presets.get(idx)):
            assert num1 == num2
Ejemplo n.º 6
0
def test_obj_creation_should_fail_wrong_response():
    mock = HcsDefectMock()
    hcs = HcsCom(port=mock)
Ejemplo n.º 7
0
def test_obj_creation_should_fail_wrong_port_type():
    hcs = HcsCom(port=None)
Ejemplo n.º 8
0
def test_obj_creation_should_fail_wrong_port_string():
    hcs = HcsCom(port="some_port")
Ejemplo n.º 9
0
def test_print():
    mock = HcsMock()
    hcs = HcsCom(port=mock)
    print(hcs)