What changed, and why it matters
This commit only adds a new hardware board ('wonder_k') to the project's test suite. It introduces mock definitions, test fixtures, and expected test outputs for the new board. There are no changes to the actual application code that users run, and nothing in the commit fixes or introduces a security vulnerability.
No security action needed. This is a routine test-maintenance commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit is a pure test-code change. It adds board_wonder_k() to tests/shared_mocks.py, a wonder_k fixture to tests/conftest.py, includes ‘wonder_k’ in the multiple_devices parametrized fixture, and updates test expectations in tests/pages/test_flash_tools.py, tests/pages/test_page.py, tests/test_camera.py, and tests/test_power.py to account for the new board. It also refactors some magic numbers into named constants and gives time.ticks_ms a fixed return value of 1 in the test mock. No production code is modified.
Changed components
tests/conftest.pytests/shared_mocks.pytests/pages/test_flash_tools.pytests/pages/test_page.pytests/test_camera.pytests/test_power.pyInspect captured patch +249 / −48
diff --git a/tests/conftest.py b/tests/conftest.py
index 2b01749..1d6d456 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -9,6 +9,7 @@ from .shared_mocks import (
board_wonder_mv,
board_yahboom,
board_bit,
+ board_wonder_k,
encode_to_string,
encode,
statvfs,
@@ -66,7 +67,9 @@ def mp_modules(mocker, monkeypatch):
)
monkeypatch.setitem(sys.modules, "shannon", mocker.MagicMock())
monkeypatch.setattr(time, "sleep_ms", mocker.MagicMock(), raising=False)
- monkeypatch.setattr(time, "ticks_ms", mocker.MagicMock(), raising=False)
+ monkeypatch.setattr(
+ time, "ticks_ms", mocker.MagicMock(return_value=1), raising=False
+ )
monkeypatch.setattr(sys, "print_exception", mocker.MagicMock(), raising=False)
monkeypatch.setitem(
sys.modules,
@@ -163,8 +166,26 @@ def bit(monkeypatch, mp_modules):
reset_krux_modules()
+@pytest.fixture
+def wonder_k(monkeypatch, mp_modules):
+ import sys
+
+ monkeypatch.setitem(sys.modules, "board", board_wonder_k())
+ monkeypatch.setitem(sys.modules, "pmu", None)
+ reset_krux_modules()
+
+
@pytest.fixture(
- params=["amigo", "m5stickv", "dock", "cube", "yahboom", "wonder_mv", "bit"]
+ params=[
+ "amigo",
+ "m5stickv",
+ "dock",
+ "cube",
+ "yahboom",
+ "wonder_mv",
+ "bit",
+ "wonder_k",
+ ]
)
def multiple_devices(request):
return request.getfixturevalue(request.param)
diff --git a/tests/pages/test_flash_tools.py b/tests/pages/test_flash_tools.py
index 3054511..c5b2d27 100644
--- a/tests/pages/test_flash_tools.py
+++ b/tests/pages/test_flash_tools.py
@@ -90,6 +90,7 @@ def test_tc_flash_hash(multiple_devices, mocker):
"yahboom": DOCK_FW_POS,
"wonder_mv": DOCK_FW_POS,
"bit": DOCK_FW_POS,
+ "wonder_k": DOCK_FW_POS,
}
users_data_words_positions = {
"amigo": 331,
@@ -99,6 +100,7 @@ def test_tc_flash_hash(multiple_devices, mocker):
"yahboom": DOCK_USER_POS,
"wonder_mv": DOCK_USER_POS,
"bit": DOCK_USER_POS,
+ "wonder_k": DOCK_USER_POS,
}
fw_words_pos = fw_words_positions[board.config["type"]]
u_data_words_pos = users_data_words_positions[board.config["type"]]
diff --git a/tests/pages/test_page.py b/tests/pages/test_page.py
index f57d1aa..041abd3 100644
--- a/tests/pages/test_page.py
+++ b/tests/pages/test_page.py
@@ -327,7 +327,6 @@ def test_keypad_swipe_hint_is_not_shown_on_nontouch_device(
def test_fit_to_line_text(mocker, multiple_devices, mock_page_cls):
import board
- from krux.display import FONT_WIDTH
ctx = mock_context(mocker)
page = mock_page_cls(ctx)
@@ -336,6 +335,11 @@ def test_fit_to_line_text(mocker, multiple_devices, mock_page_cls):
AMIGO = "amigo"
M5 = "m5stickv"
DOCK = "dock"
+ BIT = "bit"
+ CUBE = "cube"
+ YAHBOOM = "yahboom"
+ WONDER_MV = "wonder_mv"
+ WONDER_K = "wonder_k"
cases = [
{
@@ -343,96 +347,167 @@ def test_fit_to_line_text(mocker, multiple_devices, mock_page_cls):
AMIGO: "0123456789ab…opqrstuvwxyz",
M5: "0123456…tuvwxyz",
DOCK: "0123456789abc…nopqrstuvwxyz",
+ BIT: "0123456789abc…nopqrstuvwxyz",
+ CUBE: "0123456789abc…nopqrstuvwxyz",
+ YAHBOOM: "0123456789abc…nopqrstuvwxyz",
+ WONDER_MV: "0123456789abc…nopqrstuvwxyz",
+ WONDER_K: "0123456789abc…nopqrstuvwxyz",
},
{
TXT: "0123456789abcdefghijklmnopqrstuvwxy",
AMIGO: "0123456789ab…nopqrstuvwxy",
M5: "0123456…stuvwxy",
DOCK: "0123456789abc…mnopqrstuvwxy",
+ BIT: "0123456789abc…mnopqrstuvwxy",
+ CUBE: "0123456789abc…mnopqrstuvwxy",
+ YAHBOOM: "0123456789abc…mnopqrstuvwxy",
+ WONDER_MV: "0123456789abc…mnopqrstuvwxy",
+ WONDER_K: "0123456789abc…mnopqrstuvwxy",
},
{
TXT: "0123456789abcdefghijklmnopqrstuvwx",
AMIGO: "0123456789ab…mnopqrstuvwx",
M5: "0123456…rstuvwx",
DOCK: "0123456789abc…lmnopqrstuvwx",
+ BIT: "0123456789abc…lmnopqrstuvwx",
+ CUBE: "0123456789abc…lmnopqrstuvwx",
+ YAHBOOM: "0123456789abc…lmnopqrstuvwx",
+ WONDER_MV: "0123456789abc…lmnopqrstuvwx",
+ WONDER_K: "0123456789abc…lmnopqrstuvwx",
},
{
TXT: "0123456789abcdefghijklmnopqrstuvw",
AMIGO: "0123456789ab…lmnopqrstuvw",
M5: "0123456…qrstuvw",
DOCK: "0123456789abc…klmnopqrstuvw",
+ BIT: "0123456789abc…klmnopqrstuvw",
+ CUBE: "0123456789abc…klmnopqrstuvw",
+ YAHBOOM: "0123456789abc…klmnopqrstuvw",
+ WONDER_MV: "0123456789abc…klmnopqrstuvw",
+ WONDER_K: "0123456789abc…klmnopqrstuvw",
},
{
TXT: "0123456789abcdefghijklmnopqr",
AMIGO: "0123456789ab…ghijklmnopqr",
M5: "0123456…lmnopqr",
DOCK: "0123456789abc…fghijklmnopqr",
+ BIT: "0123456789abc…fghijklmnopqr",
+ CUBE: "0123456789abc…fghijklmnopqr",
+ YAHBOOM: "0123456789abc…fghijklmnopqr",
+ WONDER_MV: "0123456789abc…fghijklmnopqr",
+ WONDER_K: "0123456789abc…fghijklmnopqr",
},
{
TXT: "0123456789abcdefghijklmnopq",
AMIGO: "0123456789ab…fghijklmnopq",
M5: "0123456…klmnopq",
DOCK: "0123456789abcdefghijklmnopq",
+ BIT: "0123456789abcdefghijklmnopq",
+ CUBE: "0123456789abcdefghijklmnopq",
+ YAHBOOM: "0123456789abcdefghijklmnopq",
+ WONDER_MV: "0123456789abcdefghijklmnopq",
+ WONDER_K: "0123456789abcdefghijklmnopq",
},
{
TXT: "0123456789abcdefghijklmnop",
AMIGO: "0123456789ab…efghijklmnop",
M5: "0123456…jklmnop",
DOCK: "0123456789abcdefghijklmnop",
+ BIT: "0123456789abcdefghijklmnop",
+ CUBE: "0123456789abcdefghijklmnop",
+ YAHBOOM: "0123456789abcdefghijklmnop",
+ WONDER_MV: "0123456789abcdefghijklmnop",
+ WONDER_K: "0123456789abcdefghijklmnop",
},
{
TXT: "0123456789abcdefghijklmno",
AMIGO: "0123456789abcdefghijklmno",
M5: "0123456…ijklmno",
DOCK: "0123456789abcdefghijklmno",
+ BIT: "0123456789abcdefghijklmno",
+ CUBE: "0123456789abcdefghijklmno",
+ YAHBOOM: "0123456789abcdefghijklmno",
+ WONDER_MV: "0123456789abcdefghijklmno",
+ WONDER_K: "0123456789abcdefghijklmno",
},
{
TXT: "0123456789abcdefghijklmn",
AMIGO: "0123456789abcdefghijklmn",
M5: "0123456…hijklmn",
DOCK: "0123456789abcdefghijklmn",
+ BIT: "0123456789abcdefghijklmn",
+ CUBE: "0123456789abcdefghijklmn",
+ YAHBOOM: "0123456789abcdefghijklmn",
+ WONDER_MV: "0123456789abcdefghijklmn",
+ WONDER_K: "0123456789abcdefghijklmn",
},
{
TXT: "0123456789abcdefghijklm",
AMIGO: "0123456789abcdefghijklm",
M5: "0123456…ghijklm",
DOCK: "0123456789abcdefghijklm",
+ BIT: "0123456789abcdefghijklm",
+ CUBE: "0123456789abcdefghijklm",
+ YAHBOOM: "0123456789abcdefghijklm",
+ WONDER_MV: "0123456789abcdefghijklm",
+ WONDER_K: "0123456789abcdefghijklm",
},
{
TXT: "0123456789abcdefghij",
AMIGO: "0123456789abcdefghij",
M5: "0123456…defghij",
DOCK: "0123456789abcdefghij",
+ BIT: "0123456789abcdefghij",
+ CUBE: "0123456789abcdefghij",
+ YAHBOOM: "0123456789abcdefghij",
+ WONDER_MV: "0123456789abcdefghij",
+ WONDER_K: "0123456789abcdefghij",
},
{
TXT: "0123456789abcdefg",
AMIGO: "0123456789abcdefg",
M5: "0123456…abcdefg",
DOCK: "0123456789abcdefg",
+ BIT: "0123456789abcdefg",
+ CUBE: "0123456789abcdefg",
+ YAHBOOM: "0123456789abcdefg",
+ WONDER_MV: "0123456789abcdefg",
+ WONDER_K: "0123456789abcdefg",
},
{
TXT: "0123456789abcdef",
AMIGO: "0123456789abcdef",
M5: "0123456789abcdef",
DOCK: "0123456789abcdef",
+ BIT: "0123456789abcdef",
+ CUBE: "0123456789abcdef",
+ YAHBOOM: "0123456789abcdef",
+ WONDER_MV: "0123456789abcdef",
+ WONDER_K: "0123456789abcdef",
},
{
TXT: "0123456789abcde",
AMIGO: "0123456789abcde",
M5: "0123456789abcde",
DOCK: "0123456789abcde",
+ BIT: "0123456789abcde",
+ CUBE: "0123456789abcde",
+ YAHBOOM: "0123456789abcde",
+ WONDER_MV: "0123456789abcde",
+ WONDER_K: "0123456789abcde",
},
]
curr_device = board.config["type"]
- device_type = curr_device if curr_device in (AMIGO, M5) else DOCK
max_chars_in_line = ctx.display.ascii_chars_per_line()
+ n = 0
for i, case in enumerate(cases):
- print(i)
+ print(n)
formatted_text = page.fit_to_line(case[TXT])
assert len(formatted_text) <= max_chars_in_line
- assert formatted_text == case[device_type]
+ assert formatted_text == case[curr_device]
+ n += 1
def test_fit_to_line_prefix(mocker, multiple_devices, mock_page_cls):
diff --git a/tests/shared_mocks.py b/tests/shared_mocks.py
index 592067a..cadd019 100644
--- a/tests/shared_mocks.py
+++ b/tests/shared_mocks.py
@@ -1,10 +1,29 @@
-import pytest
from unittest import mock
from unittest.mock import MagicMock
import pyqrcode
import zlib
import base64
+M5STICKV_WIDTH = 135
+M5STICKV_HEIGHT = 240
+M5STICKV_USABLE_WIDTH = M5STICKV_WIDTH - 2 * 10
+M5STICKV_IN_LINE = M5STICKV_WIDTH // 8
+
+DOCK_WIDTH = 240
+DOCK_HEIGHT = 320
+DOCK_USABLE_WIDTH = DOCK_WIDTH - 2 * 10
+DOCK_IN_LINE = DOCK_USABLE_WIDTH // 8
+
+AMIGO_WIDTH = 320
+AMIGO_HEIGHT = 480
+AMIGO_USABLE_WIDTH = AMIGO_WIDTH - 2 * 10
+AMIGO_IN_LINE = AMIGO_USABLE_WIDTH // 12
+
+CUBE_WIDTH = 240
+CUBE_HEIGHT = 240
+CUBE_USABLE_WIDTH = DOCK_WIDTH - 2 * 10
+CUBE_IN_LINE = DOCK_USABLE_WIDTH // 8
+
class MockFile:
"""Custom mock file class that supports read, write, seek, and other file methods"""
@@ -653,6 +672,61 @@ def board_bit():
)
+def board_wonder_k():
+ return mock.MagicMock(
+ config={
+ "type": "wonder_k",
+ "lcd": {
+ "dcx": 37,
+ "ss": 38,
+ "rst": 36,
+ "clk": 39,
+ "height": 240,
+ "width": 320,
+ "invert": 0,
+ "dir": 160,
+ "lcd_type": 0,
+ },
+ "sensor": {
+ "pin_sda": 40,
+ "cmos_href": 45,
+ "cmos_pclk": 47,
+ "cmos_xclk": 46,
+ "cmos_pwdn": 44,
+ "cmos_vsync": 43,
+ "reg_width": 16,
+ "i2c_num": 2,
+ "pin_clk": 41,
+ "cmos_rst": 42,
+ },
+ "sdcard": {"sclk": 32, "mosi": 33, "miso": 35, "cs": 30},
+ "board_info": {
+ "BOOT_KEY": 16,
+ "CONNEXT_A": 6,
+ "CONNEXT_B": 8,
+ "I2C_SDA": 27,
+ "I2C_SCL": 24,
+ "SPI_SCLK": 32,
+ "SPI_MOSI": 33,
+ "SPI_MISO": 35,
+ "SPI_CS": 30,
+ },
+ "krux": {
+ "pins": {
+ "BUTTON_A": 25,
+ "BUTTON_B": 31,
+ "TOUCH_IRQ": 26,
+ "TOUCH_RESET": 29,
+ "I2C_SDA": 27,
+ "I2C_SCL": 24,
+ "BACKLIGHT": 22,
+ },
+ "display": {"touch": True, "font": [8, 16], "font_wide": [16, 16]},
+ },
+ }
+ )
+
+
def mock_context(mocker):
import board
@@ -669,17 +743,18 @@ def mock_context(mocker):
font_width=8,
font_height=14,
total_lines=17, # 240 / 14
- width=mocker.MagicMock(return_value=135),
- height=mocker.MagicMock(return_value=240),
- usable_width=mocker.MagicMock(return_value=(135 - 2 * 10)),
- usable_pixels_in_line=mocker.MagicMock(return_value=135),
- ascii_chars_per_line=mocker.MagicMock(return_value=135 // 8),
+ width=mocker.MagicMock(return_value=M5STICKV_WIDTH),
+ height=mocker.MagicMock(return_value=M5STICKV_HEIGHT),
+ usable_width=mocker.MagicMock(return_value=M5STICKV_USABLE_WIDTH),
+ usable_pixels_in_line=mocker.MagicMock(return_value=M5STICKV_WIDTH),
+ ascii_chars_per_line=mocker.MagicMock(return_value=M5STICKV_IN_LINE),
to_lines=mocker.MagicMock(return_value=[""]),
to_lines_endpos=mocker.MagicMock(return_value=([""], 0)),
max_menu_lines=mocker.MagicMock(return_value=7),
draw_hcentered_text=mocker.MagicMock(return_value=1),
),
)
+
elif board.config["type"] == "dock":
return mocker.MagicMock(
input=mocker.MagicMock(
@@ -693,11 +768,11 @@ def mock_context(mocker):
font_width=8,
font_height=16,
total_lines=20, # 320 / 16
- width=mocker.MagicMock(return_value=240),
- height=mocker.MagicMock(return_value=320),
- usable_width=mocker.MagicMock(return_value=(240 - 2 * 10)),
- usable_pixels_in_line=mocker.MagicMock(return_value=(240 - 2 * 10)),
- ascii_chars_per_line=mocker.MagicMock(return_value=(240 - 2 * 10) // 8),
+ width=mocker.MagicMock(return_value=DOCK_WIDTH),
+ height=mocker.MagicMock(return_value=DOCK_HEIGHT),
+ usable_width=mocker.MagicMock(return_value=DOCK_USABLE_WIDTH),
+ usable_pixels_in_line=mocker.MagicMock(return_value=DOCK_USABLE_WIDTH),
+ ascii_chars_per_line=mocker.MagicMock(return_value=DOCK_IN_LINE),
to_lines=mocker.MagicMock(return_value=[""]),
to_lines_endpos=mocker.MagicMock(return_value=([""], 0)),
max_menu_lines=mocker.MagicMock(return_value=9),
@@ -705,6 +780,7 @@ def mock_context(mocker):
),
light=None,
)
+
elif board.config["type"] == "amigo":
return mocker.MagicMock(
input=mocker.MagicMock(
@@ -718,19 +794,18 @@ def mock_context(mocker):
font_width=12,
font_height=24,
total_lines=20, # 480 / 24
- width=mocker.MagicMock(return_value=320),
- height=mocker.MagicMock(return_value=480),
- usable_width=mocker.MagicMock(return_value=(320 - 2 * 10)),
- usable_pixels_in_line=mocker.MagicMock(return_value=(320 - 2 * 10)),
- ascii_chars_per_line=mocker.MagicMock(
- return_value=(320 - 2 * 10) // 12
- ),
+ width=mocker.MagicMock(return_value=AMIGO_WIDTH),
+ height=mocker.MagicMock(return_value=AMIGO_HEIGHT),
+ usable_width=mocker.MagicMock(return_value=AMIGO_USABLE_WIDTH),
+ usable_pixels_in_line=mocker.MagicMock(return_value=AMIGO_USABLE_WIDTH),
+ ascii_chars_per_line=mocker.MagicMock(return_value=AMIGO_IN_LINE),
to_lines=mocker.MagicMock(return_value=[""]),
to_lines_endpos=mocker.MagicMock(return_value=([""], 0)),
max_menu_lines=mocker.MagicMock(return_value=9),
draw_hcentered_text=mocker.MagicMock(return_value=1),
),
)
+
elif board.config["type"] == "cube":
return mocker.MagicMock(
input=mocker.MagicMock(
@@ -744,11 +819,11 @@ def mock_context(mocker):
font_width=8,
font_height=14,
total_lines=17, # 240 / 14
- width=mocker.MagicMock(return_value=240),
- height=mocker.MagicMock(return_value=240),
- usable_width=mocker.MagicMock(return_value=(240 - 2 * 10)),
- usable_pixels_in_line=mocker.MagicMock(return_value=(240 - 2 * 10)),
- ascii_chars_per_line=mocker.MagicMock(return_value=(240 - 2 * 10) // 8),
+ width=mocker.MagicMock(return_value=CUBE_WIDTH),
+ height=mocker.MagicMock(return_value=CUBE_HEIGHT),
+ usable_width=mocker.MagicMock(return_value=CUBE_USABLE_WIDTH),
+ usable_pixels_in_line=mocker.MagicMock(return_value=CUBE_USABLE_WIDTH),
+ ascii_chars_per_line=mocker.MagicMock(return_value=CUBE_IN_LINE),
to_lines=mocker.MagicMock(return_value=[""]),
to_lines_endpos=mocker.MagicMock(return_value=([""], 0)),
max_menu_lines=mocker.MagicMock(return_value=7),
@@ -756,6 +831,7 @@ def mock_context(mocker):
),
light=None,
)
+
elif board.config["type"] == "yahboom":
return mocker.MagicMock(
input=mocker.MagicMock(
@@ -769,17 +845,18 @@ def mock_context(mocker):
font_width=8,
font_height=16,
total_lines=20, # 320 / 16
- width=mocker.MagicMock(return_value=240),
- height=mocker.MagicMock(return_value=320),
- usable_width=mocker.MagicMock(return_value=(240 - 2 * 10)),
- usable_pixels_in_line=mocker.MagicMock(return_value=(240 - 2 * 10)),
- ascii_chars_per_line=mocker.MagicMock(return_value=(240 - 2 * 10) // 8),
+ width=mocker.MagicMock(return_value=DOCK_WIDTH),
+ height=mocker.MagicMock(return_value=DOCK_HEIGHT),
+ usable_width=mocker.MagicMock(return_value=DOCK_USABLE_WIDTH),
+ usable_pixels_in_line=mocker.MagicMock(return_value=DOCK_USABLE_WIDTH),
+ ascii_chars_per_line=mocker.MagicMock(return_value=DOCK_IN_LINE),
to_lines=mocker.MagicMock(return_value=[""]),
to_lines_endpos=mocker.MagicMock(return_value=([""], 0)),
max_menu_lines=mocker.MagicMock(return_value=9),
draw_hcentered_text=mocker.MagicMock(return_value=1),
),
)
+
elif board.config["type"] == "wonder_mv":
return mocker.MagicMock(
input=mocker.MagicMock(
@@ -793,11 +870,11 @@ def mock_context(mocker):
font_width=8,
font_height=16,
total_lines=20, # 320 / 16
- width=mocker.MagicMock(return_value=240),
- height=mocker.MagicMock(return_value=320),
- usable_width=mocker.MagicMock(return_value=(240 - 2 * 10)),
- usable_pixels_in_line=mocker.MagicMock(return_value=(240 - 2 * 10)),
- ascii_chars_per_line=mocker.MagicMock(return_value=(240 - 2 * 10) // 8),
+ width=mocker.MagicMock(return_value=DOCK_WIDTH),
+ height=mocker.MagicMock(return_value=DOCK_HEIGHT),
+ usable_width=mocker.MagicMock(return_value=DOCK_USABLE_WIDTH),
+ usable_pixels_in_line=mocker.MagicMock(return_value=DOCK_USABLE_WIDTH),
+ ascii_chars_per_line=mocker.MagicMock(return_value=DOCK_IN_LINE),
to_lines=mocker.MagicMock(return_value=[""]),
to_lines_endpos=mocker.MagicMock(return_value=([""], 0)),
max_menu_lines=mocker.MagicMock(return_value=9),
@@ -818,12 +895,37 @@ def mock_context(mocker):
font_width=8,
font_height=16,
total_lines=20, # 320 / 16
- width=mocker.MagicMock(return_value=240),
- height=mocker.MagicMock(return_value=320),
- usable_width=mocker.MagicMock(return_value=(240 - 2 * 10)),
- usable_pixels_in_line=mocker.MagicMock(return_value=(240 - 2 * 10)),
- ascii_chars_per_line=mocker.MagicMock(return_value=(240 - 2 * 10) // 8),
+ width=mocker.MagicMock(return_value=DOCK_WIDTH),
+ height=mocker.MagicMock(return_value=DOCK_HEIGHT),
+ usable_width=mocker.MagicMock(return_value=DOCK_USABLE_WIDTH),
+ usable_pixels_in_line=mocker.MagicMock(return_value=DOCK_USABLE_WIDTH),
+ ascii_chars_per_line=mocker.MagicMock(return_value=DOCK_IN_LINE),
+ to_lines=mocker.MagicMock(return_value=[""]),
+ max_menu_lines=mocker.MagicMock(return_value=9),
+ draw_hcentered_text=mocker.MagicMock(return_value=1),
+ ),
+ )
+
+ elif board.config["type"] == "wonder_k":
+ return mocker.MagicMock(
+ input=mocker.MagicMock(
+ touch=mocker.MagicMock(),
+ enter_event=mocker.MagicMock(return_value=False),
+ page_event=mocker.MagicMock(return_value=False),
+ page_prev_event=mocker.MagicMock(return_value=False),
+ touch_event=mocker.MagicMock(return_value=False),
+ ),
+ display=mocker.MagicMock(
+ font_width=8,
+ font_height=16,
+ total_lines=20, # 320 / 16
+ width=mocker.MagicMock(return_value=DOCK_WIDTH),
+ height=mocker.MagicMock(return_value=DOCK_HEIGHT),
+ usable_width=mocker.MagicMock(return_value=DOCK_USABLE_WIDTH),
+ usable_pixels_in_line=mocker.MagicMock(return_value=DOCK_USABLE_WIDTH),
+ ascii_chars_per_line=mocker.MagicMock(return_value=DOCK_IN_LINE),
to_lines=mocker.MagicMock(return_value=[""]),
+ to_lines_endpos=mocker.MagicMock(return_value=([""], 0)),
max_menu_lines=mocker.MagicMock(return_value=9),
draw_hcentered_text=mocker.MagicMock(return_value=1),
),
diff --git a/tests/test_camera.py b/tests/test_camera.py
index 4f04531..a35e171 100644
--- a/tests/test_camera.py
+++ b/tests/test_camera.py
@@ -1,4 +1,5 @@
import pytest
+from tests.conftest import wonder_k
def test_init(mocker, m5stickv):
@@ -42,14 +43,14 @@ def test_initialize_sensors(mocker, multiple_devices):
if config_method:
getattr(c, config_method).assert_called()
- if board.config["type"] == "cube" or c.cam_id == OV2640_ID:
+ if board.config["type"] in ("cube", "wonder_k") or c.cam_id == OV2640_ID:
krux.camera.sensor.set_vflip.assert_called_with(1)
else:
krux.camera.sensor.set_vflip.assert_not_called()
krux.camera.sensor.set_vflip.reset_mock()
- if board.config["type"] == "cube" or c.cam_id == OV5642_ID:
+ if board.config["type"] in ("cube", "wonder_k") or c.cam_id == OV5642_ID:
krux.camera.sensor.set_hmirror.assert_called_with(1)
else:
krux.camera.sensor.set_hmirror.assert_not_called()
diff --git a/tests/test_power.py b/tests/test_power.py
index 1f70981..43422ce 100644
--- a/tests/test_power.py
+++ b/tests/test_power.py
@@ -15,7 +15,7 @@ def test_pmu(mocker, multiple_devices):
manager = PowerManager()
- if board.config["type"] in ("dock", "yahboom", "wonder_mv", "bit"):
+ if board.config["type"] in ("dock", "yahboom", "wonder_mv", "bit", "wonder_k"):
assert manager.pmu is None
assert manager.has_battery() is False
else:
@@ -51,7 +51,7 @@ def test_charge_has_no_battery(mocker, multiple_devices):
assert not manager.has_battery()
manager.pmu.get_battery_voltage.assert_called_once()
- # Dock, Yahboom and WonderMV do not have battery
+ # Dock, Yahboom, WonderMV and WonderK do not have battery
# it just raises an exception and returns False
else:
with pytest.raises(AttributeError) as exc_info:
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.