21437c78ad
Implements MihomoClient wrapping Mihomo's REST API with provider refresh polling, config reload, and startup readiness check. Also fixes a Python 3.14 + respx 0.21.1 compatibility issue where the httpcore mocker passes bytes method to httpx.Request causing Method pattern matching to fail; resolved by switching respx DEFAULT_MOCKER to the httpx-level mocker. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
27 lines
971 B
Python
27 lines
971 B
Python
import sys
|
|
import os
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
|
|
|
import respx.mocks
|
|
# Python 3.14 + httpx 0.28 compatibility: httpcore passes method as bytes,
|
|
# but the httpcore mocker reconstructs httpx.Request with bytes method,
|
|
# causing Method pattern comparison ('GET' == b'GET') to always fail.
|
|
# Use the httpx-level mocker instead, which patches AsyncClient._transport_for_url
|
|
# and avoids the bytes/str mismatch entirely.
|
|
respx.mocks.DEFAULT_MOCKER = "httpx"
|
|
|
|
import pytest_asyncio
|
|
from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker
|
|
from models import Base
|
|
|
|
|
|
@pytest_asyncio.fixture
|
|
async def db_session():
|
|
engine = create_async_engine("sqlite+aiosqlite:///:memory:")
|
|
async with engine.begin() as conn:
|
|
await conn.run_sync(Base.metadata.create_all)
|
|
Session = async_sessionmaker(engine, expire_on_commit=False)
|
|
async with Session() as session:
|
|
yield session
|
|
await engine.dispose()
|