A catalog app for the LihonT mod: avatar frames and chat bubbles made by members. Browse, add with the plus button, author profiles, publishing with a check before anything is shown. Signs in through the TikTok that carries the mod, which hands over only the public account data to an app signed with the same key. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
40 lines
1.5 KiB
Python
40 lines
1.5 KiB
Python
"""The picture maths of LihonT Store (a photo becomes a ring, pictures are fitted) on a real JVM. Needs a JDK: py -m unittest discover tests"""
|
|
|
|
import shutil
|
|
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
CUT = ROOT / "src" / "lihonstore" / "app" / "Cut.java"
|
|
CASE = ROOT / "tests" / "lihonstore" / "app" / "CutTest.java"
|
|
|
|
|
|
class CutTest(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
cls.javac, cls.java = shutil.which("javac"), shutil.which("java")
|
|
if not cls.javac or not cls.java:
|
|
raise RuntimeError("these tests need a JDK")
|
|
cls.temporary = tempfile.TemporaryDirectory(prefix="lihonstore-tests-")
|
|
cls.addClassCleanup(cls.temporary.cleanup)
|
|
cls.classes = Path(cls.temporary.name)
|
|
done = subprocess.run([cls.javac, "-encoding", "UTF-8", "-d", str(cls.classes), str(CUT), str(CASE)], capture_output=True, text=True)
|
|
if done.returncode != 0:
|
|
raise RuntimeError(done.stdout + done.stderr)
|
|
|
|
def scenario(self, name):
|
|
done = subprocess.run([self.java, "-cp", str(self.classes), "lihonstore.app.CutTest", name], capture_output=True, text=True, timeout=60)
|
|
self.assertEqual(done.stdout.strip(), "PASS " + name, done.stdout + done.stderr)
|
|
|
|
def test_a_photo_becomes_a_ring_and_a_frame_is_kept(self):
|
|
self.scenario("ring")
|
|
|
|
def test_pictures_are_fitted_without_enlarging(self):
|
|
self.scenario("fit")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|