Test tweaks and linting
[EVA-2020-02-2.git] / library / tests / test_setup.py
1 import sys
2 import mock
3
4
5 def test_gas_setup(GPIO, smbus):
6 from enviroplus import gas
7 gas._is_setup = False
8 gas.setup()
9 gas.setup()
10
11
12 def test_gas_read_all(GPIO, smbus):
13 from enviroplus import gas
14 gas._is_setup = False
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
29 def test_gas_read_each(GPIO, smbus):
30 from enviroplus import gas
31 gas._is_setup = False
32
33 assert int(gas.read_oxidising()) == 16641
34 assert int(gas.read_reducing()) == 16727
35 assert int(gas.read_nh3()) == 16813
36
37
38 def test_gas_read_adc(GPIO, smbus):
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
47 def test_gas_read_adc_default_gain(GPIO, smbus):
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
55 def test_gas_read_adc_str(GPIO, smbus):
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())