Skip to content

Commit

Permalink
prevents loading custom lib in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Robb-Fr committed Apr 23, 2024
1 parent 64e56e1 commit 5e1a93c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ jobs:
cd display_controller && ruff check *.py lib/*.py -v
- name: Test with pytest
run: |
cd display_controller && ls -lah lib/waveshare_epd && python3 -m unittest
cd display_controller && python3 -m unittest
8 changes: 5 additions & 3 deletions display_controller/tests.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import unittest
import os
from lib import create_to_display_image, parse_api_result, font
from lib.waveshare_epd import epd4in2
from PIL import Image, ImageChops

TEST_RESULT_FILENAME = "api_result_test.tsv"
TEST_IMAGE_FILENAME = "test_display.bmp"
IMAGE_WIDTH = 400
IMAGE_HEIGHT = 300

test_result_filepath = os.path.join(
os.path.dirname(os.path.dirname(os.path.realpath(__file__))),
Expand All @@ -31,9 +32,10 @@ def test_parse_result(self):

def test_generate_image(self):
to_display = parse_api_result(test_result_filepath)
epd = epd4in2.EPD()

test_image = create_to_display_image(to_display, epd.width, epd.height, font)
test_image = create_to_display_image(
to_display, IMAGE_WIDTH, IMAGE_HEIGHT, font
)
with Image.open(test_image_filepath) as expected_image:
diff = ImageChops.difference(test_image, expected_image)
self.assertIsNone(diff.getbbox())
Expand Down

0 comments on commit 5e1a93c

Please sign in to comment.