Coverage for tests/test_dummy_dev.py: 100%

1"""

2 Prerequisites:

3

4 All unit tests assume that the dummy device simulator is already running. You can start the simulator

5 with the following command:

6

7 $ cgse dummy start-sim

8

9"""

10

11 from cgse_dummy.dummy_dev import Dummy

12

13

14 def test_connect_disconnect():

15 dev = Dummy()

16

17 dev.connect()

18 assert dev.is_connected()

19

20 dev.disconnect()

21 assert not dev.is_connected()

22

23 with Dummy() as dummy:

24 assert dummy.is_connected()

25

26 assert not dummy.is_connected()

27

28

29 def test_id():

30

31 from cgse_dummy.dummy_sim import _VERSION

32

33 dev = Dummy()

34 dev.connect()

35

36 response = dev.query("*IDN?")

37

38 parts = response.decode().strip().split(", ")

39

40 assert len(parts) == 4

41

42 manufacturer, model, sn, version = parts

43

44 assert manufacturer == "DUMMY INSTRUMENTS" # check the settings.yaml if this test fails

45 assert model == "DAQ-1234" # check the settings.yaml if this test fails

46 assert sn == "SN2025-X23-5" # check the settings.yaml if this test fails

47 assert version == _VERSION

48

49 dev.disconnect()