X-Git-Url: https://zdv2.bktei.com/gitweb/EVA-2020-02-2.git/blobdiff_plain/4f8716dc13aa14bf586dd78002d6bf4d331bc656..c440294cc10ba86b4cdeae53b3b3592110493190:/library/tests/test_setup.py diff --git a/library/tests/test_setup.py b/library/tests/test_setup.py index af3ed82..7c25d94 100644 --- a/library/tests/test_setup.py +++ b/library/tests/test_setup.py @@ -15,7 +15,8 @@ def test_gas_setup(): smbus = mock.Mock() smbus.SMBus = SMBusFakeDevice sys.modules['smbus'] = smbus - from envirophatplus import gas + from enviroplus import gas + gas._is_setup = False gas.setup() gas.setup() @@ -26,7 +27,8 @@ def test_gas_read_all(): smbus = mock.Mock() smbus.SMBus = SMBusFakeDevice sys.modules['smbus'] = smbus - from envirophatplus import gas + from enviroplus import gas + gas._is_setup = False result = gas.read_all() assert type(result.oxidising) == float @@ -47,8 +49,50 @@ def test_gas_read_each(): smbus = mock.Mock() smbus.SMBus = SMBusFakeDevice sys.modules['smbus'] = smbus - from envirophatplus import gas + from enviroplus import gas + gas._is_setup = False assert int(gas.read_oxidising()) == 16641 assert int(gas.read_reducing()) == 16727 assert int(gas.read_nh3()) == 16813 + + +def test_gas_read_adc(): + sys.modules['RPi'] = mock.Mock() + sys.modules['RPi.GPIO'] = mock.Mock() + smbus = mock.Mock() + smbus.SMBus = SMBusFakeDevice + sys.modules['smbus'] = smbus + from enviroplus import gas + gas._is_setup = False + + gas.enable_adc(True) + gas.set_adc_gain(2.048) + assert gas.read_adc() == 0.255 + + +def test_gas_read_adc_default_gain(): + sys.modules['RPi'] = mock.Mock() + sys.modules['RPi.GPIO'] = mock.Mock() + smbus = mock.Mock() + smbus.SMBus = SMBusFakeDevice + sys.modules['smbus'] = smbus + from enviroplus import gas + gas._is_setup = False + + gas.enable_adc(True) + assert gas.read_adc() == 0.255 + + +def test_gas_read_adc_str(): + sys.modules['RPi'] = mock.Mock() + sys.modules['RPi.GPIO'] = mock.Mock() + smbus = mock.Mock() + smbus.SMBus = SMBusFakeDevice + sys.modules['smbus'] = smbus + from enviroplus import gas + gas._is_setup = False + + gas.enable_adc(True) + gas.set_adc_gain(2.048) + assert 'ADC' in str(gas.read_all())