Skip to content

Commit

Permalink
Test again
Browse files Browse the repository at this point in the history
  • Loading branch information
klaasnicolaas committed Oct 16, 2023
1 parent 66fe6a8 commit e2a1669
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 11 deletions.
25 changes: 14 additions & 11 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def led_controller(mock_pixelstrip) -> pytest.fixture:
Args:
----
mock_pixelstrip (pytest.fixture): Mock PixelStrip object
Returns:
-------
pytest.fixture: Mock LEDController
Expand All @@ -94,16 +94,19 @@ def led_controller(mock_pixelstrip) -> pytest.fixture:
invert = False
channel = 0

led_controller = LEDController(
count,
pin,
freq_hz,
dma,
brightness,
invert,
channel,
)
led_controller.strip.begin = True
led_controller = MagicMock(spec=LEDController)

# Set attributes as needed
led_controller.count = count
led_controller.pin = pin
led_controller.freq_hz = freq_hz
led_controller.dma = dma
led_controller.brightness = brightness
led_controller.invert = invert
led_controller.channel = channel

led_controller.strip = mock_pixelstrip
led_controller.strip.begin.return_value = True

return led_controller

Expand Down
1 change: 1 addition & 0 deletions tests/unit/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Unit tests for the Stair Flask application."""
23 changes: 23 additions & 0 deletions tests/unit/test_ledstrip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Unit tests for the LEDController class."""

from unittest.mock import MagicMock

from app import Color, LEDController
from app.led_controller import Direction


def test_led_controller_color_wipe() -> None:
# Create a mock PixelStrip object
mock_pixelstrip = MagicMock()

# Create an instance of LEDController with the mock PixelStrip
led_controller = LEDController(10, 10, 800000, 10, 255, False, 0)
led_controller.strip = mock_pixelstrip

# Call the color_wipe method
color = Color(0, 0, 255) # Assuming Color is a class with RGB values
wait_ms = 50
direction = Direction.TOP_TO_BOTTOM
led_controller.color_wipe(color, wait_ms, direction)

assert True

0 comments on commit e2a1669

Please sign in to comment.