aboutsummaryrefslogtreecommitdiff
path: root/tests/managers/thl/test_ledger
diff options
context:
space:
mode:
authorstuppie2026-09-18 14:56:36 -0600
committerstuppie2026-09-18 14:56:36 -0600
commitf4909f0fafd6161dd423859afadb72b916e90564 (patch)
tree4b364461c185f935d315b591d3b52808d3824f45 /tests/managers/thl/test_ledger
parent438ea05fdb98c847d534ae190179b4766fa96f26 (diff)
downloadgeneralresearch-f4909f0fafd6161dd423859afadb72b916e90564.tar.gz
generalresearch-f4909f0fafd6161dd423859afadb72b916e90564.zip
1 single broken managers test
Diffstat (limited to 'tests/managers/thl/test_ledger')
-rw-r--r--tests/managers/thl/test_ledger/test_lm_tx.py4
-rw-r--r--tests/managers/thl/test_ledger/test_lm_tx_locks.py21
-rw-r--r--tests/managers/thl/test_ledger/test_thl_pem.py14
3 files changed, 19 insertions, 20 deletions
diff --git a/tests/managers/thl/test_ledger/test_lm_tx.py b/tests/managers/thl/test_ledger/test_lm_tx.py
index 025f6ac..d98b838 100644
--- a/tests/managers/thl/test_ledger/test_lm_tx.py
+++ b/tests/managers/thl/test_ledger/test_lm_tx.py
@@ -206,12 +206,12 @@ class TestLedgerManagerGetTx:
self, ledger_tx: LedgerTransaction, tag: str, ledger_manager: LedgerManager
):
# (1) search for a random tag
- res = ledger_manager.get_tx_by_tag(tag="aaa:bbb")
+ res = ledger_manager.get_txs_by_tag(tag="aaa:bbb")
assert isinstance(res, list)
assert len(res) == 0
# (2) search for the tag that was used during ledger_transaction creation
- res = ledger_manager.get_tx_by_tag(tag=tag)
+ res = ledger_manager.get_txs_by_tag(tag=tag)
assert isinstance(res, list)
assert len(res) == 1
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 166598e..91d9cbc 100644
--- a/tests/managers/thl/test_ledger/test_lm_tx_locks.py
+++ b/tests/managers/thl/test_ledger/test_lm_tx_locks.py
@@ -38,7 +38,6 @@ logger = logging.getLogger("LedgerManager")
class TestLedgerLocks:
-
def test_a(
self,
user_factory: Callable[..., User],
@@ -108,16 +107,16 @@ class TestLedgerLocks:
f1 = generate_condition_mp_payment(wall=w1)
f2 = generate_condition_mp_payment(wall=w2)
f3 = generate_condition_mp_payment(wall=w3)
- assert f1(ledger_manager) is False
- assert f2(lm=ledger_manager) is False
- assert f3(lm=ledger_manager) is True
+ assert f1(ledger_manager) == (False, "duplicate tag")
+ assert f2(lm=ledger_manager) == (False, "duplicate tag")
+ assert f3(lm=ledger_manager)[0] == True
condition = f3
create_tx_func = lambda: thl_ledger_manager.create_tx_task_complete_(
wall=w3, user=user
)
assert isinstance(create_tx_func, Callable)
- assert f3(ledger_manager) is True
+ assert f3(ledger_manager)[0] is True
ledger_manager.redis_client.delete(flag_name)
ledger_manager.redis_client.delete(lock_name)
@@ -125,13 +124,14 @@ class TestLedgerLocks:
tx = thl_ledger_manager.create_tx_protected(
lock_key=lock_key, condition=condition, create_tx_func=create_tx_func
)
- assert f3(ledger_manager) is False
+ assert f3(ledger_manager) == (False, "duplicate tag")
# purposely hold the lock open
tx = None
ledger_manager.redis_client.set(lock_name, "1")
- with caplog.at_level(logging.ERROR), pytest.raises(
- expected_exception=LedgerTransactionCreateLockError
+ with (
+ caplog.at_level(logging.ERROR),
+ pytest.raises(expected_exception=LedgerTransactionCreateLockError),
):
tx = thl_ledger_manager.create_tx_protected(
lock_key=lock_key,
@@ -231,8 +231,9 @@ class TestLedgerLocks:
# Purposely hold the lock open
ledger_manager.redis_client.set(name=lock_name, value="1")
- with caplog.at_level(logging.DEBUG), pytest.raises(
- expected_exception=LedgerTransactionCreateLockError
+ with (
+ caplog.at_level(logging.DEBUG),
+ pytest.raises(expected_exception=LedgerTransactionCreateLockError),
):
tx = thl_ledger_manager.create_tx_task_complete(
wall=wall3, user=user, created=wall3.started
diff --git a/tests/managers/thl/test_ledger/test_thl_pem.py b/tests/managers/thl/test_ledger/test_thl_pem.py
index 2d03b25..348a02d 100644
--- a/tests/managers/thl/test_ledger/test_thl_pem.py
+++ b/tests/managers/thl/test_ledger/test_thl_pem.py
@@ -8,13 +8,9 @@ from uuid import UUID, uuid4
import pytest
from generalresearch.currency import USDCent
-from generalresearch.models.thl.definitions import PayoutStatus
from generalresearch.models.thl.payout import (
BrokerageProductPayoutEvent,
)
-from generalresearch.models.thl.wallet.cashout_method import (
- CashoutRequestInfo,
-)
if TYPE_CHECKING:
from generalresearch.managers.thl.ledger_manager.ledger import LedgerManager
@@ -23,6 +19,7 @@ if TYPE_CHECKING:
)
from generalresearch.managers.thl.payout import (
BrokerageProductPayoutEventManager,
+ BusinessPayoutEventManager,
UserPayoutEventManager,
)
from generalresearch.models.thl.payout import UserPayoutEvent
@@ -153,6 +150,7 @@ class TestThlPayoutEventManager:
create_main_accounts: Callable[..., None],
thl_ledger_manager: ThlLedgerManager,
brokerage_product_payout_event_manager: BrokerageProductPayoutEventManager,
+ business_payout_event_manager: BusinessPayoutEventManager,
ledger_manager: LedgerManager,
):
@@ -166,13 +164,13 @@ class TestThlPayoutEventManager:
# Save a Brokerage Product Payout, so we have something in the
# Payout Event table and the respective ledger TX and Entry rows for it
- pe = brokerage_product_payout_event_manager.create_bp_payout_event(
+ bus_pe = business_payout_event_manager.create_bp_payout_event(
thl_ledger_manager=thl_ledger_manager,
product=product,
amount=USDCent(rand_amount),
- skip_wallet_balance_check=True,
- skip_one_per_day_check=True,
+ ext_ref_id=uuid4().hex
)
+ pe = bus_pe.bp_payouts[0]
assert isinstance(pe, BrokerageProductPayoutEvent)
# Now try to query for it!
@@ -183,7 +181,7 @@ class TestThlPayoutEventManager:
res = thl_ledger_manager.get_tx_bp_payouts(account_uuids=[uuid4().hex])
assert len(res) == 0
- # Confirm it added to the users balance. The amount is negative because
+ # Confirm it added to the user's balance. The amount is negative because
# money was sent to the Brokerage product: Product, but they didn't have
# any activity that earned them money
bal = ledger_manager.get_account_balance(account=account_bp_wallet)