aboutsummaryrefslogtreecommitdiff
path: root/tests/managers/thl
diff options
context:
space:
mode:
authorMax Nanis2026-08-27 17:46:11 -0700
committerMax Nanis2026-08-27 17:46:11 -0700
commitaeeb7fef2594ccd34fbe96a77f6c5b392299fed7 (patch)
treede0896615df0c9747208fc26eb1ddde60f248286 /tests/managers/thl
parentfdc170938ac4ac8fa5d9d4df1936e6dc0777f291 (diff)
downloadgeneralresearch-aeeb7fef2594ccd34fbe96a77f6c5b392299fed7.tar.gz
generalresearch-aeeb7fef2594ccd34fbe96a77f6c5b392299fed7.zip
Ruff afternoon
Diffstat (limited to 'tests/managers/thl')
-rw-r--r--tests/managers/thl/test_contest/test_leaderboard.py5
-rw-r--r--tests/managers/thl/test_contest/test_milestone.py5
-rw-r--r--tests/managers/thl/test_contest/test_raffle.py12
-rw-r--r--tests/managers/thl/test_ledger/test_lm_accounts.py2
-rw-r--r--tests/managers/thl/test_ledger/test_lm_tx.py4
-rw-r--r--tests/managers/thl/test_ledger/test_thl_lm_accounts.py11
-rw-r--r--tests/managers/thl/test_ledger/test_thl_lm_bp_payout.py54
-rw-r--r--tests/managers/thl/test_ledger/test_thl_lm_tx.py26
-rw-r--r--tests/managers/thl/test_payout.py2
-rw-r--r--tests/managers/thl/test_survey.py6
-rw-r--r--tests/managers/thl/test_user_manager/test_base.py2
11 files changed, 65 insertions, 64 deletions
diff --git a/tests/managers/thl/test_contest/test_leaderboard.py b/tests/managers/thl/test_contest/test_leaderboard.py
index 07d8d74..3a63075 100644
--- a/tests/managers/thl/test_contest/test_leaderboard.py
+++ b/tests/managers/thl/test_contest/test_leaderboard.py
@@ -5,7 +5,6 @@ from zoneinfo import ZoneInfo
from generalresearch.currency import USDCent
from generalresearch.managers.thl.contest_manager import ContestManager
-from generalresearch.managers.thl.ledger_manager.ledger import LedgerManager
from generalresearch.managers.thl.ledger_manager.thl_ledger import ThlLedgerManager
from generalresearch.managers.thl.user_manager.user_manager import UserManager
from generalresearch.models.thl.contest.definitions import (
@@ -116,7 +115,9 @@ class TestLeaderboardContestCRUD:
assert decision
assert reason == ContestEndReason.ENDS_AT
- contest_manager.end_contest_if_over(contest=contest, ledger_manager=thl_lm)
+ contest_manager.end_contest_if_over(
+ contest=contest, ledger_manager=thl_ledger_manager
+ )
c: LeaderboardContest = contest_manager.get(contest_uuid=contest.uuid)
assert c.status == ContestStatus.COMPLETED
diff --git a/tests/managers/thl/test_contest/test_milestone.py b/tests/managers/thl/test_contest/test_milestone.py
index a2d575b..e3889bc 100644
--- a/tests/managers/thl/test_contest/test_milestone.py
+++ b/tests/managers/thl/test_contest/test_milestone.py
@@ -292,7 +292,10 @@ class TestMilestoneContestUserViews:
assert len(cs) == 1
contest_manager.enter_milestone_contest(
- contest_uuid=c.uuid, user=user, country_iso="us", ledger_manager=thl_lm
+ contest_uuid=c.uuid,
+ user=user,
+ country_iso="us",
+ ledger_manager=thl_ledger_manager,
)
# User isn't eligible anymore
diff --git a/tests/managers/thl/test_contest/test_raffle.py b/tests/managers/thl/test_contest/test_raffle.py
index b435576..06d4676 100644
--- a/tests/managers/thl/test_contest/test_raffle.py
+++ b/tests/managers/thl/test_contest/test_raffle.py
@@ -14,6 +14,7 @@ from generalresearch.managers.thl.ledger_manager.exceptions import (
)
from generalresearch.managers.thl.ledger_manager.thl_ledger import ThlLedgerManager
from generalresearch.models.thl.contest import (
+ Contest,
ContestEndCondition,
ContestEntryRule,
ContestPrize,
@@ -40,8 +41,6 @@ class TestRaffleContest:
def test_should_end(
self,
contest: RaffleContest,
- thl_ledger_manager: ThlLedgerManager,
- contest_manager: ContestManager,
):
# contest is active and has no entries
should, msg = contest.should_end()
@@ -67,7 +66,6 @@ class TestRaffleContestCRUD:
self,
contest_create: RaffleContestCreate,
product_user_wallet_yes: Product,
- thl_ledger_manager: ThlLedgerManager,
contest_manager: ContestManager,
):
c = contest_manager.create(
@@ -329,7 +327,7 @@ class TestRaffleContestCRUD:
contest_uuid=c.uuid,
entry=entry,
country_iso="us",
- ledger_manager=thl_lm,
+ ledger_manager=thl_ledger_manager,
)
assert "Entry would exceed max amount per user." in str(e.value)
@@ -342,7 +340,7 @@ class TestRaffleContestCRUD:
contest_uuid=c.uuid,
entry=entry,
country_iso="us",
- ledger_manager=thl_lm,
+ ledger_manager=thl_ledger_manager,
)
assert "Entry would exceed max amount per user per day." in str(e.value)
@@ -354,7 +352,7 @@ class TestRaffleContestCRUD:
contest_uuid=c.uuid,
entry=entry,
country_iso="us",
- ledger_manager=thl_lm,
+ ledger_manager=thl_ledger_manager,
)
# Then can't anymore
@@ -366,7 +364,7 @@ class TestRaffleContestCRUD:
contest_uuid=c.uuid,
entry=entry,
country_iso="us",
- ledger_manager=thl_lm,
+ ledger_manager=thl_ledger_manager,
)
assert "Entry would exceed max amount per user per day." in str(e.value)
diff --git a/tests/managers/thl/test_ledger/test_lm_accounts.py b/tests/managers/thl/test_ledger/test_lm_accounts.py
index 540bea8..7b65b2d 100644
--- a/tests/managers/thl/test_ledger/test_lm_accounts.py
+++ b/tests/managers/thl/test_ledger/test_lm_accounts.py
@@ -63,7 +63,7 @@ class TestLedgerAccountManagerNoResults:
acct_id: UUIDStr,
lm: LedgerManager,
):
- qn = ":".join([currency, kind, acct_id])
+ qn = f"{currency}:{kind}:{acct_id}"
# (1) .get_many_
assert lm.get_account_many_(qualified_names=[qn], raise_on_error=False) == []
diff --git a/tests/managers/thl/test_ledger/test_lm_tx.py b/tests/managers/thl/test_ledger/test_lm_tx.py
index 13495a7..ce609d6 100644
--- a/tests/managers/thl/test_ledger/test_lm_tx.py
+++ b/tests/managers/thl/test_ledger/test_lm_tx.py
@@ -24,8 +24,6 @@ class TestLedgerManagerCreateTx:
"""Confirm that the Permission values that are set on the Ledger Manger
allow the Creation action to occur.
"""
- acct_uuid = uuid4().hex
-
# (1) With no Permissions defined
test_lm = LedgerManager(
pg_config=ledger_manager.pg_config,
@@ -44,8 +42,6 @@ class TestLedgerManagerCreateTx:
def test_create_assertions(
self,
- ledger_account_debit: LedgerAccount,
- ledger_account_credit: LedgerAccount,
ledger_manager: LedgerManager,
):
with pytest.raises(expected_exception=ValueError) as excinfo:
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 dce9116..60eb71c 100644
--- a/tests/managers/thl/test_ledger/test_thl_lm_accounts.py
+++ b/tests/managers/thl/test_ledger/test_thl_lm_accounts.py
@@ -229,6 +229,7 @@ class TestThlLedgerManagerAccounts:
# (1) known account and confirm it comes back
res = ledger_manager.get_account(qualified_name=account1.qualified_name)
+ assert isinstance(res, LedgerAccount)
assert account1.model_dump_json() == res.model_dump_json()
# (2) known accounts and confirm they both come back
@@ -291,6 +292,7 @@ class TestThlLedgerManagerAccounts:
assert len(res) == 2
# Confirm an empty array comes back for all unknown qualified names
+ assert isinstance(ledger_manager.currency, LedgerCurrency)
res = ledger_manager.get_accounts_if_exists(
qualified_names=[
f"{ledger_manager.currency.value}:bp_wall:{uuid4().hex}"
@@ -328,7 +330,7 @@ class TestThlLedgerManagerAccounts:
product_uuids=product_uuids
)
assert len(res) == len(product_uuids)
- assert all([isinstance(i, LedgerAccount) for i in res])
+ assert all(isinstance(i, LedgerAccount) for i in res)
class TestLedgerAccountManager:
@@ -351,10 +353,10 @@ class TestLedgerAccountManager:
# First we want to validate that using the get_account method raises
# an error for a random LedgerAccount which we know does not exist.
with pytest.raises(LedgerAccountDoesntExistError):
- lam.get_account(qualified_name=account.qualified_name)
+ ledger_account_manager.get_account(qualified_name=account.qualified_name)
# Now that we know it doesn't exist, get_or_create for it
- instance = lam.get_account_or_create(account=account)
+ instance = ledger_account_manager.get_account_or_create(account=account)
# It should always return
assert isinstance(instance, LedgerAccount)
@@ -364,10 +366,11 @@ class TestLedgerAccountManager:
self,
user: User,
thl_ledger_manager: ThlLedgerManager,
- ledger_manager: LedgerManager,
ledger_account_manager: LedgerAccountManager,
):
+ assert isinstance(user.product, Product)
+
with pytest.raises(LedgerAccountDoesntExistError):
ledger_account_manager.get_account(
qualified_name=f"test:bp_wallet:{user.product.id}"
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 e4a25a3..b518453 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
@@ -133,16 +133,17 @@ class TestThlLedgerManagerBPPayout:
)
payoutevent_uuid = uuid4().hex
- with caplog.at_level(logging.INFO):
- with pytest.raises(LedgerTransactionConditionFailedError):
- thl_ledger_manager.create_tx_bp_payout(
- user.product,
- amount=USDCent(10_000),
- created=now + timedelta(minutes=2),
- skip_one_per_day_check=True,
- skip_wallet_balance_check=False,
- payoutevent_uuid=payoutevent_uuid,
- )
+ with caplog.at_level(logging.INFO), pytest.raises(
+ LedgerTransactionConditionFailedError
+ ):
+ thl_ledger_manager.create_tx_bp_payout(
+ user.product,
+ amount=USDCent(10_000),
+ created=now + timedelta(minutes=2),
+ skip_one_per_day_check=True,
+ skip_wallet_balance_check=False,
+ payoutevent_uuid=payoutevent_uuid,
+ )
assert "failed condition check balance:" in caplog.text
thl_ledger_manager.create_tx_bp_payout(
@@ -197,17 +198,18 @@ class TestThlLedgerManagerBPPayout:
assert balance == int(rand_amount) * -1
# Test some basic assertions
- with caplog.at_level(logging.INFO):
- with pytest.raises(expected_exception=Exception):
- thl_ledger_manager.create_tx_bp_payout(
- product=product,
- amount=rand_amount,
- payoutevent_uuid=uuid4().hex,
- created=datetime.now(tz=UTC),
- skip_wallet_balance_check=False,
- skip_one_per_day_check=False,
- skip_flag_check=False,
- )
+ with caplog.at_level(logging.INFO), pytest.raises(
+ expected_exception=ValueError
+ ):
+ thl_ledger_manager.create_tx_bp_payout(
+ product=product,
+ amount=rand_amount,
+ payoutevent_uuid=uuid4().hex,
+ created=datetime.now(tz=UTC),
+ skip_wallet_balance_check=False,
+ skip_one_per_day_check=False,
+ skip_flag_check=False,
+ )
assert "failed condition check >1 tx per day" in caplog.text
def test_create_tx_redis_failure(
@@ -291,7 +293,7 @@ class TestThlLedgerManagerBPPayout:
# Will fail due to multiple per day
payoutevent_uuid2 = uuid4().hex
with pytest.raises(expected_exception=Exception) as e:
- tx = thl_ledger_manager.create_tx_bp_payout(
+ thl_ledger_manager.create_tx_bp_payout(
product=product,
amount=rand_amount,
payoutevent_uuid=payoutevent_uuid2,
@@ -348,7 +350,7 @@ class TestThlLedgerManagerBPPayout:
# Create TX will fail on lock exit, after the tx was created!
with pytest.raises(expected_exception=Exception) as e:
- tx = thl_ledger_manager.create_tx_bp_payout(
+ thl_ledger_manager.create_tx_bp_payout(
product=product,
amount=rand_amount,
payoutevent_uuid=payoutevent_uuid,
@@ -384,7 +386,9 @@ class TestPayoutEventManagerBPPayout:
product, rand_amount, now, direction=Direction.CREDIT
)
assert thl_ledger_manager.get_account_balance(bp_wallet_account) == rand_amount
- brokerage_product_payout_event_manager.set_account_lookup_table(thl_lm=thl_lm)
+ brokerage_product_payout_event_manager.set_account_lookup_table(
+ thl_lm=thl_ledger_manager
+ )
pe = brokerage_product_payout_event_manager.create_bp_payout_event(
thl_ledger_manager=thl_ledger_manager,
@@ -557,7 +561,7 @@ class TestPayoutEventManagerBPPayout:
# Will fail on lock exit, after the tx was created!
# But it'll see that the tx was created and so everything will be fine
Lock.release = broken_release
- pe = brokerage_product_payout_event_manager.create_bp_payout_event(
+ brokerage_product_payout_event_manager.create_bp_payout_event(
thl_ledger_manager=thl_ledger_manager,
product=product,
created=now,
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 89adb0b..1860d6d 100644
--- a/tests/managers/thl/test_ledger/test_thl_lm_tx.py
+++ b/tests/managers/thl/test_ledger/test_thl_lm_tx.py
@@ -23,7 +23,6 @@ from generalresearch.models.thl.definitions import (
WALL_ALLOWED_STATUS_STATUS_CODE,
)
from generalresearch.models.thl.ledger import (
- AccountType,
Direction,
LedgerAccount,
TransactionType,
@@ -287,17 +286,18 @@ class TestThlLedgerTxManager:
assert balance == int(rand_amount) * -1
# Test some basic assertions
- with caplog.at_level(logging.INFO):
- with pytest.raises(expected_exception=Exception):
- thl_ledger_manager.create_tx_bp_payout(
- product=product,
- amount=rand_amount,
- payoutevent_uuid=uuid4().hex,
- created=datetime.now(tz=UTC),
- skip_wallet_balance_check=False,
- skip_one_per_day_check=False,
- skip_flag_check=False,
- )
+ with caplog.at_level(logging.INFO), pytest.raises(
+ expected_exception=ValueError
+ ):
+ thl_ledger_manager.create_tx_bp_payout(
+ product=product,
+ amount=rand_amount,
+ payoutevent_uuid=uuid4().hex,
+ created=datetime.now(tz=UTC),
+ skip_wallet_balance_check=False,
+ skip_one_per_day_check=False,
+ skip_flag_check=False,
+ )
assert "failed condition check >1 tx per day" in caplog.text
def test_create_tx_bp_payout_(
@@ -1794,7 +1794,7 @@ class TestThlLedgerManagerAdj:
)
thl_ledger_manager.create_tx_bp_payment(session, created=wall1.started)
- revenue = ththl_ledger_managerl_lm.get_account_task_complete_revenue()
+ revenue = thl_ledger_manager.get_account_task_complete_revenue()
bp_wallet_account = thl_ledger_manager.get_account_or_create_bp_wallet(
user.product
)
diff --git a/tests/managers/thl/test_payout.py b/tests/managers/thl/test_payout.py
index e6c597b..0f3f103 100644
--- a/tests/managers/thl/test_payout.py
+++ b/tests/managers/thl/test_payout.py
@@ -727,8 +727,6 @@ class TestBusinessPayoutEventManager:
# {"uuid": bp_pe.uuid, "status": PayoutStatus.FAILED},
# )
- assert 1 == 0
-
def test_ach_payment(
self,
mnt_filepath: GRLDatasets,
diff --git a/tests/managers/thl/test_survey.py b/tests/managers/thl/test_survey.py
index 2c2bf9d..c3ab162 100644
--- a/tests/managers/thl/test_survey.py
+++ b/tests/managers/thl/test_survey.py
@@ -11,9 +11,6 @@ from generalresearch.managers.thl.buyer import BuyerManager
from generalresearch.managers.thl.profiling.question import (
QuestionManager,
)
-from generalresearch.managers.thl.profiling.schema import (
- UpkSchemaManager,
-)
from generalresearch.managers.thl.profiling.uqa import UQAManager
from generalresearch.managers.thl.survey import SurveyManager, SurveyStatManager
from generalresearch.models import Source
@@ -183,7 +180,8 @@ class TestSurvey:
]
uqad = {}
for uqa in uqas:
- for k, _ in uqa.calc_answers.items():
+ assert uqa.calc_answers
+ for k in uqa.calc_answers:
if k in qualifying_questions:
uqad[k] = uqa
uqad[uqa.property_code] = uqa
diff --git a/tests/managers/thl/test_user_manager/test_base.py b/tests/managers/thl/test_user_manager/test_base.py
index 5822207..8cd83ad 100644
--- a/tests/managers/thl/test_user_manager/test_base.py
+++ b/tests/managers/thl/test_user_manager/test_base.py
@@ -21,7 +21,7 @@ from generalresearch.managers.thl.user_manager.user_manager import (
UserManager,
)
from generalresearch.managers.thl.userhealth import AuditLogManager
-from generalresearch.models.thl.product import Product, UserCreateConfig, product
+from generalresearch.models.thl.product import Product, UserCreateConfig
from generalresearch.models.thl.user import User
from generalresearch.pg_helper import PostgresConfig