File: test_manualswitchdriver.py

package info (click to toggle)
labgrid 25.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,796 kB
  • sloc: python: 21,352; sh: 846; makefile: 35
file content (43 lines) | stat: -rw-r--r-- 1,125 bytes parent folder | download | duplicates (2)
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