mirror of
https://github.com/Flowseal/tg-ws-proxy.git
synced 2026-05-26 17:31:43 +03:00
fix(android): normalize Chaquopy Java list inputs for proxy config
This commit is contained in:
50
tests/test_android_proxy_bridge.py
Normal file
50
tests/test_android_proxy_bridge.py
Normal file
@@ -0,0 +1,50 @@
|
||||
import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
sys.path.insert(0, str(
|
||||
Path(__file__).resolve().parents[1] / "android" / "app" / "src" / "main" / "python"
|
||||
))
|
||||
|
||||
import android_proxy_bridge # noqa: E402
|
||||
|
||||
|
||||
class FakeJavaArrayList:
|
||||
def __init__(self, items):
|
||||
self._items = list(items)
|
||||
|
||||
def size(self):
|
||||
return len(self._items)
|
||||
|
||||
def get(self, index):
|
||||
return self._items[index]
|
||||
|
||||
|
||||
class AndroidProxyBridgeTests(unittest.TestCase):
|
||||
def test_normalize_dc_ip_list_with_python_iterable(self):
|
||||
result = android_proxy_bridge._normalize_dc_ip_list([
|
||||
"2:149.154.167.220",
|
||||
" ",
|
||||
"4:149.154.167.220 ",
|
||||
])
|
||||
|
||||
self.assertEqual(result, [
|
||||
"2:149.154.167.220",
|
||||
"4:149.154.167.220",
|
||||
])
|
||||
|
||||
def test_normalize_dc_ip_list_with_java_array_list_shape(self):
|
||||
result = android_proxy_bridge._normalize_dc_ip_list(FakeJavaArrayList([
|
||||
"2:149.154.167.220",
|
||||
"4:149.154.167.220",
|
||||
]))
|
||||
|
||||
self.assertEqual(result, [
|
||||
"2:149.154.167.220",
|
||||
"4:149.154.167.220",
|
||||
])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user