Files
Yuvomi-App/scripts/test-integration-evidence.py
T
Yuvomi Mobile Contributors 1433e1670a ci: collect native APK and screenshot evidence on Gitea
Bootstrap checksum-pinned ARM64 Node before Mac checkout, upload a dedicated installable native debug APK, collect AGP test output before UTP uninstall and reject stale/missing screenshots. Add five screenshot-output regressions and enforce native shipping-source invariants. Workflow lint, 10 runner and 8 JUnit verifier regressions pass; remote execution is not yet verified.
2026-10-21 09:12:56 +02:00

63 lines
2.8 KiB
Python

#!/usr/bin/env python3
"""Regressions for AGP screenshot output collection, not visual parity tests."""
import base64
import importlib.util
from pathlib import Path
import tempfile
import unittest
SPEC = importlib.util.spec_from_file_location("integration", Path(__file__).with_name("test-integration.py"))
HARNESS = importlib.util.module_from_spec(SPEC)
SPEC.loader.exec_module(HARNESS)
PNG = base64.b64decode("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+jJ1sAAAAASUVORK5CYII=")
class ScreenshotEvidenceTests(unittest.TestCase):
def setUp(self):
base = "/tmp/opencode" if Path("/tmp/opencode").exists() else None
self.temporary = tempfile.TemporaryDirectory(prefix="yuvomi-evidence-", dir=base)
self.addCleanup(self.temporary.cleanup)
self.output = Path(self.temporary.name)
self.additional, self.screenshots = HARNESS.prepare_android_screenshots(self.output)
def fixture(self, device="fixture(AVD) - 15", contents=PNG):
image = self.additional / "connected" / device / "native-dashboard.png"
image.parent.mkdir(parents=True, exist_ok=True)
image.write_bytes(contents)
return image
def test_collects_actual_agp_variant_path_without_adb_or_installed_app(self):
image = self.fixture()
HARNESS.collect_native_screenshot(self.additional, self.screenshots)
self.assertEqual((self.screenshots / image.name).read_bytes(), PNG)
self.assertEqual(self.additional.name, "integrationAndroidTest")
def test_missing_screenshot_is_not_success(self):
with self.assertRaisesRegex(AssertionError, "Missing or ambiguous"):
HARNESS.collect_native_screenshot(self.additional, self.screenshots)
def test_rejects_run_as_error_even_when_command_reported_zero_exit(self):
self.fixture(contents=b"run-as: unknown package: community.yuvomi.mobile.integration\n")
with self.assertRaisesRegex(AssertionError, "Invalid native"):
HARNESS.collect_native_screenshot(self.additional, self.screenshots)
def test_rejects_ambiguous_device_evidence(self):
self.fixture("first")
self.fixture("second")
with self.assertRaisesRegex(AssertionError, "ambiguous"):
HARNESS.collect_native_screenshot(self.additional, self.screenshots)
def test_preparation_removes_only_known_stale_capture(self):
image = self.fixture()
HARNESS.collect_native_screenshot(self.additional, self.screenshots)
unrelated = image.with_name("other-output.txt")
unrelated.write_text("preserve")
HARNESS.prepare_android_screenshots(self.output)
self.assertFalse(image.exists())
self.assertFalse((self.screenshots / image.name).exists())
self.assertEqual(unrelated.read_text(), "preserve")
if __name__ == "__main__":
unittest.main()