Debian Codegraph @

tests/instruments/texio/test_texioPSW360L30.py

raw
1 #
2 # This file is part of the PyMeasure package.
3 #
4 # Copyright (c) 2013-2024 PyMeasure Developers
5 #
6 # Permission is hereby granted, free of charge, to any person obtaining a copy
7 # of this software and associated documentation files (the "Software"), to deal
8 # in the Software without restriction, including without limitation the rights
9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 # copies of the Software, and to permit persons to whom the Software is
11 # furnished to do so, subject to the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be included in
14 # all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 # THE SOFTWARE.
23 #
24 import pytest
25
26 from pymeasure.test import expected_protocol
27 from pymeasure.instruments.texio.texioPSW360L30 import TexioPSW360L30
28
29
30 def test_name():
31 texio = TexioPSW360L30(adapter=None)
32 assert "TEXIO" in texio.name.upper()
33
34
35 def test_output_enabled():
36 with expected_protocol(
37 TexioPSW360L30,
38 [(b"OUTPut?", b"1"),
39 (b"OUTPut 1", None),
40 (b"OUTPut?", b"0"),
41 (b"OUTPut 0", None),
42 ],
43 ) as inst:
44 assert inst.output_enabled is True
45 inst.output_enabled = True
46 assert inst.output_enabled is False
47 inst.output_enabled = False
48
49
50 def test_current_limit():
51 with expected_protocol(
52 TexioPSW360L30,
53 [(b":SOUR:CURR?", b"+5.120"),
54 (b":SOUR:CURR 5", None)
55 ],
56 ) as inst:
57 assert inst.current_limit == 5.12
58 inst.current_limit = 5
59
60
61 def test_voltage_setpoint():
62 with expected_protocol(
63 TexioPSW360L30,
64 [(b":SOUR:VOLT?", b"+10.000"),
65 (b":SOUR:VOLT 10", None)
66 ],
67 ) as inst:
68 assert inst.voltage_setpoint == 10.
69 inst.voltage_setpoint = 10
70
71
72 def test_measure_power():
73 with expected_protocol(
74 TexioPSW360L30,
75 [(b":MEAS:POW?", b"+51.200"),
76 ],
77 ) as inst:
78 assert inst.power == 51.2
79
80
81 def test_measure_voltage():
82 with expected_protocol(
83 TexioPSW360L30,
84 [(b":MEAS:VOLT?", b"+10.000"),
85 ],
86 ) as inst:
87 assert inst.voltage == 10.
88
89
90 def test_measure_current():
91 with expected_protocol(
92 TexioPSW360L30,
93 [(b":MEAS:CURR?", b"+5.120"),
94 ],
95 ) as inst:
96 assert inst.current == 5.12
97
98
99 def test_applied():
100 with expected_protocol(
101 TexioPSW360L30,
102 [(b":APPly?", b"+5.050, +1.100"),
103 (b":APPly 5.05,1.1", None)
104 ],
105 ) as inst:
106 assert inst.applied == [5.05, 1.1]
107 inst.applied = (5.05, 1.1)
108
109
110 if __name__ == '__main__':
111 pytest.main()