b6caca4096
Replace positional args[3..5] assertions with assert_called_once_with using rounding=/thickness=/flags= kwargs to match the existing add_rect call in src/theme_nerv_fx.py:AlertPulsing.render and the parallel test in tests/test_theme_nerv_fx.py:TestThemeNervFx.test_alert_pulsing_render. Fixes test_alert_pulsing_render_active IndexError that surfaced when the positional contract was asserted against the kwargs-shaped production call.
44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
import pytest
|
|
from unittest.mock import MagicMock, patch
|
|
from imgui_bundle import imgui
|
|
from src.theme_nerv_fx import AlertPulsing
|
|
|
|
def test_alert_pulsing_update():
|
|
ap = AlertPulsing()
|
|
assert ap.active is False
|
|
|
|
ap.update("error: something failed")
|
|
assert ap.active is True
|
|
|
|
ap.update("ok: all good")
|
|
assert ap.active is False
|
|
|
|
ap.update("Error: Case Insensitive")
|
|
assert ap.active is True
|
|
|
|
def test_alert_pulsing_render_inactive():
|
|
ap = AlertPulsing()
|
|
ap.active = False
|
|
|
|
with patch("src.theme_nerv_fx.imgui.get_foreground_draw_list") as mock_get_draw_list:
|
|
ap.render(100.0, 100.0)
|
|
mock_get_draw_list.assert_not_called()
|
|
|
|
def test_alert_pulsing_render_active():
|
|
ap = AlertPulsing()
|
|
ap.active = True
|
|
|
|
mock_draw_list = MagicMock()
|
|
with patch("src.theme_nerv_fx.imgui.get_foreground_draw_list", return_value=mock_draw_list) as mock_get_draw_list, \
|
|
patch("src.theme_nerv_fx.imgui.get_color_u32", return_value=0xFF0000FF) as mock_get_color, \
|
|
patch("time.time", return_value=1.0):
|
|
|
|
ap.render(800.0, 600.0)
|
|
|
|
mock_get_draw_list.assert_called_once()
|
|
mock_get_color.assert_called_once()
|
|
mock_draw_list.add_rect.assert_called_once_with(
|
|
(0.0, 0.0), (800.0, 600.0), 0xFF0000FF,
|
|
rounding=0.0, thickness=10.0, flags=0
|
|
)
|