aboutsummaryrefslogtreecommitdiff
path: root/tests/managers/thl/test_ledger
diff options
context:
space:
mode:
authorMax Nanis2026-08-21 17:19:41 -0700
committerMax Nanis2026-08-21 17:19:41 -0700
commit6cf7ccbaa8306700e64ada19d6f99807743b2865 (patch)
tree16ccde36ba2694b8c03bf8bdcee9cfcb2909046a /tests/managers/thl/test_ledger
parent352520a2bd4ac066e90587e44d8b818043407917 (diff)
downloadgeneralresearch-6cf7ccbaa8306700e64ada19d6f99807743b2865.tar.gz
generalresearch-6cf7ccbaa8306700e64ada19d6f99807743b2865.zip
Ruff auto updates to 3.14
Diffstat (limited to 'tests/managers/thl/test_ledger')
-rw-r--r--tests/managers/thl/test_ledger/test_lm_accounts.py65
-rw-r--r--tests/managers/thl/test_ledger/test_lm_tx_locks.py22
-rw-r--r--tests/managers/thl/test_ledger/test_thl_lm_bp_payout.py48
-rw-r--r--tests/managers/thl/test_ledger/test_thl_lm_tx.py55
-rw-r--r--tests/managers/thl/test_ledger/test_thl_lm_tx__user_payouts.py10
-rw-r--r--tests/managers/thl/test_ledger/test_user_txs.py31
6 files changed, 116 insertions, 115 deletions
diff --git a/tests/managers/thl/test_ledger/test_lm_accounts.py b/tests/managers/thl/test_ledger/test_lm_accounts.py
index 5cfaac1..faef5fb 100644
--- a/tests/managers/thl/test_ledger/test_lm_accounts.py
+++ b/tests/managers/thl/test_ledger/test_lm_accounts.py
@@ -1,6 +1,7 @@
+from collections.abc import Callable
from itertools import product as iproduct
from random import randint
-from typing import TYPE_CHECKING, Callable
+from typing import TYPE_CHECKING
from uuid import uuid4
import pytest
@@ -51,10 +52,10 @@ class TestLedgerAccountManagerNoResults:
def test_get_account_no_results(
self,
- currency: "LedgerCurrency",
+ currency: LedgerCurrency,
kind: str,
- acct_id: "UUIDStr",
- lm: "LedgerManager",
+ acct_id: UUIDStr,
+ lm: LedgerManager,
):
"""Try to query for accounts that we know don't exist and confirm that
we either get the expected None result or it raises the correct
@@ -74,10 +75,10 @@ class TestLedgerAccountManagerNoResults:
def test_get_account_no_results_many(
self,
- currency: "LedgerCurrency",
+ currency: LedgerCurrency,
kind: str,
- acct_id: "UUIDStr",
- lm: "LedgerManager",
+ acct_id: UUIDStr,
+ lm: LedgerManager,
):
qn = ":".join([currency, kind, acct_id])
@@ -114,10 +115,10 @@ class TestLedgerAccountManagerCreate:
def test_create_account_error_permission(
self,
- currency: "LedgerCurrency",
- account_type: "AccountType",
- direction: "Direction",
- lm: "LedgerManager",
+ currency: LedgerCurrency,
+ account_type: AccountType,
+ direction: Direction,
+ lm: LedgerManager,
):
"""Confirm that the Permission values that are set on the Ledger Manger
allow the Creation action to occur.
@@ -164,10 +165,10 @@ class TestLedgerAccountManagerCreate:
def test_create(
self,
- currency: "LedgerCurrency",
- account_type: "AccountType",
- direction: "Direction",
- lm: "LedgerManager",
+ currency: LedgerCurrency,
+ account_type: AccountType,
+ direction: Direction,
+ lm: LedgerManager,
):
"""Confirm that the Permission values that are set on the Ledger Manger
allow the Creation action to occur.
@@ -194,10 +195,10 @@ class TestLedgerAccountManagerCreate:
def test_get_or_create(
self,
- currency: "LedgerCurrency",
- account_type: "AccountType",
- direction: "Direction",
- lm: "LedgerManager",
+ currency: LedgerCurrency,
+ account_type: AccountType,
+ direction: Direction,
+ lm: LedgerManager,
):
"""Confirm that the Permission values that are set on the Ledger Manger
allow the Creation action to occur.
@@ -225,7 +226,7 @@ class TestLedgerAccountManagerCreate:
class TestLedgerAccountManagerGet:
- def test_get(self, ledger_account: "LedgerAccount", lm: "LedgerManager"):
+ def test_get(self, ledger_account: LedgerAccount, lm: LedgerManager):
res = lm.get_account(qualified_name=ledger_account.qualified_name)
assert res is not None
assert res.uuid == ledger_account.uuid
@@ -243,11 +244,11 @@ class TestLedgerAccountManagerGet:
def test_get_balance_empty(
self,
- ledger_account: "LedgerAccount",
- ledger_account_credit: "LedgerAccount",
- ledger_account_debit: "LedgerAccount",
- ledger_tx: "LedgerTransaction",
- lm: "LedgerManager",
+ ledger_account: LedgerAccount,
+ ledger_account_credit: LedgerAccount,
+ ledger_account_debit: LedgerAccount,
+ ledger_tx: LedgerTransaction,
+ lm: LedgerManager,
):
res = lm.get_account_balance(account=ledger_account)
assert res == 0
@@ -261,12 +262,12 @@ class TestLedgerAccountManagerGet:
@pytest.mark.parametrize("n_times", range(5))
def test_get_account_filtered_balance(
self,
- ledger_account: "LedgerAccount",
- ledger_account_credit: "LedgerAccount",
- ledger_account_debit: "LedgerAccount",
- ledger_tx: "LedgerTransaction",
- n_times: "PositiveInt",
- lm: "LedgerManager",
+ ledger_account: LedgerAccount,
+ ledger_account_credit: LedgerAccount,
+ ledger_account_debit: LedgerAccount,
+ ledger_tx: LedgerTransaction,
+ n_times: PositiveInt,
+ lm: LedgerManager,
):
"""Try searching for random metadata and confirm it's always 0 because
Tx can be found.
@@ -320,7 +321,7 @@ class TestLedgerAccountManagerGet:
)
def test_get_balance_timerange_empty(
- self, ledger_account: "LedgerAccount", lm: "LedgerManager"
+ self, ledger_account: LedgerAccount, lm: LedgerManager
):
res = lm.get_account_balance_timerange(account=ledger_account)
assert res == 0
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 df2611b..07c3712 100644
--- a/tests/managers/thl/test_ledger/test_lm_tx_locks.py
+++ b/tests/managers/thl/test_ledger/test_lm_tx_locks.py
@@ -1,7 +1,7 @@
import logging
-from datetime import datetime, timezone, timedelta
+from collections.abc import Callable
+from datetime import UTC, datetime, timedelta, timezone
from decimal import Decimal
-from typing import Callable
import pytest
@@ -9,21 +9,21 @@ from generalresearch.managers.thl.ledger_manager.conditions import (
generate_condition_mp_payment,
)
from generalresearch.managers.thl.ledger_manager.exceptions import (
+ LedgerTransactionCreateError,
LedgerTransactionCreateLockError,
LedgerTransactionFlagAlreadyExistsError,
- LedgerTransactionCreateError,
)
from generalresearch.models import Source
from generalresearch.models.thl.ledger import LedgerTransaction
from generalresearch.models.thl.session import (
- Wall,
+ Session,
Status,
StatusCode1,
- Session,
+ Wall,
WallAdjustedStatus,
)
from generalresearch.models.thl.user import User
-from test_utils.models.conftest import user_factory, session, product_user_wallet_no
+from test_utils.models.conftest import product_user_wallet_no, session, user_factory
logger = logging.getLogger("LedgerManager")
@@ -139,7 +139,7 @@ class TestLedgerLocks:
delete_ledger_db()
create_main_accounts()
- now = datetime.now(timezone.utc) - timedelta(hours=1)
+ now = datetime.now(UTC) - timedelta(hours=1)
user: User = user_factory(product=product_user_wallet_no)
# A User does a Wall complete on Session.id=1 and the transaction is
@@ -283,8 +283,8 @@ class TestLedgerLocks:
session_id=3,
status=Status.COMPLETE,
status_code_1=StatusCode1.COMPLETE,
- started=datetime.now(timezone.utc),
- finished=datetime.now(timezone.utc) + timedelta(seconds=1),
+ started=datetime.now(UTC),
+ finished=datetime.now(UTC) + timedelta(seconds=1),
)
thl_lm.create_tx_task_complete(wall=wall1, user=user, created=wall1.started)
@@ -327,8 +327,8 @@ class TestLedgerLocks:
session_id=3,
status=Status.COMPLETE,
status_code_1=StatusCode1.COMPLETE,
- started=datetime.now(timezone.utc),
- finished=datetime.now(timezone.utc) + timedelta(seconds=1),
+ started=datetime.now(UTC),
+ finished=datetime.now(UTC) + timedelta(seconds=1),
)
thl_lm.create_tx_task_complete(wall1, user, created=wall1.started)
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 294d092..1fb9c01 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
@@ -1,5 +1,5 @@
import logging
-from datetime import datetime, timezone, timedelta
+from datetime import UTC, datetime, timedelta, timezone
from decimal import Decimal
from random import randint
from uuid import uuid4
@@ -11,22 +11,22 @@ from redis.lock import Lock
from generalresearch.currency import USDCent
from generalresearch.managers.base import Permission
-from generalresearch.managers.thl.ledger_manager.thl_ledger import ThlLedgerManager
from generalresearch.managers.thl.ledger_manager.exceptions import (
- LedgerTransactionFlagAlreadyExistsError,
LedgerTransactionConditionFailedError,
- LedgerTransactionReleaseLockError,
LedgerTransactionCreateError,
+ LedgerTransactionFlagAlreadyExistsError,
+ LedgerTransactionReleaseLockError,
)
from generalresearch.managers.thl.ledger_manager.ledger import LedgerTransaction
+from generalresearch.managers.thl.ledger_manager.thl_ledger import ThlLedgerManager
from generalresearch.models import Source
from generalresearch.models.thl.definitions import PayoutStatus
from generalresearch.models.thl.ledger import Direction, TransactionType
from generalresearch.models.thl.session import (
- Wall,
+ Session,
Status,
StatusCode1,
- Session,
+ Wall,
)
from generalresearch.models.thl.user import User
from generalresearch.models.thl.wallet import PayoutType
@@ -55,7 +55,7 @@ class TestThlLedgerManagerBPPayout:
delete_ledger_db()
create_main_accounts()
- now = datetime.now(timezone.utc) - timedelta(hours=1)
+ now = datetime.now(UTC) - timedelta(hours=1)
user: User = user_factory(product=product_user_wallet_no)
wall1 = Wall(
@@ -158,7 +158,7 @@ class TestThlLedgerManagerBPPayout:
product=product,
amount=rand_amount,
payoutevent_uuid=payoutevent_uuid,
- created=datetime.now(tz=timezone.utc),
+ created=datetime.now(tz=UTC),
skip_wallet_balance_check=True,
skip_one_per_day_check=True,
skip_flag_check=True,
@@ -189,7 +189,7 @@ class TestThlLedgerManagerBPPayout:
product=product,
amount=rand_amount,
payoutevent_uuid=uuid4().hex,
- created=datetime.now(tz=timezone.utc),
+ created=datetime.now(tz=UTC),
skip_wallet_balance_check=False,
skip_one_per_day_check=False,
skip_flag_check=False,
@@ -199,7 +199,7 @@ class TestThlLedgerManagerBPPayout:
def test_create_tx_redis_failure(self, product, thl_web_rw, thl_lm):
rand_amount: USDCent = USDCent(randint(100, 1_000))
payoutevent_uuid = uuid4().hex
- now = datetime.now(tz=timezone.utc)
+ now = datetime.now(tz=UTC)
thl_lm.create_tx_plug_bp_wallet(
product, rand_amount, now, direction=Direction.CREDIT
@@ -226,7 +226,7 @@ class TestThlLedgerManagerBPPayout:
product=product,
amount=rand_amount,
payoutevent_uuid=payoutevent_uuid,
- created=datetime.now(tz=timezone.utc),
+ created=datetime.now(tz=UTC),
)
assert e.type is redis.exceptions.TimeoutError
# No txs were created
@@ -238,7 +238,7 @@ class TestThlLedgerManagerBPPayout:
def test_create_tx_multiple_per_day(self, product, thl_lm):
rand_amount: USDCent = USDCent(randint(100, 1_000))
payoutevent_uuid = uuid4().hex
- now = datetime.now(tz=timezone.utc)
+ now = datetime.now(tz=UTC)
thl_lm.create_tx_plug_bp_wallet(
product, rand_amount * USDCent(2), now, direction=Direction.CREDIT
@@ -248,7 +248,7 @@ class TestThlLedgerManagerBPPayout:
product=product,
amount=rand_amount,
payoutevent_uuid=payoutevent_uuid,
- created=datetime.now(tz=timezone.utc),
+ created=datetime.now(tz=UTC),
)
# Try to create another
@@ -258,7 +258,7 @@ class TestThlLedgerManagerBPPayout:
product=product,
amount=rand_amount,
payoutevent_uuid=payoutevent_uuid,
- created=datetime.now(tz=timezone.utc),
+ created=datetime.now(tz=UTC),
)
assert e.type is LedgerTransactionFlagAlreadyExistsError
@@ -270,7 +270,7 @@ class TestThlLedgerManagerBPPayout:
product=product,
amount=rand_amount,
payoutevent_uuid=payoutevent_uuid2,
- created=datetime.now(tz=timezone.utc),
+ created=datetime.now(tz=UTC),
)
assert e.type is LedgerTransactionConditionFailedError
assert str(e.value) == ">1 tx per day"
@@ -280,14 +280,14 @@ class TestThlLedgerManagerBPPayout:
product=product,
amount=rand_amount,
payoutevent_uuid=payoutevent_uuid2,
- created=datetime.now(tz=timezone.utc),
+ created=datetime.now(tz=UTC),
skip_one_per_day_check=True,
)
def test_create_tx_redis_lock_release_error(self, product, thl_lm):
rand_amount: USDCent = USDCent(randint(100, 1_000))
payoutevent_uuid = uuid4().hex
- now = datetime.now(tz=timezone.utc)
+ now = datetime.now(tz=UTC)
bp_wallet_account = thl_lm.get_account_or_create_bp_wallet(product=product)
thl_lm.create_tx_plug_bp_wallet(
@@ -304,7 +304,7 @@ class TestThlLedgerManagerBPPayout:
product=product,
amount=rand_amount,
payoutevent_uuid=payoutevent_uuid,
- created=datetime.now(tz=timezone.utc),
+ created=datetime.now(tz=UTC),
)
assert e.type is LedgerTransactionCreateError
assert str(e.value) == "Redis error: Simulated timeout during acquire"
@@ -321,7 +321,7 @@ class TestThlLedgerManagerBPPayout:
product=product,
amount=rand_amount,
payoutevent_uuid=payoutevent_uuid,
- created=datetime.now(tz=timezone.utc),
+ created=datetime.now(tz=UTC),
)
assert e.type is LedgerTransactionReleaseLockError
assert str(e.value) == "Redis error: Simulated timeout during release"
@@ -337,7 +337,7 @@ class TestPayoutEventManagerBPPayout:
def test_create(self, product, thl_lm, brokerage_product_payout_event_manager):
rand_amount: USDCent = USDCent(randint(100, 1_000))
- now = datetime.now(tz=timezone.utc)
+ now = datetime.now(tz=UTC)
bp_wallet_account = thl_lm.get_account_or_create_bp_wallet(product=product)
assert thl_lm.get_account_balance(bp_wallet_account) == 0
thl_lm.create_tx_plug_bp_wallet(
@@ -369,7 +369,7 @@ class TestPayoutEventManagerBPPayout:
original_release = Lock.release
rand_amount: USDCent = USDCent(randint(100, 1_000))
- now = datetime.now(tz=timezone.utc)
+ now = datetime.now(tz=UTC)
bp_wallet_account = thl_lm.get_account_or_create_bp_wallet(product=product)
assert thl_lm.get_account_balance(bp_wallet_account) == 0
thl_lm.create_tx_plug_bp_wallet(
@@ -435,7 +435,7 @@ class TestPayoutEventManagerBPPayout:
# We wouldn't do this in practice, because this is paying out the BP again, but
# we can if want to.
# Change the timestamp so it'll create a new payout event
- now = datetime.now(tz=timezone.utc)
+ now = datetime.now(tz=UTC)
with pytest.raises(LedgerTransactionConditionFailedError) as e:
pe = brokerage_product_payout_event_manager.create_bp_payout_event(
thl_ledger_manager=thl_lm,
@@ -450,7 +450,7 @@ class TestPayoutEventManagerBPPayout:
assert pe.status == PayoutStatus.FAILED
# And if we really want to, we can make it again
- now = datetime.now(tz=timezone.utc)
+ now = datetime.now(tz=UTC)
pe = brokerage_product_payout_event_manager.create_bp_payout_event(
thl_ledger_manager=thl_lm,
product=product,
@@ -478,7 +478,7 @@ class TestPayoutEventManagerBPPayout:
original_release = Lock.release
rand_amount: USDCent = USDCent(randint(100, 1_000))
- now = datetime.now(tz=timezone.utc)
+ now = datetime.now(tz=UTC)
bp_wallet_account = thl_lm.get_account_or_create_bp_wallet(product=product)
brokerage_product_payout_event_manager.set_account_lookup_table(thl_lm=thl_lm)
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 31c7107..be988a1 100644
--- a/tests/managers/thl/test_ledger/test_thl_lm_tx.py
+++ b/tests/managers/thl/test_ledger/test_thl_lm_tx.py
@@ -1,5 +1,5 @@
import logging
-from datetime import datetime, timezone, timedelta
+from datetime import UTC, datetime, timedelta, timezone
from decimal import Decimal
from random import randint
from uuid import uuid4
@@ -14,23 +14,22 @@ from generalresearch.models import Source
from generalresearch.models.thl.definitions import (
WALL_ALLOWED_STATUS_STATUS_CODE,
)
-from generalresearch.models.thl.ledger import Direction
-from generalresearch.models.thl.ledger import TransactionType
+from generalresearch.models.thl.ledger import Direction, TransactionType
+from generalresearch.models.thl.payout import UserPayoutEvent
from generalresearch.models.thl.product import (
PayoutConfig,
PayoutTransformation,
UserWalletConfig,
)
from generalresearch.models.thl.session import (
- Wall,
+ Session,
Status,
StatusCode1,
- Session,
+ Wall,
WallAdjustedStatus,
)
from generalresearch.models.thl.user import User
from generalresearch.models.thl.wallet import PayoutType
-from generalresearch.models.thl.payout import UserPayoutEvent
logger = logging.getLogger("LedgerManager")
@@ -82,7 +81,7 @@ class TestThlLedgerTxManager:
session=s1,
status=Status.COMPLETE,
status_code_1=status_code_1,
- finished=datetime.now(tz=timezone.utc) + timedelta(minutes=10),
+ finished=datetime.now(tz=UTC) + timedelta(minutes=10),
payout=bp_pay,
user_payout=user_pay,
)
@@ -127,7 +126,7 @@ class TestThlLedgerTxManager:
session=s1,
status=Status.COMPLETE,
status_code_1=status_code_1,
- finished=datetime.now(tz=timezone.utc) + timedelta(minutes=10),
+ finished=datetime.now(tz=UTC) + timedelta(minutes=10),
payout=bp_pay,
user_payout=user_pay,
)
@@ -209,7 +208,7 @@ class TestThlLedgerTxManager:
# there is no financial changes needed
session.update(
**{
- "finished": datetime.now(tz=timezone.utc) + timedelta(minutes=10),
+ "finished": datetime.now(tz=UTC) + timedelta(minutes=10),
}
)
assert session.finished
@@ -229,7 +228,7 @@ class TestThlLedgerTxManager:
product=product,
amount=rand_amount,
payoutevent_uuid=payoutevent_uuid,
- created=datetime.now(tz=timezone.utc),
+ created=datetime.now(tz=UTC),
skip_wallet_balance_check=True,
skip_one_per_day_check=True,
skip_flag_check=True,
@@ -260,7 +259,7 @@ class TestThlLedgerTxManager:
product=product,
amount=rand_amount,
payoutevent_uuid=uuid4().hex,
- created=datetime.now(tz=timezone.utc),
+ created=datetime.now(tz=UTC),
skip_wallet_balance_check=False,
skip_one_per_day_check=False,
skip_flag_check=False,
@@ -276,7 +275,7 @@ class TestThlLedgerTxManager:
product=product,
amount=rand_amount,
payoutevent_uuid=payoutevent_uuid,
- created=datetime.now(tz=timezone.utc),
+ created=datetime.now(tz=UTC),
)
# Check the basic attributes
@@ -300,7 +299,7 @@ class TestThlLedgerTxManager:
tx = thl_lm.create_tx_plug_bp_wallet(
product=product,
amount=rand_amount,
- created=datetime.now(tz=timezone.utc),
+ created=datetime.now(tz=UTC),
direction=Direction.DEBIT,
skip_flag_check=False,
)
@@ -328,7 +327,7 @@ class TestThlLedgerTxManager:
tx = thl_lm.create_tx_plug_bp_wallet_(
product=product,
amount=rand_amount,
- created=datetime.now(tz=timezone.utc),
+ created=datetime.now(tz=UTC),
direction=Direction.DEBIT,
)
@@ -345,7 +344,7 @@ class TestThlLedgerTxManager:
thl_lm.create_tx_plug_bp_wallet_(
product=product,
amount=rand_amount + rand_amount,
- created=datetime.now(tz=timezone.utc),
+ created=datetime.now(tz=UTC),
direction=Direction.CREDIT,
)
balance = thl_lm.get_account_balance(
@@ -727,8 +726,8 @@ class TestThlLedgerTxManagerFlows:
session_id=1,
status=Status.COMPLETE,
status_code_1=StatusCode1.COMPLETE,
- started=datetime.now(timezone.utc),
- finished=datetime.now(timezone.utc) + timedelta(seconds=1),
+ started=datetime.now(UTC),
+ finished=datetime.now(UTC) + timedelta(seconds=1),
)
thl_lm.create_tx_task_complete(wall=wall1, user=user, created=wall1.started)
@@ -740,8 +739,8 @@ class TestThlLedgerTxManagerFlows:
session_id=1,
status=Status.COMPLETE,
status_code_1=StatusCode1.COMPLETE,
- started=datetime.now(timezone.utc),
- finished=datetime.now(timezone.utc) + timedelta(seconds=1),
+ started=datetime.now(UTC),
+ finished=datetime.now(UTC) + timedelta(seconds=1),
)
thl_lm.create_tx_task_complete(wall=wall2, user=user, created=wall2.started)
@@ -793,8 +792,8 @@ class TestThlLedgerTxManagerFlows:
session_id=1,
status=Status.COMPLETE,
status_code_1=StatusCode1.COMPLETE,
- started=datetime.now(timezone.utc),
- finished=datetime.now(timezone.utc) + timedelta(seconds=1),
+ started=datetime.now(UTC),
+ finished=datetime.now(UTC) + timedelta(seconds=1),
)
tx = thl_lm.create_tx_task_complete(
wall=wall1, user=user, created=wall1.started
@@ -880,8 +879,8 @@ class TestThlLedgerTxManagerFlows:
session_id=3,
status=Status.COMPLETE,
status_code_1=StatusCode1.COMPLETE,
- started=datetime.now(timezone.utc),
- finished=datetime.now(timezone.utc) + timedelta(seconds=1),
+ started=datetime.now(UTC),
+ finished=datetime.now(UTC) + timedelta(seconds=1),
)
tx = thl_lm.create_tx_task_complete(
@@ -922,8 +921,8 @@ class TestThlLedgerTxManagerFlows:
session_id=3,
status=Status.COMPLETE,
status_code_1=StatusCode1.COMPLETE,
- started=datetime.now(timezone.utc),
- finished=datetime.now(timezone.utc) + timedelta(seconds=1),
+ started=datetime.now(UTC),
+ finished=datetime.now(UTC) + timedelta(seconds=1),
)
thl_lm.create_tx_task_complete(wall=wall1, user=user, created=wall1.started)
@@ -963,8 +962,8 @@ class TestThlLedgerTxManagerFlows:
session_id=3,
status=Status.COMPLETE,
status_code_1=StatusCode1.COMPLETE,
- started=datetime.now(timezone.utc),
- finished=datetime.now(timezone.utc) + timedelta(seconds=1),
+ started=datetime.now(UTC),
+ finished=datetime.now(UTC) + timedelta(seconds=1),
)
thl_lm.create_tx_task_complete(wall=wall1, user=user, created=wall1.started)
@@ -1416,7 +1415,7 @@ class TestThlLedgerManagerAdj:
delete_ledger_db()
create_main_accounts()
- now = datetime.now(timezone.utc) - timedelta(days=1)
+ now = datetime.now(UTC) - timedelta(days=1)
user: User = user_factory(product=product_user_wallet_yes)
# Create 2 Wall completes and create the respective transaction for
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 1e7146a..9253ff0 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
@@ -1,17 +1,17 @@
import logging
-from datetime import datetime, timezone, timedelta
+from datetime import UTC, datetime, timedelta, timezone
from decimal import Decimal
from uuid import uuid4
import pytest
from generalresearch.managers.thl.ledger_manager.exceptions import (
- LedgerTransactionFlagAlreadyExistsError,
LedgerTransactionConditionFailedError,
+ LedgerTransactionFlagAlreadyExistsError,
)
+from generalresearch.models.thl.payout import UserPayoutEvent
from generalresearch.models.thl.user import User
from generalresearch.models.thl.wallet import PayoutType
-from generalresearch.models.thl.payout import UserPayoutEvent
from test_utils.managers.ledger.conftest import create_main_accounts
@@ -243,7 +243,7 @@ class TestLedgerManagerAMT:
delete_ledger_db()
create_main_accounts()
- now = datetime.now(timezone.utc) - timedelta(hours=1)
+ now = datetime.now(UTC) - timedelta(hours=1)
user: User = user_factory(product=product_amt_true)
pe = UserPayoutEvent(
@@ -394,7 +394,7 @@ class TestLedgerManagerPaypal:
delete_ledger_db()
create_main_accounts()
- now = datetime.now(tz=timezone.utc) - timedelta(hours=1)
+ now = datetime.now(tz=UTC) - timedelta(hours=1)
user: User = user_factory(product=product_amt_true)
# debit_account_uuid nothing checks they match the ledger ... todo?
diff --git a/tests/managers/thl/test_ledger/test_user_txs.py b/tests/managers/thl/test_ledger/test_user_txs.py
index ecf146f..b4b0437 100644
--- a/tests/managers/thl/test_ledger/test_user_txs.py
+++ b/tests/managers/thl/test_ledger/test_user_txs.py
@@ -1,6 +1,7 @@
-from datetime import datetime, timedelta, timezone
+from collections.abc import Callable
+from datetime import UTC, datetime, timedelta, timezone
from decimal import Decimal
-from typing import TYPE_CHECKING, Callable
+from typing import TYPE_CHECKING
from uuid import uuid4
from generalresearch.managers.thl.ledger_manager.thl_ledger import ThlLedgerManager
@@ -24,8 +25,8 @@ if TYPE_CHECKING:
def test_user_txs(
- user_factory: Callable[..., "User"],
- product_amt_true: "Product",
+ user_factory: Callable[..., User],
+ product_amt_true: Product,
create_main_accounts: Callable[..., None],
thl_lm: ThlLedgerManager,
lm,
@@ -36,7 +37,7 @@ def test_user_txs(
session_factory,
user_payout_event_manager,
utc_now: datetime,
- settings: "GRLSettings",
+ settings: GRLSettings,
):
delete_ledger_db()
create_main_accounts()
@@ -136,13 +137,13 @@ def test_user_txs(
def test_user_txs_pagination(
- user_factory: Callable[..., "User"],
- product_amt_true: "Product",
+ user_factory: Callable[..., User],
+ product_amt_true: Product,
create_main_accounts: Callable[..., None],
- thl_lm: "ThlLedgerManager",
- lm: "LedgerManager",
+ thl_lm: ThlLedgerManager,
+ lm: LedgerManager,
delete_ledger_db: Callable[..., None],
- session_with_tx_factory: Callable[..., "Session"],
+ session_with_tx_factory: Callable[..., Session],
adj_to_fail_with_tx_factory,
user_payout_event_manager,
utc_now: datetime,
@@ -187,7 +188,7 @@ def test_user_txs_pagination(
assert txs.summary.user_bonus.entry_count == 12
# Test filtering. We should pull back only this one
- now = datetime.now(tz=timezone.utc)
+ now = datetime.now(tz=UTC)
user_compensate(
ledger_manager=thl_lm,
user=user,
@@ -203,7 +204,7 @@ def test_user_txs_pagination(
assert txs.summary.user_bonus.entry_count == 1
# And filtering with 0 results
- now = datetime.now(tz=timezone.utc)
+ now = datetime.now(tz=UTC)
txs = thl_lm.get_user_txs(user, page=1, size=5, time_start=now)
assert len(txs.transactions) == 0
assert txs.total == 0
@@ -215,8 +216,8 @@ def test_user_txs_pagination(
def test_user_txs_rolling_balance(
- user_factory: Callable[..., "User"],
- product_amt_true: "Product",
+ user_factory: Callable[..., User],
+ product_amt_true: Product,
create_main_accounts,
thl_lm,
lm,
@@ -224,7 +225,7 @@ def test_user_txs_rolling_balance(
session_with_tx_factory,
adj_to_fail_with_tx_factory,
user_payout_event_manager,
- settings: "GRLSettings",
+ settings: GRLSettings,
):
"""
Creates 3 $1.00 bonuses (postive),