Skip to content

Commit

Permalink
Repurpose tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rm-hull committed May 29, 2019
1 parent 37ead92 commit 5853f68
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions tests/test_backlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# See LICENSE.rst for details.

import luma.core.error
from luma.lcd.aux import backlight

from luma.lcd.device import backlit_device
from luma.core.interface.serial import noop
from helpers import Mock


Expand All @@ -26,46 +26,46 @@ def test_unsupported_platform():
errorgpio.setmode.side_effect = e

try:
backlight(gpio_LIGHT=19, gpio=errorgpio)
backlit_device(serial_interface=noop(), gpio_LIGHT=19, gpio=errorgpio)
except luma.core.error.UnsupportedPlatform as ex:
assert str(ex) == 'GPIO access not available'


def test_init():
gpio_LIGHT = 11
backlight(gpio=gpio, gpio_LIGHT=gpio_LIGHT)
backlit_device(serial_interface=noop(), gpio=gpio, gpio_LIGHT=gpio_LIGHT)
gpio.setmode.assert_called_once_with(gpio.BCM)
gpio.setup.assert_called_once_with(gpio_LIGHT, gpio.OUT)
gpio.output.assert_called_once_with(gpio_LIGHT, gpio.LOW)


def test_active_low_enable_on():
gpio_LIGHT = 14
light = backlight(gpio=gpio, gpio_LIGHT=gpio_LIGHT)
device = backlit_device(serial_interface=noop(), gpio=gpio, gpio_LIGHT=gpio_LIGHT)
gpio.reset_mock()
light.enable(True)
device.backlight(True)
gpio.output.assert_called_once_with(gpio_LIGHT, gpio.LOW)


def test_active_low_enable_off():
gpio_LIGHT = 19
light = backlight(gpio=gpio, gpio_LIGHT=gpio_LIGHT)
device = backlit_device(serial_interface=noop(), gpio=gpio, gpio_LIGHT=gpio_LIGHT)
gpio.reset_mock()
light.enable(False)
device.backlight(False)
gpio.output.assert_called_once_with(gpio_LIGHT, gpio.HIGH)


def test_active_high_enable_on():
gpio_LIGHT = 14
light = backlight(gpio=gpio, gpio_LIGHT=gpio_LIGHT, active_low=False)
device = backlit_device(serial_interface=noop(), gpio=gpio, gpio_LIGHT=gpio_LIGHT, active_low=False)
gpio.reset_mock()
light.enable(True)
device.backlight(True)
gpio.output.assert_called_once_with(gpio_LIGHT, gpio.HIGH)


def test_active_high_enable_off():
gpio_LIGHT = 19
light = backlight(gpio=gpio, gpio_LIGHT=gpio_LIGHT, active_low=False)
device = backlit_device(serial_interface=noop(), gpio=gpio, gpio_LIGHT=gpio_LIGHT, active_low=False)
gpio.reset_mock()
light.enable(False)
device.backlight(False)
gpio.output.assert_called_once_with(gpio_LIGHT, gpio.LOW)

0 comments on commit 5853f68

Please sign in to comment.