prole/tests/installer/test_screen.py
chrisfu 906392d462 feat(installer): improve UI and add test coverage for core features
- Refactored installer UI with updated canvas rendering, sidebar navigation, and footer buttons.
- Enhanced styling for macOS compatibility and consistent design across controls.
- Added Pytest-based unit tests for `screen.py` and `config.py`.
- Expanded dependency catalog with new tools like `tshark` and `pyshark`.
- Improved error tolerance for background rendering and added placeholders for Kerberos configuration.
2026-01-08 21:51:30 -08:00

49 lines
1.6 KiB
Python

import pytest
from unittest.mock import MagicMock, patch
import tkinter as tk
from installer.screen import render_title, render_paragraph, TerminalConsole
@pytest.fixture
def mock_app():
app = MagicMock()
app.bg_canvas = MagicMock()
app._canvas_items = []
return app
def test_render_title(mock_app):
render_title(mock_app, "Test Title", y=50)
mock_app.bg_canvas.create_text.assert_called_once()
args, kwargs = mock_app.bg_canvas.create_text.call_args
assert args == (48, 50)
assert kwargs['text'] == "Test Title"
assert len(mock_app._canvas_items) == 1
def test_render_paragraph(mock_app):
render_paragraph(mock_app, "Test Paragraph", y=100)
mock_app.bg_canvas.create_text.assert_called_once()
args, kwargs = mock_app.bg_canvas.create_text.call_args
assert args == (48, 100)
assert kwargs['text'] == "Test Paragraph"
assert len(mock_app._canvas_items) == 1
def test_render_title_no_canvas():
app = MagicMock()
app.bg_canvas = None
render_title(app, "Title")
# Should not raise exception
@patch('platform.system', return_value='Darwin')
def test_terminal_console(mock_platform):
root = tk.Tk()
try:
console = TerminalConsole(root)
console.write("Hello\n")
# In mock or headless env, we might not be able to check text content easily
# but we can verify it doesn't crash and state is managed
assert console.text.cget('state') == 'disabled'
console.clear()
assert console.text.cget('state') == 'disabled'
finally:
root.destroy()