Added user projects section to README
[EVA-2020-02-2.git] / library / tests / test_setup.py
1 def test_gas_setup(GPIO, smbus):
2 from enviroplus import gas
3 gas._is_setup = False
4 gas.setup()
5 gas.setup()
6
7
8 def test_gas_read_all(GPIO, smbus):
9 from enviroplus import gas
10 gas._is_setup = False
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
25 def test_gas_read_each(GPIO, smbus):
26 from enviroplus import gas
27 gas._is_setup = False
28
29 assert int(gas.read_oxidising()) == 16641
30 assert int(gas.read_reducing()) == 16727
31 assert int(gas.read_nh3()) == 16813
32
33
34 def test_gas_read_adc(GPIO, smbus):
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
43 def test_gas_read_adc_default_gain(GPIO, smbus):
44 from enviroplus import gas
45 gas._is_setup = False
46
47 gas.enable_adc(True)
48 gas.set_adc_gain(gas.MICS6814_GAIN)
49 assert gas.read_adc() == 0.765
50
51
52 def test_gas_read_adc_str(GPIO, smbus):
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())
59
60
61 def test_gas_cleanup(GPIO, smbus):
62 from enviroplus import gas
63
64 gas.cleanup()
65
66 GPIO.output.assert_called_with(gas.MICS6814_HEATER_PIN, 0)