aboutsummaryrefslogtreecommitdiff
path: root/tests/managers/thl/test_ledger
diff options
context:
space:
mode:
Diffstat (limited to 'tests/managers/thl/test_ledger')
-rw-r--r--tests/managers/thl/test_ledger/test_lm_accounts.py10
-rw-r--r--tests/managers/thl/test_ledger/test_lm_tx.py7
-rw-r--r--tests/managers/thl/test_ledger/test_lm_tx_entries.py10
-rw-r--r--tests/managers/thl/test_ledger/test_lm_tx_locks.py15
-rw-r--r--tests/managers/thl/test_ledger/test_lm_tx_metadata.py11
-rw-r--r--tests/managers/thl/test_ledger/test_thl_lm_accounts.py15
-rw-r--r--tests/managers/thl/test_ledger/test_thl_lm_bp_payout.py22
-rw-r--r--tests/managers/thl/test_ledger/test_thl_lm_tx.py28
-rw-r--r--tests/managers/thl/test_ledger/test_thl_lm_tx__user_payouts.py13
-rw-r--r--tests/managers/thl/test_ledger/test_thl_pem.py21
-rw-r--r--tests/managers/thl/test_ledger/test_user_txs.py19
-rw-r--r--tests/managers/thl/test_ledger/test_wallet.py9
12 files changed, 115 insertions, 65 deletions
diff --git a/tests/managers/thl/test_ledger/test_lm_accounts.py b/tests/managers/thl/test_ledger/test_lm_accounts.py
index 7b65b2d..f5ed883 100644
--- a/tests/managers/thl/test_ledger/test_lm_accounts.py
+++ b/tests/managers/thl/test_ledger/test_lm_accounts.py
@@ -2,6 +2,7 @@ from __future__ import annotations
from itertools import product as iproduct
from random import randint
+from typing import TYPE_CHECKING
from uuid import uuid4
import pytest
@@ -13,13 +14,18 @@ from generalresearch.managers.thl.ledger_manager.exceptions import (
LedgerAccountDoesntExistError,
)
from generalresearch.managers.thl.ledger_manager.ledger import LedgerManager
-from generalresearch.models.custom_types import AccountType, Direction, UUIDStr
+from generalresearch.models.custom_types import AccountType, Direction
from generalresearch.models.thl.ledger import (
LedgerAccount,
LedgerEntry,
- LedgerTransaction,
)
+if TYPE_CHECKING:
+ from generalresearch.models.custom_types import UUIDStr
+ from generalresearch.models.thl.ledger import (
+ LedgerTransaction,
+ )
+
@pytest.mark.parametrize(
argnames="currency, kind, acct_id",
diff --git a/tests/managers/thl/test_ledger/test_lm_tx.py b/tests/managers/thl/test_ledger/test_lm_tx.py
index ce609d6..445405e 100644
--- a/tests/managers/thl/test_ledger/test_lm_tx.py
+++ b/tests/managers/thl/test_ledger/test_lm_tx.py
@@ -2,6 +2,7 @@ from __future__ import annotations
from decimal import Decimal
from random import randint
+from typing import TYPE_CHECKING
from uuid import uuid4
import pytest
@@ -12,11 +13,15 @@ from generalresearch.managers.thl.ledger_manager.ledger import (
)
from generalresearch.models.thl.ledger import (
Direction,
- LedgerAccount,
LedgerEntry,
LedgerTransaction,
)
+if TYPE_CHECKING:
+ from generalresearch.models.thl.ledger import (
+ LedgerAccount,
+ )
+
class TestLedgerManagerCreateTx:
diff --git a/tests/managers/thl/test_ledger/test_lm_tx_entries.py b/tests/managers/thl/test_ledger/test_lm_tx_entries.py
index 9925b87..03c6e02 100644
--- a/tests/managers/thl/test_ledger/test_lm_tx_entries.py
+++ b/tests/managers/thl/test_ledger/test_lm_tx_entries.py
@@ -1,11 +1,17 @@
from __future__ import annotations
-from generalresearch.managers.thl.ledger_manager.ledger import LedgerManager
+from typing import TYPE_CHECKING
+
from generalresearch.models.thl.ledger import (
LedgerEntry,
- LedgerTransaction,
)
+if TYPE_CHECKING:
+ from generalresearch.managers.thl.ledger_manager.ledger import LedgerManager
+ from generalresearch.models.thl.ledger import (
+ LedgerTransaction,
+ )
+
class TestLedgerEntryManager:
diff --git a/tests/managers/thl/test_ledger/test_lm_tx_locks.py b/tests/managers/thl/test_ledger/test_lm_tx_locks.py
index e603632..9ecc1bc 100644
--- a/tests/managers/thl/test_ledger/test_lm_tx_locks.py
+++ b/tests/managers/thl/test_ledger/test_lm_tx_locks.py
@@ -5,10 +5,10 @@ from collections.abc import Callable, Generator
from datetime import UTC, datetime, timedelta
from decimal import Decimal
from logging import LogCaptureFixture
+from typing import TYPE_CHECKING
import pytest
-from generalresearch.currency import LedgerCurrency
from generalresearch.managers.thl.ledger_manager.conditions import (
generate_condition_mp_payment,
)
@@ -17,11 +17,8 @@ from generalresearch.managers.thl.ledger_manager.exceptions import (
LedgerTransactionCreateLockError,
LedgerTransactionFlagAlreadyExistsError,
)
-from generalresearch.managers.thl.ledger_manager.ledger import LedgerManager
-from generalresearch.managers.thl.ledger_manager.thl_ledger import ThlLedgerManager
-from generalresearch.models import Source
+from generalresearch.models.definitions import Source
from generalresearch.models.thl.ledger import LedgerTransaction
-from generalresearch.models.thl.product import Product
from generalresearch.models.thl.session import (
Session,
Status,
@@ -29,7 +26,13 @@ from generalresearch.models.thl.session import (
Wall,
WallAdjustedStatus,
)
-from generalresearch.models.thl.user import User
+
+if TYPE_CHECKING:
+ from generalresearch.currency import LedgerCurrency
+ from generalresearch.managers.thl.ledger_manager.ledger import LedgerManager
+ from generalresearch.managers.thl.ledger_manager.thl_ledger import ThlLedgerManager
+ from generalresearch.models.thl.product import Product
+ from generalresearch.models.thl.user import User
logger = logging.getLogger("LedgerManager")
diff --git a/tests/managers/thl/test_ledger/test_lm_tx_metadata.py b/tests/managers/thl/test_ledger/test_lm_tx_metadata.py
index f63efa4..3d8cf89 100644
--- a/tests/managers/thl/test_ledger/test_lm_tx_metadata.py
+++ b/tests/managers/thl/test_ledger/test_lm_tx_metadata.py
@@ -1,9 +1,12 @@
from __future__ import annotations
-from generalresearch.managers.thl.ledger_manager.ledger import (
- LedgerManager,
- LedgerTransaction,
-)
+from typing import TYPE_CHECKING
+
+if TYPE_CHECKING:
+ from generalresearch.managers.thl.ledger_manager.ledger import (
+ LedgerManager,
+ LedgerTransaction,
+ )
class TestLedgerMetadataManager:
diff --git a/tests/managers/thl/test_ledger/test_thl_lm_accounts.py b/tests/managers/thl/test_ledger/test_thl_lm_accounts.py
index 60eb71c..adff446 100644
--- a/tests/managers/thl/test_ledger/test_thl_lm_accounts.py
+++ b/tests/managers/thl/test_ledger/test_thl_lm_accounts.py
@@ -1,6 +1,7 @@
from __future__ import annotations
from collections.abc import Callable
+from typing import TYPE_CHECKING
from uuid import uuid4
import pytest
@@ -9,18 +10,20 @@ from generalresearch.currency import LedgerCurrency
from generalresearch.managers.thl.ledger_manager.exceptions import (
LedgerAccountDoesntExistError,
)
-from generalresearch.managers.thl.ledger_manager.ledger import (
- LedgerAccountManager,
- LedgerManager,
-)
-from generalresearch.managers.thl.ledger_manager.thl_ledger import ThlLedgerManager
from generalresearch.models.thl.ledger import (
AccountType,
Direction,
LedgerAccount,
)
from generalresearch.models.thl.product import Product
-from generalresearch.models.thl.user import User
+
+if TYPE_CHECKING:
+ from generalresearch.managers.thl.ledger_manager.ledger import (
+ LedgerAccountManager,
+ LedgerManager,
+ )
+ from generalresearch.managers.thl.ledger_manager.thl_ledger import ThlLedgerManager
+ from generalresearch.models.thl.user import User
class TestThlLedgerManagerAccounts:
diff --git a/tests/managers/thl/test_ledger/test_thl_lm_bp_payout.py b/tests/managers/thl/test_ledger/test_thl_lm_bp_payout.py
index b518453..14c5270 100644
--- a/tests/managers/thl/test_ledger/test_thl_lm_bp_payout.py
+++ b/tests/managers/thl/test_ledger/test_thl_lm_bp_payout.py
@@ -5,6 +5,7 @@ from collections.abc import Callable
from datetime import UTC, datetime, timedelta
from decimal import Decimal
from random import randint
+from typing import TYPE_CHECKING
from uuid import uuid4
import pytest
@@ -12,7 +13,7 @@ import redis
from pydantic import RedisDsn
from redis.lock import Lock
-from generalresearch.currency import LedgerCurrency, USDCent
+from generalresearch.currency import USDCent
from generalresearch.managers.base import Permission
from generalresearch.managers.thl.ledger_manager.exceptions import (
LedgerTransactionConditionFailedError,
@@ -22,24 +23,27 @@ from generalresearch.managers.thl.ledger_manager.exceptions import (
)
from generalresearch.managers.thl.ledger_manager.ledger import LedgerTransaction
from generalresearch.managers.thl.ledger_manager.thl_ledger import ThlLedgerManager
-from generalresearch.managers.thl.payout import (
- BrokerageProductPayoutEventManager,
-)
-from generalresearch.models import Source
+from generalresearch.models.definitions import Source
from generalresearch.models.thl.definitions import PayoutStatus
from generalresearch.models.thl.ledger import Direction, TransactionType
-from generalresearch.models.thl.product import Product
from generalresearch.models.thl.session import (
Session,
Status,
StatusCode1,
Wall,
)
-from generalresearch.models.thl.user import User
-from generalresearch.models.thl.wallet import PayoutType
-from generalresearch.pg_helper import PostgresConfig
+from generalresearch.models.thl.wallet.definitions import PayoutType
from generalresearch.redis_helper import RedisConfig
+if TYPE_CHECKING:
+ from generalresearch.currency import LedgerCurrency
+ from generalresearch.managers.thl.payout import (
+ BrokerageProductPayoutEventManager,
+ )
+ from generalresearch.models.thl.product import Product
+ from generalresearch.models.thl.user import User
+ from generalresearch.pg_helper import PostgresConfig
+
def broken_acquire(self, *args, **kwargs):
raise redis.exceptions.TimeoutError("Simulated timeout during acquire")
diff --git a/tests/managers/thl/test_ledger/test_thl_lm_tx.py b/tests/managers/thl/test_ledger/test_thl_lm_tx.py
index 1860d6d..2e4ab5e 100644
--- a/tests/managers/thl/test_ledger/test_thl_lm_tx.py
+++ b/tests/managers/thl/test_ledger/test_thl_lm_tx.py
@@ -5,26 +5,21 @@ from collections.abc import Callable
from datetime import UTC, datetime, timedelta
from decimal import Decimal
from random import randint
+from typing import TYPE_CHECKING
from uuid import uuid4
import pytest
-from generalresearch.currency import LedgerCurrency, USDCent
+from generalresearch.currency import USDCent
from generalresearch.managers.thl.ledger_manager.ledger import (
- LedgerManager,
LedgerTransaction,
)
-from generalresearch.managers.thl.ledger_manager.thl_ledger import ThlLedgerManager
-from generalresearch.managers.thl.product import ProductManager
-from generalresearch.managers.thl.session import SessionManager
-from generalresearch.managers.thl.wall import WallManager
-from generalresearch.models import Source
+from generalresearch.models.definitions import Source
from generalresearch.models.thl.definitions import (
WALL_ALLOWED_STATUS_STATUS_CODE,
)
from generalresearch.models.thl.ledger import (
Direction,
- LedgerAccount,
TransactionType,
)
from generalresearch.models.thl.payout import UserPayoutEvent
@@ -41,8 +36,21 @@ from generalresearch.models.thl.session import (
Wall,
WallAdjustedStatus,
)
-from generalresearch.models.thl.user import User
-from generalresearch.models.thl.wallet import PayoutType
+from generalresearch.models.thl.wallet.definitions import PayoutType
+
+if TYPE_CHECKING:
+ from generalresearch.currency import LedgerCurrency
+ from generalresearch.managers.thl.ledger_manager.ledger import (
+ LedgerManager,
+ )
+ from generalresearch.managers.thl.ledger_manager.thl_ledger import ThlLedgerManager
+ from generalresearch.managers.thl.product import ProductManager
+ from generalresearch.managers.thl.session import SessionManager
+ from generalresearch.managers.thl.wall import WallManager
+ from generalresearch.models.thl.ledger import (
+ LedgerAccount,
+ )
+ from generalresearch.models.thl.user import User
logger = logging.getLogger("LedgerManager")
diff --git a/tests/managers/thl/test_ledger/test_thl_lm_tx__user_payouts.py b/tests/managers/thl/test_ledger/test_thl_lm_tx__user_payouts.py
index 82dc143..3fd21dc 100644
--- a/tests/managers/thl/test_ledger/test_thl_lm_tx__user_payouts.py
+++ b/tests/managers/thl/test_ledger/test_thl_lm_tx__user_payouts.py
@@ -3,6 +3,7 @@ from __future__ import annotations
import logging
from collections.abc import Callable
from decimal import Decimal
+from typing import TYPE_CHECKING
from uuid import uuid4
import pytest
@@ -11,12 +12,14 @@ from generalresearch.managers.thl.ledger_manager.exceptions import (
LedgerTransactionConditionFailedError,
LedgerTransactionFlagAlreadyExistsError,
)
-from generalresearch.managers.thl.ledger_manager.ledger import LedgerManager
-from generalresearch.managers.thl.ledger_manager.thl_ledger import ThlLedgerManager
from generalresearch.models.thl.payout import UserPayoutEvent
-from generalresearch.models.thl.product import Product
-from generalresearch.models.thl.user import User
-from generalresearch.models.thl.wallet import PayoutType
+from generalresearch.models.thl.wallet.definitions import PayoutType
+
+if TYPE_CHECKING:
+ from generalresearch.managers.thl.ledger_manager.ledger import LedgerManager
+ from generalresearch.managers.thl.ledger_manager.thl_ledger import ThlLedgerManager
+ from generalresearch.models.thl.product import Product
+ from generalresearch.models.thl.user import User
class TestLedgerManagerAMT:
diff --git a/tests/managers/thl/test_ledger/test_thl_pem.py b/tests/managers/thl/test_ledger/test_thl_pem.py
index 29341cf..9dbec48 100644
--- a/tests/managers/thl/test_ledger/test_thl_pem.py
+++ b/tests/managers/thl/test_ledger/test_thl_pem.py
@@ -2,28 +2,31 @@ from __future__ import annotations
from collections.abc import Callable
from random import randint
+from typing import TYPE_CHECKING
from uuid import UUID, uuid4
import pytest
from generalresearch.currency import USDCent
-from generalresearch.managers.thl.ledger_manager.ledger import LedgerManager
-from generalresearch.managers.thl.ledger_manager.thl_ledger import (
- ThlLedgerManager,
-)
-from generalresearch.managers.thl.payout import (
- BrokerageProductPayoutEventManager,
- UserPayoutEventManager,
-)
from generalresearch.models.thl.definitions import PayoutStatus
from generalresearch.models.thl.payout import (
BrokerageProductPayoutEvent,
)
-from generalresearch.models.thl.product import Product
from generalresearch.models.thl.wallet.cashout_method import (
CashoutRequestInfo,
)
+if TYPE_CHECKING:
+ from generalresearch.managers.thl.ledger_manager.ledger import LedgerManager
+ from generalresearch.managers.thl.ledger_manager.thl_ledger import (
+ ThlLedgerManager,
+ )
+ from generalresearch.managers.thl.payout import (
+ BrokerageProductPayoutEventManager,
+ UserPayoutEventManager,
+ )
+ from generalresearch.models.thl.product import Product
+
class TestThlPayoutEventManager:
diff --git a/tests/managers/thl/test_ledger/test_user_txs.py b/tests/managers/thl/test_ledger/test_user_txs.py
index 56dc485..1c08498 100644
--- a/tests/managers/thl/test_ledger/test_user_txs.py
+++ b/tests/managers/thl/test_ledger/test_user_txs.py
@@ -3,12 +3,9 @@ from __future__ import annotations
from collections.abc import Callable
from datetime import UTC, datetime
from decimal import Decimal
+from typing import TYPE_CHECKING
from uuid import uuid4
-from generalresearch.config import GRLBaseSettings
-from generalresearch.managers.thl.ledger_manager.ledger import LedgerManager
-from generalresearch.managers.thl.ledger_manager.thl_ledger import ThlLedgerManager
-from generalresearch.managers.thl.payout import UserPayoutEventManager
from generalresearch.managers.thl.user_compensate import user_compensate
from generalresearch.models.thl.definitions import (
Status,
@@ -18,10 +15,16 @@ from generalresearch.models.thl.ledger import (
UserLedgerTransactionTypesSummary,
UserLedgerTransactionTypeSummary,
)
-from generalresearch.models.thl.product import Product
-from generalresearch.models.thl.session import Session
-from generalresearch.models.thl.user import User
-from generalresearch.models.thl.wallet import PayoutType
+from generalresearch.models.thl.wallet.definitions import PayoutType
+
+if TYPE_CHECKING:
+ from generalresearch.config import GRLBaseSettings
+ from generalresearch.managers.thl.ledger_manager.ledger import LedgerManager
+ from generalresearch.managers.thl.ledger_manager.thl_ledger import ThlLedgerManager
+ from generalresearch.managers.thl.payout import UserPayoutEventManager
+ from generalresearch.models.thl.product import Product
+ from generalresearch.models.thl.session import Session
+ from generalresearch.models.thl.user import User
def test_user_txs(
diff --git a/tests/managers/thl/test_ledger/test_wallet.py b/tests/managers/thl/test_ledger/test_wallet.py
index cad3ea4..1ee9bf9 100644
--- a/tests/managers/thl/test_ledger/test_wallet.py
+++ b/tests/managers/thl/test_ledger/test_wallet.py
@@ -2,12 +2,11 @@ from __future__ import annotations
from collections.abc import Callable
from decimal import Decimal
+from typing import TYPE_CHECKING
from uuid import uuid4
import pytest
-from generalresearch.managers.thl.ledger_manager.thl_ledger import ThlLedgerManager
-from generalresearch.managers.thl.product import ProductManager
from generalresearch.models.thl.product import (
PayoutConfig,
PayoutTransformation,
@@ -15,7 +14,11 @@ from generalresearch.models.thl.product import (
Product,
UserWalletConfig,
)
-from generalresearch.models.thl.user import User
+
+if TYPE_CHECKING:
+ from generalresearch.managers.thl.ledger_manager.thl_ledger import ThlLedgerManager
+ from generalresearch.managers.thl.product import ProductManager
+ from generalresearch.models.thl.user import User
@pytest.fixture()