1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
import pytest
from labgrid.driver.manualswitchdriver import ManualSwitchDriver
class TestManualSwitchDriver:
def test_create(self, target):
d = ManualSwitchDriver(target, "foo-switch")
assert isinstance(d, ManualSwitchDriver)
def test_set_on(self, target, mocker):
m = mocker.patch("builtins.input")
d = ManualSwitchDriver(target, "foo-switch")
target.activate(d)
d.set(True)
m.assert_called_once_with(
"Set foo-switch for target Test to ON and press enter"
)
def test_set_off(self, target, mocker):
m = mocker.patch("builtins.input")
d = ManualSwitchDriver(target, "foo-switch")
target.activate(d)
d.set(False)
m.assert_called_once_with(
"Set foo-switch for target Test to OFF and press enter"
)
def test_get(self, target, mocker):
m = mocker.patch("builtins.input")
d = ManualSwitchDriver(target, "foo-switch")
target.activate(d)
d.set(True)
assert d.get() is True
d.set(False)
assert d.get() is False
|