Debian Codegraph @

tests/instruments/inficon/test_sqm160.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.inficon.sqm160 import calculate_checksum, SQM160
28
29
30 def test_checksum():
31 """Verify the calculate_checksum function."""
32 # test against values documented in the manual
33 assert calculate_checksum(b'#@') == b'O7'
34 assert calculate_checksum(b'$C?') == b'g/'
35
36
37 def test_firmware_version():
38 """Verify the communication of the firmware version."""
39 with expected_protocol(
40 SQM160,
41 [(b"!#@O7", b"!0AMON Ver 4.13Uw"), ],
42 ) as inst:
43 assert inst.firmware_version == "MON Ver 4.13"
44
45
46 def test_number_of_channels():
47 """Verify the communication of the number of channels."""
48 with expected_protocol(
49 SQM160,
50 [(b"!#JO8", b"!%A6v\x86"), ],
51 ) as inst:
52 assert inst.number_of_channels == 6
53
54
55 def test_average_rate():
56 """Verify reading of the average rate."""
57 with expected_protocol(
58 SQM160,
59 [(b"!#M\x8e\x8a", b"!*A 0.01 i?"), ],
60 ) as inst:
61 assert inst.average_rate == pytest.approx(0.01)
62
63
64 def test_average_thickness():
65 """Verify reading of the average rate."""
66 with expected_protocol(
67 SQM160,
68 [(b"!#O\x8f9", b"!+A 0.000 Jo"), ],
69 ) as inst:
70 assert inst.average_thickness == pytest.approx(0.0)
71
72
73 def test_channel_rate():
74 """Verify reading of the rate of a channel."""
75 with expected_protocol(
76 SQM160,
77 [(b"!%L1?\x85{", b"!*A 0.00 [d"), ],
78 ) as inst:
79 assert inst.sensor_1.rate == pytest.approx(0.0)
80
81
82 def test_channel_frequency():
83 """Verify reading of the frequency of a channel."""
84 with expected_protocol(
85 SQM160,
86 [(b"!$P1Z\x91", b"!/A5875830.230:X"), ],
87 ) as inst:
88 assert inst.sensor_1.frequency == pytest.approx(5875830.23)