From a5641700ed892e47b904e7acfc8a2085a1f1a300 Mon Sep 17 00:00:00 2001 From: Dark_Avery Date: Mon, 30 Mar 2026 17:18:44 +0300 Subject: [PATCH] test(android): cover bridge startup without cryptography --- tests/test_android_proxy_bridge.py | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/test_android_proxy_bridge.py b/tests/test_android_proxy_bridge.py index ab10293..09a7b50 100644 --- a/tests/test_android_proxy_bridge.py +++ b/tests/test_android_proxy_bridge.py @@ -1,6 +1,7 @@ import sys import unittest import json +import subprocess from pathlib import Path @@ -226,6 +227,38 @@ class AndroidProxyBridgeTests(unittest.TestCase): self.assertEqual(result["error"], "") self.assertEqual(result["html_url"], "https://example.com/releases/latest") + def test_android_bridge_import_and_update_status_work_without_cryptography(self): + root = Path(__file__).resolve().parents[1] + script = f""" +import importlib.abc +import sys +from pathlib import Path + +root = Path({str(root)!r}) +sys.path.insert(0, str(root / "android" / "app" / "src" / "main" / "python")) +sys.path.insert(0, str(root)) + +class BlockCryptography(importlib.abc.MetaPathFinder): + def find_spec(self, fullname, path, target=None): + if fullname == "cryptography" or fullname.startswith("cryptography."): + raise ModuleNotFoundError("No module named 'cryptography'") + return None + +sys.meta_path.insert(0, BlockCryptography()) + +import android_proxy_bridge +print(android_proxy_bridge.get_update_status_json(False)) +""" + result = subprocess.run( + [sys.executable, "-c", script], + check=True, + capture_output=True, + text=True, + ) + payload = json.loads(result.stdout.strip()) + self.assertEqual(payload["current_version"], android_proxy_bridge.__version__) + self.assertEqual(payload["error"], "") + if __name__ == "__main__": unittest.main()