Added user projects section to README
[EVA-2020-02-2.git] / library / tests / test_setup.py
CommitLineData
be4d0fc9 1def test_gas_setup(GPIO, smbus):
8ab4cd2d 2 from enviroplus import gas
8c9d0615 3 gas._is_setup = False
4f8716dc
PH
4 gas.setup()
5 gas.setup()
6
7
be4d0fc9 8def test_gas_read_all(GPIO, smbus):
8ab4cd2d 9 from enviroplus import gas
8c9d0615 10 gas._is_setup = False
4f8716dc
PH
11 result = gas.read_all()
12
13 assert type(result.oxidising) == float
14 assert int(result.oxidising) == 16641
15
16 assert type(result.reducing) == float
17 assert int(result.reducing) == 16727
18
19 assert type(result.nh3) == float
20 assert int(result.nh3) == 16813
21
22 assert "Oxidising" in str(result)
23
24
be4d0fc9 25def test_gas_read_each(GPIO, smbus):
8ab4cd2d 26 from enviroplus import gas
8c9d0615 27 gas._is_setup = False
4f8716dc
PH
28
29 assert int(gas.read_oxidising()) == 16641
30 assert int(gas.read_reducing()) == 16727
31 assert int(gas.read_nh3()) == 16813
8c9d0615
PH
32
33
be4d0fc9 34def test_gas_read_adc(GPIO, smbus):
8c9d0615
PH
35 from enviroplus import gas
36 gas._is_setup = False
37
38 gas.enable_adc(True)
39 gas.set_adc_gain(2.048)
40 assert gas.read_adc() == 0.255
41
42
be4d0fc9 43def test_gas_read_adc_default_gain(GPIO, smbus):
8c9d0615
PH
44 from enviroplus import gas
45 gas._is_setup = False
46
47 gas.enable_adc(True)
e9c93677
PH
48 gas.set_adc_gain(gas.MICS6814_GAIN)
49 assert gas.read_adc() == 0.765
8c9d0615
PH
50
51
be4d0fc9 52def test_gas_read_adc_str(GPIO, smbus):
8c9d0615
PH
53 from enviroplus import gas
54 gas._is_setup = False
55
56 gas.enable_adc(True)
57 gas.set_adc_gain(2.048)
58 assert 'ADC' in str(gas.read_all())
e9c93677
PH
59
60
61def test_gas_cleanup(GPIO, smbus):
e9c93677
PH
62 from enviroplus import gas
63
64 gas.cleanup()
65
66 GPIO.output.assert_called_with(gas.MICS6814_HEATER_PIN, 0)