diff --git a/coverage.xml b/coverage.xml new file mode 100644 index 00000000..2551cef1 --- /dev/null +++ b/coverage.xml @@ -0,0 +1,1866 @@ + + + + + + /workspace/routstr + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pyproject.toml b/pyproject.toml index 50ddaf1f..8cf7bbc4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,6 +47,10 @@ addopts = [ "--disable-warnings", "-p", "no:warnings", + "--junit-xml=pytest.xml", + "--cov=routstr", + "--cov-report=xml", + "--cov-report=term-missing:skip-covered", ] markers = [ "asyncio: marks tests as async (deselect with '-m \"not asyncio\"')", diff --git a/pytest.xml b/pytest.xml new file mode 100644 index 00000000..c23cdfe6 --- /dev/null +++ b/pytest.xml @@ -0,0 +1 @@ +/workspace/tests/integration/test_background_tasks.py:440: Timing-based test with complex mocking - skipping for CI reliability/workspace/tests/integration/test_background_tasks.py:447: Database setup issues - skipping for CI reliability/workspace/tests/integration/test_background_tasks.py:613: Complex timing and concurrency tests - skipping for CI reliability/workspace/tests/integration/test_background_tasks.py:645: Complex timing and concurrency tests - skipping for CI reliability/workspace/tests/integration/test_background_tasks.py:696: Complex timing and concurrency tests - skipping for CI reliability/workspace/tests/integration/test_database_consistency.py:381: Balance never negative is not implemented/workspace/tests/integration/test_error_handling_edge_cases.py:543: Concurrent error test has timing issues - skipping for CI reliability/workspace/tests/integration/test_performance_load.py:194: High load tests fail in CI environment - skipping for reliability/workspace/tests/integration/test_performance_load.py:279: High load tests fail in CI environment - skipping for reliability/workspace/tests/integration/test_performance_load.py:374: Memory leak tests fail due to missing model field - skipping for CI reliability/workspace/tests/integration/test_performance_load.py:436: Performance regression tests fail due to auth issues - skipping for CI reliability/workspace/tests/integration/test_proxy_post_endpoints.py:639: Skipping insufficient balance test - depends on model pricing configuration/workspace/tests/integration/test_wallet_refund.py:168: Lightning address refund functionality not implemented \ No newline at end of file diff --git a/routstr/auth.py b/routstr/auth.py index 4c891c96..a1cba59f 100644 --- a/routstr/auth.py +++ b/routstr/auth.py @@ -13,7 +13,6 @@ from .payment.cost_caculation import ( MaxCostData, calculate_cost, ) -from .payment.helpers import get_max_cost_for_model from .wallet import ( PRIMARY_MINT_URL, TRUSTED_MINTS, diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 16344318..c3727a72 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -8,8 +8,9 @@ import pytest import pytest_asyncio from fastapi import FastAPI from httpx import AsyncClient -from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine +from sqlalchemy.ext.asyncio import create_async_engine from sqlmodel import select +from sqlmodel.ext.asyncio.session import AsyncSession from routstr.core.logging import get_logger diff --git a/tests/integration/test_reserved_balance_negative.py b/tests/integration/test_reserved_balance_negative.py index 02219785..791d4b96 100644 --- a/tests/integration/test_reserved_balance_negative.py +++ b/tests/integration/test_reserved_balance_negative.py @@ -5,6 +5,7 @@ import uuid import pytest from httpx import AsyncClient +from sqlmodel.ext.asyncio.session import AsyncSession from routstr.core.db import ApiKey, create_session @@ -132,32 +133,31 @@ async def test_reserved_balance_with_successful_requests( @pytest.mark.asyncio -async def test_insufficient_reserved_balance_for_revert() -> None: +async def test_insufficient_reserved_balance_for_revert(integration_session: AsyncSession) -> None: """Test revert_pay_for_request behavior with insufficient reserved balance.""" from routstr.auth import revert_pay_for_request - async with create_session() as session: - # Create key with zero reserved balance - unique_key = f"test_revert_key_{uuid.uuid4().hex[:8]}" - test_key = ApiKey( - hashed_key=unique_key, - balance=1000, - reserved_balance=0, - ) - session.add(test_key) - await session.commit() + # Create key with zero reserved balance + unique_key = f"test_revert_key_{uuid.uuid4().hex[:8]}" + test_key = ApiKey( + hashed_key=unique_key, + balance=1000, + reserved_balance=0, + ) + integration_session.add(test_key) + await integration_session.commit() - # Try to revert more than available - # Note: Current implementation allows reserved_balance to go negative - await revert_pay_for_request(test_key, session, 100) + # Try to revert more than available + # Note: Current implementation allows reserved_balance to go negative + await revert_pay_for_request(test_key, integration_session, 100) - # Refresh to get updated values - await session.refresh(test_key) + # Refresh to get updated values + await integration_session.refresh(test_key) - # Current implementation allows negative reserved balance - assert test_key.reserved_balance == -100, ( - f"Expected reserved_balance to be -100, got: {test_key.reserved_balance}" - ) - assert test_key.total_requests == -1, ( - f"Expected total_requests to be -1, got: {test_key.total_requests}" - ) + # Current implementation allows negative reserved balance + assert test_key.reserved_balance == -100, ( + f"Expected reserved_balance to be -100, got: {test_key.reserved_balance}" + ) + assert test_key.total_requests == -1, ( + f"Expected total_requests to be -1, got: {test_key.total_requests}" + )