feat: add ACTIVE_THEME global and set_active_theme() to config
This commit is contained in:
@@ -7,6 +7,8 @@ import tempfile
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from engine import config
|
||||
|
||||
|
||||
@@ -160,3 +162,55 @@ class TestSetFontSelection:
|
||||
config.set_font_selection(font_path=None, font_index=None)
|
||||
assert original_path == config.FONT_PATH
|
||||
assert original_index == config.FONT_INDEX
|
||||
|
||||
|
||||
class TestActiveTheme:
|
||||
"""Tests for ACTIVE_THEME global and set_active_theme function."""
|
||||
|
||||
def test_active_theme_initially_none(self):
|
||||
"""ACTIVE_THEME should be None at module start."""
|
||||
# Reset to None to test initial state
|
||||
original = config.ACTIVE_THEME
|
||||
config.ACTIVE_THEME = None
|
||||
try:
|
||||
assert config.ACTIVE_THEME is None
|
||||
finally:
|
||||
config.ACTIVE_THEME = original
|
||||
|
||||
def test_set_active_theme_green(self):
|
||||
"""Setting green theme works correctly."""
|
||||
config.set_active_theme("green")
|
||||
assert config.ACTIVE_THEME is not None
|
||||
assert config.ACTIVE_THEME.name == "green"
|
||||
assert len(config.ACTIVE_THEME.main_gradient) == 12
|
||||
assert len(config.ACTIVE_THEME.message_gradient) == 12
|
||||
|
||||
def test_set_active_theme_default(self):
|
||||
"""Default theme is green when not specified."""
|
||||
config.set_active_theme()
|
||||
assert config.ACTIVE_THEME is not None
|
||||
assert config.ACTIVE_THEME.name == "green"
|
||||
|
||||
def test_set_active_theme_invalid(self):
|
||||
"""Invalid theme_id raises KeyError."""
|
||||
with pytest.raises(KeyError):
|
||||
config.set_active_theme("nonexistent")
|
||||
|
||||
def test_set_active_theme_all_themes(self):
|
||||
"""Verify orange and purple themes work."""
|
||||
# Test orange
|
||||
config.set_active_theme("orange")
|
||||
assert config.ACTIVE_THEME.name == "orange"
|
||||
|
||||
# Test purple
|
||||
config.set_active_theme("purple")
|
||||
assert config.ACTIVE_THEME.name == "purple"
|
||||
|
||||
def test_set_active_theme_idempotent(self):
|
||||
"""Calling set_active_theme multiple times works."""
|
||||
config.set_active_theme("green")
|
||||
first_theme = config.ACTIVE_THEME
|
||||
config.set_active_theme("green")
|
||||
second_theme = config.ACTIVE_THEME
|
||||
assert first_theme.name == second_theme.name
|
||||
assert first_theme.name == "green"
|
||||
|
||||
Reference in New Issue
Block a user