Files
LihonT/tests/test_card_plan.py
cheb0chik b78266d40c LihonT 3 Luna beta 1: the site look, the floating island, full-screen video and the agent
The "Как сайт" look by default, also in TikTok's settings and all their sub-pages, where every item is its own rounded row.
The bottom bar floats as an island, 9:16 videos reach under it, the seek bar is lifted, thicker and on by default, the
comment input is an island too, and "only sound" downloads are saved as audio. The LihonT agent: a chat that makes cards and
slides for a photo post, looks things up on the web, signs in with Telegram and has a daily limit on the server. Also the
нейронка.рус landing page and the 3D-phone promo scripts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 16:10:45 +03:00

66 lines
2.2 KiB
Python

"""Run the reading of a model's card answer on a real JVM."""
import os
from pathlib import Path
import shutil
import subprocess
import tempfile
import unittest
ROOT = Path(__file__).resolve().parents[1]
SOURCE = ROOT / "src" / "lihont" / "two" / "agent" / "CardPlan.java"
HARNESS = ROOT / "tests" / "java" / "lihont" / "two" / "agent" / "CardPlanTest.java"
class CardPlanTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.javac = shutil.which("javac")
cls.java = shutil.which("java")
if not cls.javac or not cls.java:
raise RuntimeError("Card plan tests require a JDK with java and javac")
cls.temporary = tempfile.TemporaryDirectory(prefix="lihont-cards-tests-")
cls.addClassCleanup(cls.temporary.cleanup)
cls.classes = Path(cls.temporary.name) / "classes"
cls.classes.mkdir()
cls.environment = dict(os.environ)
cls.environment.pop("JAVA_TOOL_OPTIONS", None)
cls.run_command([
cls.javac, "--release", "17", "-encoding", "UTF-8", "-Xlint:all", "-Werror",
"-d", str(cls.classes), str(SOURCE), str(HARNESS),
])
@classmethod
def run_command(cls, command):
result = subprocess.run(command, capture_output=True, text=True, encoding="utf-8",
env=cls.environment, timeout=120)
if result.returncode:
raise AssertionError(f"Command failed with exit {result.returncode}: {command[0]}\n"
+ result.stdout + result.stderr)
return result
def run_scenario(self, name):
result = self.run_command([self.java, "-Dfile.encoding=UTF-8", "-cp", str(self.classes),
"lihont.two.agent.CardPlanTest", name])
self.assertEqual(result.stdout.strip(), "PASS " + name)
def test_a_clean_answer(self):
self.run_scenario("plain")
def test_a_messy_answer(self):
self.run_scenario("messy")
def test_limits(self):
self.run_scenario("limits")
def test_pictures_in_cards(self):
self.run_scenario("images")
def test_the_words_without_the_block(self):
self.run_scenario("prose")
if __name__ == "__main__":
unittest.main()