Files
Rpa_Skills/tests/test_run_tab.py
T
VasanthandClaude Opus 5.5 258bfbb500 Add rpa-run-tab skill: Tebra-style Run tab in 5 minutes
The Run tab from Tebra Auto Post, scrubbed and themable (Tebra Sky, TVL Teal,
or a custom hex checked for contrast). The skill wires the real bot through
tagged log-file lines and checks itself with a fake bot (complete, partial,
stuck, crash) plus light and dark screenshots. Grill decisions R1-R14 are in
PLAN.md, terms in GLOSSARY.md, and ADRs 0001-0003.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 16:29:18 +05:30

50 lines
2.3 KiB
Python

"""Run tab Python pieces: line parsing, endings, sheet reading, sample workbook, theme writing."""
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
T = ROOT / "rpa-run-tab" / "templates"
sys.path.insert(0, str(T))
import runner # noqa: E402
def test_parse_lines():
assert runner.parse("[CPSTATE] active 3") == ("cpstate", {"kind": "active", "cp": 3})
assert runner.parse("[UI:ok] Signed in") == ("log", {"msg": "Signed in", "type": "success"})
assert runner.parse("[UI] Opening list") == ("log", {"msg": "Opening list", "type": "info"})
assert runner.parse("ValueError: bad row") == ("log", {"msg": "ValueError: bad row", "type": "error"})
assert runner.parse("debug: clicked button 4") is None
assert runner.parse(' File "bot.py", line 3') is None
def test_outcomes():
assert runner.outcome({"total": 3, "failed": []})[0] == "done"
assert runner.outcome({"total": 3, "failed": [["a", "x"]]}) == ("partial", "Finished: 1 of 3 failed")
assert runner.outcome({"total": 1, "failed": [["a", "x"]]})[0] == "error"
assert runner.outcome(None)[0] == "error"
assert runner.outcome({"total": 3}, stuck_name="Sign in") == ("error", "Stuck at Sign in, run again")
def test_sample_and_sheet_reading(tmp_path, monkeypatch):
monkeypatch.setattr(sys, "argv", ["x"])
pytest_qt = __import__("importlib").util.find_spec("PyQt6.QtWebEngineWidgets")
if pytest_qt is None:
import pytest
pytest.skip("PyQt6-WebEngine not installed")
import run_tab
out = tmp_path / "sample.xlsx"
run_tab.build_sample(out, {"Accounts": ["Account", "Password"]})
header, rows, more = run_tab.read_sheet_rows(out, "Accounts")
assert header == ["Account", "Password"] and rows == [["Example Account", "Example Password"]] and not more
def test_palette_writes_theme(tmp_path):
page = tmp_path / "run_tab.html"
page.write_text((T / "run_tab.html").read_text(encoding="utf-8"), encoding="utf-8")
r = subprocess.run([sys.executable, str(T / "palette.py"), "#7a3cff", "--write", str(page)],
capture_output=True, text=True)
assert r.returncode == 0, r.stdout + r.stderr
html = page.read_text(encoding="utf-8")
assert "--accent-rgb:122,60,255" in html and html.count("THEME:START") == 1