aboutsummaryrefslogtreecommitdiff
path: root/test_utils/managers
diff options
context:
space:
mode:
Diffstat (limited to 'test_utils/managers')
-rw-r--r--test_utils/managers/cashout_methods.py9
-rw-r--r--test_utils/managers/conftest.py33
-rw-r--r--test_utils/managers/contest/conftest.py15
-rw-r--r--test_utils/managers/ledger/conftest.py45
4 files changed, 52 insertions, 50 deletions
diff --git a/test_utils/managers/cashout_methods.py b/test_utils/managers/cashout_methods.py
index 96d33cf..b201e8c 100644
--- a/test_utils/managers/cashout_methods.py
+++ b/test_utils/managers/cashout_methods.py
@@ -1,12 +1,11 @@
-from generalresearch.models.thl.wallet import PayoutType, Currency
+import random
+from uuid import uuid4
+
+from generalresearch.models.thl.wallet import Currency, PayoutType
from generalresearch.models.thl.wallet.cashout_method import (
CashoutMethod,
TangoCashoutMethodData,
- AmtCashoutMethodData,
)
-import random
-
-from uuid import uuid4
def random_ext_id(base: str = "U02"):
diff --git a/test_utils/managers/conftest.py b/test_utils/managers/conftest.py
index 94dabae..10ee8ea 100644
--- a/test_utils/managers/conftest.py
+++ b/test_utils/managers/conftest.py
@@ -35,6 +35,7 @@ if TYPE_CHECKING:
MembershipManager,
TeamManager,
)
+ from generalresearch.managers.thl.buyer import BuyerManager
from generalresearch.managers.thl.category import CategoryManager
from generalresearch.managers.thl.contest_manager import ContestManager
from generalresearch.managers.thl.ipinfo import (
@@ -73,8 +74,6 @@ if TYPE_CHECKING:
)
from generalresearch.managers.thl.userhealth import (
AuditLogManager,
- IPGeonameManager,
- IPInformationManager,
IPRecordManager,
UserIpHistoryManager,
)
@@ -82,6 +81,7 @@ if TYPE_CHECKING:
WallCacheManager,
WallManager,
)
+ from generalresearch.models.thl.user import User
# === THL ===
@@ -98,7 +98,7 @@ def ltxm(
)
return LedgerTransactionManager(
- sql_helper=thl_web_rw,
+ pg_config=thl_web_rw,
permissions=[Permission.CREATE, Permission.READ],
testing=True,
redis_config=thl_redis_config,
@@ -335,7 +335,7 @@ def category_manager(thl_web_rw: PostgresConfig) -> "CategoryManager":
@pytest.fixture(scope="session")
-def buyer_manager(thl_web_rw: PostgresConfig):
+def buyer_manager(thl_web_rw: PostgresConfig) -> "BuyerManager":
# assert "/unittest-" in thl_web_rw.dsn.path
from generalresearch.managers.thl.buyer import BuyerManager
@@ -359,7 +359,7 @@ def surveystat_manager(thl_web_rw: PostgresConfig):
@pytest.fixture(scope="session")
-def surveypenalty_manager(thl_redis_config):
+def surveypenalty_manager(thl_redis_config: RedisConfig):
from generalresearch.managers.thl.survey_penalty import SurveyPenaltyManager
return SurveyPenaltyManager(redis_config=thl_redis_config)
@@ -404,7 +404,7 @@ def uqa_manager(thl_web_rw: PostgresConfig, thl_redis_config: RedisConfig):
@pytest.fixture(scope="function")
-def uqa_manager_clear_cache(uqa_manager, user):
+def uqa_manager_clear_cache(uqa_manager, user: "User"):
# On successive py-test/jenkins runs, the cache may contain
# the previous run's info (keyed under the same user_id)
uqa_manager.clear_cache(user)
@@ -484,23 +484,34 @@ def geoipinfo_manager(
@pytest.fixture(scope="session")
-def maxmind_basic_manager() -> "MaxmindBasicManager":
+def maxmind_basic_manager(settings: "GRLBaseSettings") -> "MaxmindBasicManager":
from generalresearch.managers.thl.maxmind.basic import (
MaxmindBasicManager,
)
- return MaxmindBasicManager(data_dir="/tmp/")
+ return MaxmindBasicManager(
+ data_dir="/tmp/",
+ maxmind_account_id=settings.maxmind_account_id,
+ maxmind_license_key=settings.maxmind_license_key,
+ )
@pytest.fixture(scope="session")
def maxmind_manager(
- thl_web_rw: PostgresConfig, thl_redis_config: RedisConfig
+ settings: "GRLBaseSettings",
+ thl_web_rw: PostgresConfig,
+ thl_redis_config: RedisConfig,
) -> "MaxmindManager":
assert "/unittest-" in thl_web_rw.dsn.path
from generalresearch.managers.thl.maxmind import MaxmindManager
- return MaxmindManager(pg_config=thl_web_rw, redis_config=thl_redis_config)
+ return MaxmindManager(
+ pg_config=thl_web_rw,
+ redis_config=thl_redis_config,
+ maxmind_account_id=settings.maxmind_account_id,
+ maxmind_license_key=settings.maxmind_license_key,
+ )
@pytest.fixture(scope="session")
@@ -700,7 +711,7 @@ def grliq_crr(grliq_db: PostgresConfig) -> "GrlIqCategoryResultsReader":
@pytest.fixture(scope="session")
-def delete_buyers_surveys(thl_web_rw: PostgresConfig, buyer_manager):
+def delete_buyers_surveys(thl_web_rw: PostgresConfig, buyer_manager: "BuyerManager"):
# assert "/unittest-" in thl_web_rw.dsn.path
thl_web_rw.execute_write(
"""
diff --git a/test_utils/managers/contest/conftest.py b/test_utils/managers/contest/conftest.py
index 0a25185..fb0b44b 100644
--- a/test_utils/managers/contest/conftest.py
+++ b/test_utils/managers/contest/conftest.py
@@ -9,26 +9,15 @@ from generalresearch.currency import USDCent
if TYPE_CHECKING:
from generalresearch.managers.thl.contest_manager import ContestManager
- from generalresearch.models.thl.contest import (
- ContestEndCondition,
- ContestPrize,
- )
+ from generalresearch.managers.thl.ledger_manager.thl_ledger import ThlLedgerManager
from generalresearch.models.thl.contest.contest import Contest
- from generalresearch.models.thl.contest.definitions import (
- ContestPrizeKind,
- ContestType,
- )
- from generalresearch.models.thl.contest.io import contest_create_to_contest
from generalresearch.models.thl.contest.leaderboard import (
LeaderboardContestCreate,
)
from generalresearch.models.thl.contest.milestone import (
- ContestEntryTrigger,
MilestoneContestCreate,
- MilestoneContestEndCondition,
)
from generalresearch.models.thl.contest.raffle import (
- ContestEntryType,
RaffleContestCreate,
)
from generalresearch.models.thl.product import Product
@@ -273,7 +262,7 @@ def user_with_money(
request,
user_factory: Callable[..., "User"],
product_user_wallet_yes: "Product",
- thl_lm,
+ thl_lm: "ThlLedgerManager",
) -> "User":
from generalresearch.models.thl.user import User
diff --git a/test_utils/managers/ledger/conftest.py b/test_utils/managers/ledger/conftest.py
index aafdaf7..c66ee4e 100644
--- a/test_utils/managers/ledger/conftest.py
+++ b/test_utils/managers/ledger/conftest.py
@@ -10,14 +10,11 @@ from generalresearch.currency import USDCent
from generalresearch.managers.base import PostgresManager
from test_utils.models.conftest import (
payout_config,
- product,
product_amt_true,
- product_factory,
product_user_wallet_no,
product_user_wallet_yes,
session,
session_factory,
- user,
user_factory,
wall,
wall_factory,
@@ -36,23 +33,24 @@ _ = (
)
if TYPE_CHECKING:
- from datetime import datetime, timedelta
from generalresearch.currency import LedgerCurrency
from generalresearch.managers.thl.ledger_manager.ledger import LedgerManager
from generalresearch.managers.thl.ledger_manager.thl_ledger import (
ThlLedgerManager,
)
+ from generalresearch.managers.thl.payout import (
+ BrokerageProductPayoutEventManager,
+ BusinessPayoutEventManager,
+ )
+ from generalresearch.managers.thl.session import SessionManager
+ from generalresearch.managers.thl.wall import WallManager
from generalresearch.models.thl.ledger import (
- AccountType,
- Direction,
LedgerAccount,
- LedgerEntry,
LedgerTransaction,
)
from generalresearch.models.thl.payout import (
BrokerageProductPayoutEvent,
- UserPayoutEvent,
)
from generalresearch.models.thl.product import Product
from generalresearch.models.thl.session import Session
@@ -185,10 +183,10 @@ def usd_cent(request) -> USDCent:
@pytest.fixture
def bp_payout_event(
product: "Product",
- usd_cent,
- business_payout_event_manager,
+ usd_cent: "USDCent",
+ business_payout_event_manager: "BusinessPayoutEventManager",
thl_lm: "ThlLedgerManager",
-) -> "UserPayoutEvent":
+) -> "BrokerageProductPayoutEvent":
return business_payout_event_manager.create_bp_payout_event(
thl_ledger_manager=thl_lm,
@@ -227,6 +225,7 @@ def bp_payout_event_factory(
@pytest.fixture
def currency(lm: "LedgerManager") -> "LedgerCurrency":
# return request.param if hasattr(request, "currency") else LedgerCurrency.TEST
+ assert lm.currency, "LedgerManager must have a currency specified for these tests"
return lm.currency
@@ -242,11 +241,11 @@ def tx_metadata(request) -> Optional[Dict[str, str]]:
@pytest.fixture
def ledger_tx(
request,
- ledger_account_credit,
- ledger_account_debit,
- tag,
+ ledger_account_credit: "LedgerAccount",
+ ledger_account_debit: "LedgerAccount",
+ tag: str,
currency: "LedgerCurrency",
- tx_metadata,
+ tx_metadata: Optional[Dict[str, str]],
lm: "LedgerManager",
) -> "LedgerTransaction":
from generalresearch.models.thl.ledger import Direction, LedgerEntry
@@ -455,7 +454,7 @@ def account_expense_tango(
@pytest.fixture
def user_account_user_wallet(
- lm: "LedgerManager", user, currency: "LedgerCurrency"
+ lm: "LedgerManager", user: "User", currency: "LedgerCurrency"
) -> "LedgerAccount":
from generalresearch.models.thl.ledger import (
AccountType,
@@ -580,8 +579,8 @@ def session_with_tx_factory(
user_factory: Callable[..., "User"],
product: "Product",
session_factory: Callable[..., "Session"],
- session_manager,
- wall_manager,
+ session_manager: "SessionManager",
+ wall_manager: "WallManager",
utc_hour_ago: datetime,
thl_lm: "ThlLedgerManager",
) -> Callable[..., "Session"]:
@@ -616,7 +615,7 @@ def session_with_tx_factory(
)
status, status_code_1 = s.determine_session_status()
- thl_net, commission_amount, bp_pay, user_pay = s.determine_payments()
+ _, _, bp_pay, user_pay = s.determine_payments()
session_manager.finish_with_status(
session=s,
finished=last_wall.finished,
@@ -642,7 +641,9 @@ def session_with_tx_factory(
@pytest.fixture
def adj_to_fail_with_tx_factory(
- session_manager, wall_manager, thl_lm: "ThlLedgerManager"
+ session_manager: "SessionManager",
+ wall_manager: "WallManager",
+ thl_lm: "ThlLedgerManager",
) -> Callable[..., None]:
from datetime import datetime, timedelta
@@ -698,7 +699,9 @@ def adj_to_fail_with_tx_factory(
@pytest.fixture
def adj_to_complete_with_tx_factory(
- session_manager, wall_manager, thl_lm: "ThlLedgerManager"
+ session_manager: "SessionManager",
+ wall_manager: "WallManager",
+ thl_lm: "ThlLedgerManager",
) -> Callable[..., None]:
from datetime import timedelta