Download tests/test_static_space.py from pedroivospatial/pis-spatial-intelligence-lab: direct link, hf CLI and curl.
- Browser
- Download file 2.26 kB
-
https://huggingface.co/spaces/pedroivospatial/pis-spatial-intelligence-lab/resolve/main/tests/test_static_space.py
- Command line
-
hf download hf://spaces/pedroivospatial/pis-spatial-intelligence-lab/tests/test_static_space.py
-
curl -L -o test_static_space.py https://huggingface.co/spaces/pedroivospatial/pis-spatial-intelligence-lab/resolve/main/tests/test_static_space.py
2.26 kB
| import hashlib | |
| import json | |
| import pathlib | |
| import unittest | |
| ROOT = pathlib.Path(__file__).resolve().parents[1] | |
| class StaticSpaceTests(unittest.TestCase): | |
| def setUp(self): | |
| self.manifest = json.loads( | |
| (ROOT / "static" / "results.json").read_text(encoding="utf-8") | |
| ) | |
| def test_manifest_is_static_synthetic_and_complete(self): | |
| self.assertEqual(self.manifest["mode"], "static_precomputed_demonstration") | |
| self.assertFalse(self.manifest["live_inference"]) | |
| self.assertTrue(self.manifest["synthetic_only"]) | |
| self.assertEqual(self.manifest["stored_client_data"], "none") | |
| self.assertEqual(len(self.manifest["scenes"]), 3) | |
| def test_static_assets_match_recorded_hashes(self): | |
| for scene in self.manifest["scenes"]: | |
| for field in ("source", "depth"): | |
| path = ROOT / scene[field] | |
| self.assertTrue(path.is_file(), path) | |
| digest = hashlib.sha256(path.read_bytes()).hexdigest() | |
| self.assertEqual(digest, scene[f"{field}_sha256"]) | |
| def test_page_exposes_no_submission_controls_or_remote_runtime(self): | |
| html = (ROOT / "index.html").read_text(encoding="utf-8").lower() | |
| script = (ROOT / "app-static.js").read_text(encoding="utf-8").lower() | |
| self.assertNotIn("<form", html) | |
| self.assertNotIn("<input", html) | |
| self.assertNotIn("<textarea", html) | |
| self.assertNotIn("type=\"file\"", html) | |
| self.assertIn('fetch("static/results.json"', script) | |
| self.assertNotIn("api-inference", script) | |
| self.assertNotIn("gradio_client", script) | |
| def test_preserved_gradio_sources_match_reviewed_hashes(self): | |
| expected = { | |
| "app.py": "5a17d5039fb1e77117ac80c104e8042a9154e1154d4dd49a02fb1b30f9199327", | |
| "lab_core.py": "77e61aadae335b45526befb50d6766dc22a8ba8add91a2183b34beebcaeca21d", | |
| "requirements.txt": "f289ae35c0e40ef77a94f2ed0cb2830fba563c02ce3594195b4c8b1d5880c561", | |
| } | |
| for relative_path, expected_hash in expected.items(): | |
| digest = hashlib.sha256((ROOT / relative_path).read_bytes()).hexdigest() | |
| self.assertEqual(digest, expected_hash) | |
| if __name__ == "__main__": | |
| unittest.main() | |