From bd354ac3e863c8d79e201ecc9db11c57255013db Mon Sep 17 00:00:00 2001 From: Kyle Santiago Date: Mon, 4 Aug 2025 19:26:19 -0400 Subject: [PATCH] pydantic v1 + import fixes --- router/payment/cost_caculation.py | 2 +- tests/integration/conftest.py | 26 +++++++++---------- tests/integration/test_background_tasks.py | 2 +- .../integration/test_database_consistency.py | 2 +- .../test_error_handling_edge_cases.py | 2 +- tests/integration/test_performance_load.py | 2 +- tests/integration/test_proxy_get_endpoints.py | 2 +- .../integration/test_wallet_authentication.py | 2 +- tests/integration/test_wallet_information.py | 2 +- tests/integration/test_wallet_refund.py | 2 +- tests/integration/test_wallet_topup.py | 2 +- tests/integration/utils.py | 2 +- tests/integration/verify_setup.py | 2 +- 13 files changed, 25 insertions(+), 25 deletions(-) diff --git a/router/payment/cost_caculation.py b/router/payment/cost_caculation.py index 6eedaf5c..0cce2827 100644 --- a/router/payment/cost_caculation.py +++ b/router/payment/cost_caculation.py @@ -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 diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 482faa9f..b5c5a325 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -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 diff --git a/tests/integration/test_background_tasks.py b/tests/integration/test_background_tasks.py index 35e4f754..feb37b5c 100644 --- a/tests/integration/test_background_tasks.py +++ b/tests/integration/test_background_tasks.py @@ -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 diff --git a/tests/integration/test_database_consistency.py b/tests/integration/test_database_consistency.py index 046ba006..99227ceb 100644 --- a/tests/integration/test_database_consistency.py +++ b/tests/integration/test_database_consistency.py @@ -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: diff --git a/tests/integration/test_error_handling_edge_cases.py b/tests/integration/test_error_handling_edge_cases.py index 93c16270..32604274 100644 --- a/tests/integration/test_error_handling_edge_cases.py +++ b/tests/integration/test_error_handling_edge_cases.py @@ -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: diff --git a/tests/integration/test_performance_load.py b/tests/integration/test_performance_load.py index 3fe1b2b4..287c2f57 100644 --- a/tests/integration/test_performance_load.py +++ b/tests/integration/test_performance_load.py @@ -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): diff --git a/tests/integration/test_proxy_get_endpoints.py b/tests/integration/test_proxy_get_endpoints.py index 7edc68d5..85a1dce9 100644 --- a/tests/integration/test_proxy_get_endpoints.py +++ b/tests/integration/test_proxy_get_endpoints.py @@ -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, diff --git a/tests/integration/test_wallet_authentication.py b/tests/integration/test_wallet_authentication.py index 7af30e87..87d66cb1 100644 --- a/tests/integration/test_wallet_authentication.py +++ b/tests/integration/test_wallet_authentication.py @@ -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, diff --git a/tests/integration/test_wallet_information.py b/tests/integration/test_wallet_information.py index b84896f9..e00a117a 100644 --- a/tests/integration/test_wallet_information.py +++ b/tests/integration/test_wallet_information.py @@ -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 diff --git a/tests/integration/test_wallet_refund.py b/tests/integration/test_wallet_refund.py index 7b522218..1b96e0ae 100644 --- a/tests/integration/test_wallet_refund.py +++ b/tests/integration/test_wallet_refund.py @@ -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 diff --git a/tests/integration/test_wallet_topup.py b/tests/integration/test_wallet_topup.py index bb106bd6..3ba35506 100644 --- a/tests/integration/test_wallet_topup.py +++ b/tests/integration/test_wallet_topup.py @@ -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, diff --git a/tests/integration/utils.py b/tests/integration/utils.py index 7cb347a0..dc23b353 100644 --- a/tests/integration/utils.py +++ b/tests/integration/utils.py @@ -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: diff --git a/tests/integration/verify_setup.py b/tests/integration/verify_setup.py index 691285c8..8f44b238 100644 --- a/tests/integration/verify_setup.py +++ b/tests/integration/verify_setup.py @@ -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