aboutsummaryrefslogtreecommitdiff
path: root/tests/managers/thl
diff options
context:
space:
mode:
authorstuppie2026-09-18 11:34:27 -0600
committerstuppie2026-09-18 11:34:27 -0600
commit1a98418317c115b92739639cf0b837bd974fc5d6 (patch)
treeb664c69fc31d0ba4bc87ca81f83a8bb3c3449497 /tests/managers/thl
parent203066cb5228ce3bcadb940b9aca1b6a36dceb4e (diff)
downloadgeneralresearch-1a98418317c115b92739639cf0b837bd974fc5d6.tar.gz
generalresearch-1a98418317c115b92739639cf0b837bd974fc5d6.zip
fix more tests
Diffstat (limited to 'tests/managers/thl')
-rw-r--r--tests/managers/thl/test_cashout_method.py4
-rw-r--r--tests/managers/thl/test_ipinfo.py6
-rw-r--r--tests/managers/thl/test_ledger/test_thl_lm_tx.py27
-rw-r--r--tests/managers/thl/test_ledger/test_thl_pem.py5
-rw-r--r--tests/managers/thl/test_payout.py19
5 files changed, 43 insertions, 18 deletions
diff --git a/tests/managers/thl/test_cashout_method.py b/tests/managers/thl/test_cashout_method.py
index fc364f2..bb978f8 100644
--- a/tests/managers/thl/test_cashout_method.py
+++ b/tests/managers/thl/test_cashout_method.py
@@ -13,7 +13,6 @@ from generalresearch.models.thl.wallet.cashout_method import (
from generalresearch.models.thl.wallet.definitions import PayoutType
if TYPE_CHECKING:
- from generalresearch.config import GRLBaseSettings
from generalresearch.managers.thl.cashout_method import (
CashoutMethodManager,
)
@@ -24,7 +23,6 @@ if TYPE_CHECKING:
class TestTangoCashoutMethods:
-
def test_create_and_get(
self,
cashout_method_manager: CashoutMethodManager,
@@ -51,9 +49,7 @@ class TestTangoCashoutMethods:
assert len(res) == 2
-
class TestUserCashoutMethods:
-
def test(
self,
cashout_method_manager: CashoutMethodManager,
diff --git a/tests/managers/thl/test_ipinfo.py b/tests/managers/thl/test_ipinfo.py
index f39d50e..d84cbf7 100644
--- a/tests/managers/thl/test_ipinfo.py
+++ b/tests/managers/thl/test_ipinfo.py
@@ -3,7 +3,7 @@ from generalresearch.models.thl.ipinfo import GeoIPInformation
class TestGeoIpInfoManager:
- def test_get(self, geoipinfo_manager: GeoIpInfoManager):
+ def test_get(self, geoip_info_manager: GeoIpInfoManager):
result = geoip_info_manager.get("8.8.8.8")
assert result == GeoIPInformation(
@@ -16,7 +16,7 @@ class TestGeoIpInfoManager:
)
geoip_info_manager.grip_mmdb.lookup.assert_called_once_with("8.8.8.8")
- def test_get_multi(self, geoipinfo_manager: GeoIpInfoManager):
+ def test_get_multi(self, geoip_info_manager: GeoIpInfoManager):
result = geoip_info_manager.get_multi(["8.8.8.8", "1.1.1.1", "8.8.8.8"])
assert result == {
@@ -42,6 +42,6 @@ class TestGeoIpInfoManager:
call.args[0] for call in geoip_info_manager.grip_mmdb.lookup.call_args_list
} == {"8.8.8.8", "1.1.1.1"}
- def test_get_multi_empty(self, geoipinfo_manager: GeoIpInfoManager):
+ def test_get_multi_empty(self, geoip_info_manager: GeoIpInfoManager):
assert geoip_info_manager.get_multi([]) == {}
geoip_info_manager.grip_mmdb.lookup.assert_not_called()
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 96ea0d6..22a7b73 100644
--- a/tests/managers/thl/test_ledger/test_thl_lm_tx.py
+++ b/tests/managers/thl/test_ledger/test_thl_lm_tx.py
@@ -806,6 +806,24 @@ class TestThlLedgerTxManager:
assert thl_ledger_manager.get_session_attempt_credit(session.uuid) == 5
assert thl_ledger_manager.get_user_attempt_credit_balance(user) == 5
+ attempt_credit_account = (
+ thl_ledger_manager.get_account_or_create_user_attempt_credit(user)
+ )
+ user_txs = thl_ledger_manager.get_user_txs(
+ user, account_uuid=attempt_credit_account.uuid
+ )
+ assert user_txs.total == 1
+ assert user_txs.transactions[0].tx_type == TransactionType.USER_ATTEMPT_CREDIT
+ assert user_txs.transactions[0].amount == 5
+ assert user_txs.transactions[0].balance_after == 5
+ assert user_txs.summary.user_attempt_credit.entry_count == 1
+ assert user_txs.summary.user_attempt_credit.total_amount == 5
+
+ user_txs_by_name = thl_ledger_manager.get_user_txs(
+ user, qualified_name=attempt_credit_account.qualified_name
+ )
+ assert user_txs_by_name == user_txs
+
with pytest.raises(
LedgerTransactionConditionFailedError, match=r"^duplicate tag$"
):
@@ -887,6 +905,15 @@ class TestThlLedgerTxManager:
assert thl_ledger_manager.get_user_wallet_balance(user) == round(user_pay * 100)
assert thl_ledger_manager.check_ledger_balanced()
+ attempt_credit_account = (
+ thl_ledger_manager.get_account_or_create_user_attempt_credit(user)
+ )
+ user_txs = thl_ledger_manager.get_user_txs(
+ user, account_uuid=attempt_credit_account.uuid
+ )
+ assert [tx.amount for tx in user_txs.transactions] == [5, -5]
+ assert [tx.balance_after for tx in user_txs.transactions] == [5, 0]
+
def test_bp_payment_with_zero_attempt_credit_balance(
self,
session_factory: Callable[..., Session],
diff --git a/tests/managers/thl/test_ledger/test_thl_pem.py b/tests/managers/thl/test_ledger/test_thl_pem.py
index fb35aa4..4761438 100644
--- a/tests/managers/thl/test_ledger/test_thl_pem.py
+++ b/tests/managers/thl/test_ledger/test_thl_pem.py
@@ -30,7 +30,6 @@ if TYPE_CHECKING:
class TestThlPayoutEventManager:
-
def test_get_by_uuid(
self, brokerage_product_payout_event_manager: BrokerageProductPayoutEventManager
):
@@ -50,8 +49,9 @@ class TestThlPayoutEventManager:
bp_payout_event_factory: Callable[..., BrokerageProductPayoutEvent],
thl_ledger_manager: ThlLedgerManager,
brokerage_product_payout_event_manager: BrokerageProductPayoutEventManager,
+ create_main_accounts,
):
-
+ create_main_accounts()
N_PRODUCTS = randint(3, 10)
N_PAYOUT_EVENTS = randint(3, 10)
amounts = []
@@ -223,7 +223,6 @@ class TestThlPayoutEventManager:
class TestBPPayoutEvent:
-
def test_get_bp_bp_payout_events_for_products(
self,
product_factory: Callable[..., Product],
diff --git a/tests/managers/thl/test_payout.py b/tests/managers/thl/test_payout.py
index 52bbbec..69b9737 100644
--- a/tests/managers/thl/test_payout.py
+++ b/tests/managers/thl/test_payout.py
@@ -163,7 +163,9 @@ class TestPayout:
thl_ledger_manager: ThlLedgerManager,
utc_now: datetime,
pending_bp_pe: BrokerageProductPayoutEvent,
+ create_main_accounts,
):
+ create_main_accounts()
thl_ledger_manager.get_account_or_create_bp_wallet(product=product)
brokerage_product_payout_event_manager.create_tx_bp_payout_from_payout_event(
@@ -871,6 +873,7 @@ class TestBusinessPayoutEventManager:
bp1 = business_payout_event_manager.create_from_ach_or_wire(
business=gr_business,
amount=USDCent(bb1.available_balance),
+ transaction_id=ach_id1,
pm=product_manager,
thl_lm=thl_ledger_manager,
created=start + timedelta(days=1, hours=5),
@@ -901,22 +904,22 @@ class TestBusinessPayoutEventManager:
ledger_collection.initial_load(client=None, sync=True)
pop_ledger_merge.build(client=client_no_amm, ledger_coll=ledger_collection)
- business.prebuild_balance(
- thl_pg_config=thl_web_rr,
+ gr_business.prebuild_balance(
+ product_manager=product_manager,
lm=ledger_manager,
ds=mnt_filepath,
client=client_no_amm,
pop_ledger=pop_ledger_merge,
)
- business.prebuild_payouts(
+ gr_business.prebuild_payouts(
bpem=business_payout_event_manager,
)
- assert isinstance(business.payouts, list)
- assert len(business.payouts) == 2
- assert len(business.payouts[0].bp_payouts) == 2
- assert len(business.payouts[1].bp_payouts) == 1
+ assert isinstance(gr_business.payouts, list)
+ assert len(gr_business.payouts) == 2
+ assert len(gr_business.payouts[0].bp_payouts) == 2
+ assert len(gr_business.payouts[1].bp_payouts) == 1
- bb2 = business.balance
+ bb2 = gr_business.balance
# Okay os we have the balance before, and after the Business Payout
# of bb1.available_balance worth..