mirror of
https://github.com/Routstr/routstr-core.git
synced 2026-10-05 12:28:22 +00:00
Add pytest coverage and XML reporting configuration
Co-authored-by: db2002dominic <db2002dominic@gmail.com>
This commit is contained in:
co-authored by
db2002dominic
parent
d7e35887de
commit
06050196d4
+1866
File diff suppressed because it is too large
Load Diff
@@ -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\"')",
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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,11 +133,10 @@ 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(
|
||||
@@ -144,15 +144,15 @@ async def test_insufficient_reserved_balance_for_revert() -> None:
|
||||
balance=1000,
|
||||
reserved_balance=0,
|
||||
)
|
||||
session.add(test_key)
|
||||
await session.commit()
|
||||
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)
|
||||
await revert_pay_for_request(test_key, integration_session, 100)
|
||||
|
||||
# Refresh to get updated values
|
||||
await session.refresh(test_key)
|
||||
await integration_session.refresh(test_key)
|
||||
|
||||
# Current implementation allows negative reserved balance
|
||||
assert test_key.reserved_balance == -100, (
|
||||
|
||||
Reference in New Issue
Block a user