mirror of
https://github.com/dredx/prole.git
synced 2026-09-23 11:03:59 +00:00
- Add build-context helper to copy Docker context safely (ignore runtime data, keep symlinks) - Update UI and core actions to use ~/.prole/build and shared copy helper - Add/adjust tests and scripts; introduce knoe ops helpers and update manifests Co-authored-by: Junie <junie@jetbrains.com>
63 lines
1.8 KiB
Python
63 lines
1.8 KiB
Python
import pytest
|
|
from unittest.mock import MagicMock, patch
|
|
import tkinter as tk
|
|
from knoe.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):
|
|
import sys
|
|
from unittest.mock import MagicMock as _MM
|
|
|
|
# TerminalConsole requires a real tkinter root; skip when tkinter is mocked.
|
|
if isinstance(sys.modules.get("tkinter"), _MM):
|
|
pytest.skip("tkinter is mocked in this test run; TerminalConsole needs real tkinter")
|
|
|
|
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()
|
|
|
|
|