32 lines
822 B
Python
32 lines
822 B
Python
import asyncio
|
|
from datetime import datetime
|
|
|
|
import pytest
|
|
|
|
from proxy_pool.plugins.builtin.checkers.tcp_connect import TcpConnectChecker
|
|
from proxy_pool.plugins.protocols import CheckContext
|
|
|
|
|
|
@pytest.fixture
|
|
def checker():
|
|
return TcpConnectChecker(timeout=2.0)
|
|
|
|
|
|
@pytest.fixture
|
|
def context():
|
|
return CheckContext(
|
|
started_at=datetime.now(),
|
|
http_client=None,
|
|
)
|
|
|
|
|
|
class TestTcpConnect:
|
|
async def test_fails_on_unreachable_host(self, checker, context):
|
|
result = await checker.check("192.0.2.1", 1, "http", context)
|
|
|
|
assert result.passed is False
|
|
assert "timed out" in result.detail or "failed" in result.detail
|
|
|
|
async def test_never_skips(self, checker):
|
|
assert checker.should_skip("http") is False
|
|
assert checker.should_skip("socks5") is False |