aboutsummaryrefslogtreecommitdiff
path: root/test_utils
diff options
context:
space:
mode:
authorGreg Stupp2026-10-23 03:20:59 +0000
committerGreg Stupp2026-10-23 03:20:59 +0000
commitaf5c3e97a8afb31f5219d4cdd9d752b7f2b2aa3b (patch)
treecd182fdd65de736cb9c93a59bc40f1e1e2360dde /test_utils
parent292860a9569e08f9f58c49802ee1f25cd39f9be1 (diff)
parent45d66cd40d409a8a05c8dde7193f1e8469058fff (diff)
downloadgeneralresearch-af5c3e97a8afb31f5219d4cdd9d752b7f2b2aa3b.tar.gz
generalresearch-af5c3e97a8afb31f5219d4cdd9d752b7f2b2aa3b.zip
Merges pull request #12 HEADv3.9.1master
virtual incentives and BrokerageProductLedgerTransaction
Diffstat (limited to 'test_utils')
-rw-r--r--test_utils/managers/conftest.py32
-rw-r--r--test_utils/models/thl/conftest.py10
2 files changed, 34 insertions, 8 deletions
diff --git a/test_utils/managers/conftest.py b/test_utils/managers/conftest.py
index a9f92a2..d78332e 100644
--- a/test_utils/managers/conftest.py
+++ b/test_utils/managers/conftest.py
@@ -31,6 +31,7 @@ from generalresearch.models.definitions import Source
from generalresearch.models.thl.wallet.cashout_method import (
CashoutMethod,
TangoCashoutMethodData,
+ VICashoutMethodData,
)
from generalresearch.models.thl.wallet.definitions import Currency, PayoutType
@@ -177,12 +178,13 @@ def setup_cashoutmethod_db(
cashout_method_manager: CashoutMethodManager,
delete_cashoutmethod_db: Callable[..., None],
example_tango_cashout_methods: list[CashoutMethod],
+ example_vi_cashout_methods: list[CashoutMethod],
) -> Callable[..., None]:
def _inner():
delete_cashoutmethod_db()
- for x in example_tango_cashout_methods:
+ for x in example_tango_cashout_methods + example_vi_cashout_methods:
cashout_method_manager.create(x)
return _inner
@@ -199,8 +201,7 @@ def random_ext_id_factory(base: str = "U02") -> Callable[..., str]:
@pytest.fixture(scope="session")
-def example_tango_cashout_methods(
-) -> list[CashoutMethod]:
+def example_tango_cashout_methods() -> list[CashoutMethod]:
return [
CashoutMethod(
id=uuid4().hex,
@@ -237,6 +238,31 @@ def example_tango_cashout_methods(
]
+@pytest.fixture(scope="session")
+def example_vi_cashout_methods() -> list[CashoutMethod]:
+ return [
+ CashoutMethod(
+ id=uuid4().hex,
+ type=PayoutType.VIRTUAL_INCENTIVES,
+ ext_id="AMAZON-US",
+ name="Amazon.com Gift Card",
+ description="Amazon.com Gift Card",
+ data=VICashoutMethodData(
+ sku="AMAZON-US",
+ value_type="variable",
+ marketing="Amazon marketing copy",
+ terms="Amazon terms",
+ ),
+ user=None,
+ image_url="https://example.com/amazon.png",
+ currency=Currency.USD,
+ original_currency=Currency.USD,
+ min_value=500,
+ max_value=25_000,
+ )
+ ]
+
+
# === THL: Marketplaces ===
diff --git a/test_utils/models/thl/conftest.py b/test_utils/models/thl/conftest.py
index a8ad037..4c93119 100644
--- a/test_utils/models/thl/conftest.py
+++ b/test_utils/models/thl/conftest.py
@@ -607,16 +607,14 @@ def user_failed_attempt_credit(
@pytest.fixture
def user_payout_event_factory(
- user_payout_event_manager: UserPayoutEventManager,
+ user_payout_event_manager: UserPayoutEventManager, thl_ledger_manager: ThlLedgerManager
) -> Callable[..., UserPayoutEvent]:
def _inner(
+ user: User,
uuid: UUIDStr | None = None,
debit_account_uuid: UUIDStr | None = None,
- account_reference_type: str | None = None,
- account_reference_uuid: UUIDStr | None = None,
cashout_method_uuid: UUIDStr | None = None,
- description: str | None = None,
created: AwareDatetimeISO | None = None,
amount: PositiveInt | None = None,
status: PayoutStatus | None = None,
@@ -626,7 +624,9 @@ def user_payout_event_factory(
order_data: dict[str, Any] | CashMailOrderData | None = None,
) -> UserPayoutEvent:
- debit_account_uuid = debit_account_uuid or uuid4().hex
+ wallet = thl_ledger_manager.get_account_or_create_user_wallet(user)
+
+ debit_account_uuid = wallet.uuid
cashout_method_uuid = cashout_method_uuid or uuid4().hex
amount = amount or randint(a=99, b=9_999)
status = status or rand_choice(list(PayoutStatus))