mirror of
https://github.com/Routstr/routstr-core.git
synced 2026-08-09 11:04:36 +00:00
pydantic v1 + import fixes
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import math
|
||||
import os
|
||||
|
||||
from pydantic import BaseModel
|
||||
from pydantic.v1 import BaseModel
|
||||
|
||||
from ..core import get_logger
|
||||
from .models import MODELS
|
||||
|
||||
@@ -28,8 +28,8 @@ os.environ.update(
|
||||
}
|
||||
)
|
||||
|
||||
from router.db import ApiKey, get_session
|
||||
from router.main import app, lifespan
|
||||
from router.core.db import ApiKey, get_session
|
||||
from router.core.main import app, lifespan
|
||||
|
||||
|
||||
class TestmintWallet:
|
||||
@@ -338,19 +338,19 @@ async def integration_app(
|
||||
real_wallet = await create_real_mint_wallet()
|
||||
|
||||
with (
|
||||
patch("router.db.engine", integration_engine),
|
||||
patch("router.cashu.wallet_instance", real_wallet.wallet),
|
||||
patch("router.cashu.wallet", lambda: real_wallet.wallet),
|
||||
patch("router.cashu.init_wallet", AsyncMock()),
|
||||
patch("router.core.db.engine", integration_engine),
|
||||
patch("router.wallet.wallet_instance", real_wallet.wallet),
|
||||
patch("router.wallet.wallet", lambda: real_wallet.wallet),
|
||||
patch("router.wallet.init_wallet", AsyncMock()),
|
||||
):
|
||||
yield test_app
|
||||
else:
|
||||
# Use mock testmint wallet (current implementation)
|
||||
with patch("router.db.engine", integration_engine):
|
||||
with patch("router.core.db.engine", integration_engine):
|
||||
# Set up the test wallet instance
|
||||
import router.cashu
|
||||
import router.wallet
|
||||
|
||||
original_wallet_instance = router.cashu.wallet_instance
|
||||
original_wallet_instance = router.wallet.wallet_instance
|
||||
|
||||
# Create a wallet adapter that uses our testmint_wallet
|
||||
mock_wallet = AsyncMock()
|
||||
@@ -362,21 +362,21 @@ async def integration_app(
|
||||
|
||||
# Patch the wallet functions to use our test wallet
|
||||
with (
|
||||
patch("router.cashu.wallet") as mock_wallet_func,
|
||||
patch("router.cashu.init_wallet") as mock_init_wallet,
|
||||
patch("router.wallet.wallet") as mock_wallet_func,
|
||||
patch("router.wallet.init_wallet") as mock_init_wallet,
|
||||
):
|
||||
# Configure to return our test wallet
|
||||
mock_wallet_func.return_value = mock_wallet
|
||||
mock_init_wallet.return_value = None
|
||||
|
||||
# Set the global wallet_instance
|
||||
router.cashu.wallet_instance = mock_wallet
|
||||
router.wallet.wallet_instance = mock_wallet
|
||||
|
||||
try:
|
||||
yield test_app
|
||||
finally:
|
||||
# Restore original wallet_instance
|
||||
router.cashu.wallet_instance = original_wallet_instance
|
||||
router.wallet.wallet_instance = original_wallet_instance
|
||||
|
||||
|
||||
@pytest_asyncio.fixture
|
||||
|
||||
@@ -11,7 +11,7 @@ import pytest
|
||||
|
||||
import router.cashu
|
||||
from router.cashu import check_for_refunds, periodic_payout
|
||||
from router.db import ApiKey
|
||||
from router.core.db import ApiKey
|
||||
from router.models import MODELS, Model, Pricing, update_sats_pricing
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ from sqlalchemy.exc import IntegrityError
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from sqlmodel import select
|
||||
|
||||
from router.db import ApiKey
|
||||
from router.core.db import ApiKey
|
||||
|
||||
|
||||
class TestTransactionAtomicity:
|
||||
|
||||
@@ -10,7 +10,7 @@ from httpx import AsyncClient, ConnectError
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from sqlmodel import select
|
||||
|
||||
from router.db import ApiKey
|
||||
from router.core.db import ApiKey
|
||||
|
||||
|
||||
class TestNetworkFailureScenarios:
|
||||
|
||||
@@ -149,7 +149,7 @@ class TestPerformanceBaseline:
|
||||
"""Test database operation performance"""
|
||||
from sqlmodel import select
|
||||
|
||||
from router.db import ApiKey
|
||||
from router.core.db import ApiKey
|
||||
|
||||
# Create test data
|
||||
for i in range(100):
|
||||
|
||||
@@ -14,7 +14,7 @@ import pytest
|
||||
from httpx import AsyncClient
|
||||
from sqlmodel import select
|
||||
|
||||
from router.db import ApiKey
|
||||
from router.core.db import ApiKey
|
||||
from tests.integration.utils import (
|
||||
ConcurrencyTester,
|
||||
PerformanceValidator,
|
||||
|
||||
@@ -11,7 +11,7 @@ import pytest
|
||||
from httpx import AsyncClient
|
||||
from sqlmodel import select
|
||||
|
||||
from router.db import ApiKey
|
||||
from router.core.db import ApiKey
|
||||
from tests.integration.utils import (
|
||||
CashuTokenGenerator,
|
||||
ConcurrencyTester,
|
||||
|
||||
@@ -11,7 +11,7 @@ import pytest
|
||||
from httpx import AsyncClient
|
||||
from sqlmodel import select, update
|
||||
|
||||
from router.db import ApiKey
|
||||
from router.core.db import ApiKey
|
||||
from tests.integration.utils import ConcurrencyTester, ResponseValidator
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import pytest
|
||||
from httpx import AsyncClient
|
||||
from sqlmodel import select
|
||||
|
||||
from router.db import ApiKey
|
||||
from router.core.db import ApiKey
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
|
||||
@@ -11,7 +11,7 @@ import pytest
|
||||
from httpx import AsyncClient
|
||||
from sqlmodel import select
|
||||
|
||||
from router.db import ApiKey
|
||||
from router.core.db import ApiKey
|
||||
from tests.integration.utils import (
|
||||
CashuTokenGenerator,
|
||||
ConcurrencyTester,
|
||||
|
||||
@@ -9,7 +9,7 @@ import httpx
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from sqlmodel import select
|
||||
|
||||
from router.db import ApiKey
|
||||
from router.core.db import ApiKey
|
||||
|
||||
|
||||
class CashuTokenGenerator:
|
||||
|
||||
@@ -45,7 +45,7 @@ def check_imports() -> bool:
|
||||
|
||||
# Check router modules - imports are for verification only
|
||||
from router.cashu import Wallet
|
||||
from router.db import ApiKey
|
||||
from router.core.db import ApiKey
|
||||
|
||||
del Wallet, ApiKey
|
||||
|
||||
|
||||
Reference in New Issue
Block a user