Files
LihonT/tests/test_image_address.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

57 lines
2.1 KiB
Python

"""Run the turning of Commons picture addresses 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" / "ImageAddress.java"
HARNESS = ROOT / "tests" / "java" / "lihont" / "two" / "agent" / "ImageAddressTest.java"
class ImageAddressTest(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("Image address tests require a JDK with java and javac")
cls.temporary = tempfile.TemporaryDirectory(prefix="lihont-address-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.ImageAddressTest", name])
self.assertEqual(result.stdout.strip(), "PASS " + name)
def test_commons_files_become_png_previews(self):
self.run_scenario("commons")
def test_other_addresses_stay(self):
self.run_scenario("others")
if __name__ == "__main__":
unittest.main()