cat / goq
clone

turns a linux box into a private steam streaming appliance: plug in, tap your key, play from another computer

release/portal-packaging
goq / scripts / tests / test_decky_package.py
test_decky_package.py 2.5K
1from __future__ import annotations23import hashlib4import json5import os6import pathlib7import subprocess8import sys9import tempfile10import unittest11import zipfile121314REPOSITORY = pathlib.Path(__file__).resolve().parents[2]15PACKAGER = REPOSITORY / "scripts/package-decky-plugin.py"16COMMIT = "a" * 40171819class DeckyPackageTests(unittest.TestCase):20 def build(self, output: pathlib.Path) -> pathlib.Path:21 environment = dict(os.environ)22 environment["GOQ_SOURCE_COMMIT"] = COMMIT23 environment["GOQ_PACKAGE_TESTING"] = "1"24 subprocess.run(25 [sys.executable, str(PACKAGER), str(output)],26 cwd=REPOSITORY,27 env=environment,28 check=True,29 stdout=subprocess.PIPE,30 stderr=subprocess.PIPE,31 timeout=10,32 )33 return output / "goq-sigil-v0.1.0.zip"3435 def test_archive_is_deterministic_bounded_and_provenance_bound(self):36 with tempfile.TemporaryDirectory() as first, tempfile.TemporaryDirectory() as second:37 first_archive = self.build(pathlib.Path(first))38 second_archive = self.build(pathlib.Path(second))39 self.assertEqual(40 hashlib.sha256(first_archive.read_bytes()).digest(),41 hashlib.sha256(second_archive.read_bytes()).digest(),42 )43 with zipfile.ZipFile(first_archive) as archive:44 names = archive.namelist()45 self.assertEqual(names, sorted(names))46 self.assertIn("goq-sigil/dist/index.js", names)47 self.assertIn("goq-sigil/main.py", names)48 self.assertFalse(any("tests/" in name for name in names))49 self.assertFalse(any(name.endswith((".toml", ".key")) for name in names))50 provenance = json.loads(51 archive.read("goq-sigil/provenance.json").decode("utf-8")52 )53 self.assertEqual(provenance["source_commit"], COMMIT)54 self.assertEqual(55 provenance["compatibility"]["compatibility_basis"], "schema_probe"56 )57 self.assertEqual(provenance["compatibility"]["appliance_status_schema"], 2)58 self.assertTrue(provenance["package_inputs_clean"])59 self.assertNotIn("source_tree_clean", provenance)60 self.assertEqual(61 provenance["files"]["dist/index.js"],62 hashlib.sha256(archive.read("goq-sigil/dist/index.js")).hexdigest(),63 )646566if __name__ == "__main__":67 unittest.main()