Commit | Line | Data |
---|---|---|
4f8716dc PH |
1 | import sys |
2 | import mock | |
4f8716dc PH |
3 | |
4 | ||
be4d0fc9 | 5 | def test_gas_setup(GPIO, smbus): |
8ab4cd2d | 6 | from enviroplus import gas |
8c9d0615 | 7 | gas._is_setup = False |
4f8716dc PH |
8 | gas.setup() |
9 | gas.setup() | |
10 | ||
11 | ||
be4d0fc9 | 12 | def test_gas_read_all(GPIO, smbus): |
8ab4cd2d | 13 | from enviroplus import gas |
8c9d0615 | 14 | gas._is_setup = False |
4f8716dc PH |
15 | result = gas.read_all() |
16 | ||
17 | assert type(result.oxidising) == float | |
18 | assert int(result.oxidising) == 16641 | |
19 | ||
20 | assert type(result.reducing) == float | |
21 | assert int(result.reducing) == 16727 | |
22 | ||
23 | assert type(result.nh3) == float | |
24 | assert int(result.nh3) == 16813 | |
25 | ||
26 | assert "Oxidising" in str(result) | |
27 | ||
28 | ||
be4d0fc9 | 29 | def test_gas_read_each(GPIO, smbus): |
8ab4cd2d | 30 | from enviroplus import gas |
8c9d0615 | 31 | gas._is_setup = False |
4f8716dc PH |
32 | |
33 | assert int(gas.read_oxidising()) == 16641 | |
34 | assert int(gas.read_reducing()) == 16727 | |
35 | assert int(gas.read_nh3()) == 16813 | |
8c9d0615 PH |
36 | |
37 | ||
be4d0fc9 | 38 | def test_gas_read_adc(GPIO, smbus): |
8c9d0615 PH |
39 | from enviroplus import gas |
40 | gas._is_setup = False | |
41 | ||
42 | gas.enable_adc(True) | |
43 | gas.set_adc_gain(2.048) | |
44 | assert gas.read_adc() == 0.255 | |
45 | ||
46 | ||
be4d0fc9 | 47 | def test_gas_read_adc_default_gain(GPIO, smbus): |
8c9d0615 PH |
48 | from enviroplus import gas |
49 | gas._is_setup = False | |
50 | ||
51 | gas.enable_adc(True) | |
52 | assert gas.read_adc() == 0.255 | |
53 | ||
54 | ||
be4d0fc9 | 55 | def test_gas_read_adc_str(GPIO, smbus): |
8c9d0615 PH |
56 | from enviroplus import gas |
57 | gas._is_setup = False | |
58 | ||
59 | gas.enable_adc(True) | |
60 | gas.set_adc_gain(2.048) | |
61 | assert 'ADC' in str(gas.read_all()) |