26 lines
838 B
Python
26 lines
838 B
Python
import unittest
|
|
|
|
import httpx
|
|
|
|
from app.llm.http_client import _mask_proxy_url, build_openrouter_http_client
|
|
|
|
|
|
class LlmProxyTests(unittest.TestCase):
|
|
def test_build_client_without_proxy(self) -> None:
|
|
self.assertIsNone(build_openrouter_http_client(""))
|
|
self.assertIsNone(build_openrouter_http_client(" "))
|
|
|
|
def test_build_client_with_proxy(self) -> None:
|
|
client = build_openrouter_http_client("socks5://127.0.0.1:1080")
|
|
self.assertIsInstance(client, httpx.AsyncClient)
|
|
|
|
def test_mask_proxy_url(self) -> None:
|
|
self.assertEqual(
|
|
_mask_proxy_url("socks5://user:secret@proxy.local:1080"),
|
|
"socks5://***@proxy.local:1080",
|
|
)
|
|
self.assertEqual(
|
|
_mask_proxy_url("socks5://127.0.0.1:1080"),
|
|
"socks5://127.0.0.1:1080",
|
|
)
|