mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-11 19:45:06 +00:00
fix(proxies): return None for unservable queries and repair live providers
Basic, NordVPN, Windscribe, Gluetun and Hola no longer raise on a query they cannot serve. Hola parses stdout only and reports a ban; NordVPN cities use the API filter; uk maps to gb.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
"""Unit tests for the Basic proxy provider: a query it cannot serve returns None so a bare query moves on."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from unshackle.core.proxies import Basic
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def basic() -> Basic:
|
||||
return Basic(us=["http://one.example:8080", "http://two.example:8080"], gb="http://gb.example:8080")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("query", "expected"), [("us1", "http://one.example:8080"), ("US2", "http://two.example:8080")]
|
||||
)
|
||||
def test_numbered_entry(basic: Basic, query: str, expected: str) -> None:
|
||||
assert basic.get_proxy(query) == expected
|
||||
|
||||
|
||||
def test_single_entry_region(basic: Basic) -> None:
|
||||
assert basic.get_proxy("gb") == "http://gb.example:8080"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("query", ["us-bos", "yul", "us:seattle", "us150", "us0", "ca"])
|
||||
def test_query_it_cannot_serve_returns_none(basic: Basic, query: str) -> None:
|
||||
assert basic.get_proxy(query) is None
|
||||
Reference in New Issue
Block a user