aboutsummaryrefslogtreecommitdiff
path: root/tests/models
diff options
context:
space:
mode:
Diffstat (limited to 'tests/models')
-rw-r--r--tests/models/gr/test_authentication.py55
-rw-r--r--tests/models/gr/test_business.py86
-rw-r--r--tests/models/gr/test_team.py6
-rw-r--r--tests/models/test_finance.py14
-rw-r--r--tests/models/thl/test_payout.py2
-rw-r--r--tests/models/thl/test_product.py99
6 files changed, 147 insertions, 115 deletions
diff --git a/tests/models/gr/test_authentication.py b/tests/models/gr/test_authentication.py
index ac1298f..059a0a4 100644
--- a/tests/models/gr/test_authentication.py
+++ b/tests/models/gr/test_authentication.py
@@ -116,7 +116,7 @@ class TestGRUser:
class TestGRUserMethods:
- def test_cache_key(self, gr_user: GRUser, gr_redis: RedisConfig):
+ def test_cache_key(self, gr_user: GRUser):
assert isinstance(gr_user.cache_key, str)
assert ":" in gr_user.cache_key
assert str(gr_user.id) in gr_user.cache_key
@@ -124,13 +124,12 @@ class TestGRUserMethods:
def test_to_redis(
self,
gr_user: GRUser,
- gr_redis: Redis,
team: Team,
- business: Business,
+ gr_business: Business,
product_factory: Callable[..., Product],
membership_factory: Callable[..., Membership],
):
- product_factory(team=team, business=business)
+ product_factory(team=team, business=gr_business)
membership_factory(team=team, gr_user=gr_user)
res = gr_user.to_redis()
@@ -144,31 +143,30 @@ class TestGRUserMethods:
def test_set_cache(
self,
gr_user: GRUser,
- gr_user_token: GRToken,
- gr_redis: Redis,
gr_db: PostgresConfig,
thl_web_rr: PostgresConfig,
gr_redis_config: RedisConfig,
):
- assert gr_redis.get(name=gr_user.cache_key) is None
- assert gr_redis.get(name=f"{gr_user.cache_key}:team_uuids") is None
- assert gr_redis.get(name=f"{gr_user.cache_key}:business_uuids") is None
- assert gr_redis.get(name=f"{gr_user.cache_key}:product_uuids") is None
+
+ client = gr_redis_config.create_redis_client()
+
+ assert client.get(name=gr_user.cache_key) is None
+ assert client.get(name=f"{gr_user.cache_key}:team_uuids") is None
+ assert client.get(name=f"{gr_user.cache_key}:business_uuids") is None
+ assert client.get(name=f"{gr_user.cache_key}:product_uuids") is None
gr_user.set_cache(
pg_config=gr_db, thl_web_rr=thl_web_rr, redis_config=gr_redis_config
)
- assert gr_redis.get(name=gr_user.cache_key) is not None
- assert gr_redis.get(name=f"{gr_user.cache_key}:team_uuids") is not None
- assert gr_redis.get(name=f"{gr_user.cache_key}:business_uuids") is not None
- assert gr_redis.get(name=f"{gr_user.cache_key}:product_uuids") is not None
+ assert client.get(name=gr_user.cache_key) is not None
+ assert client.get(name=f"{gr_user.cache_key}:team_uuids") is not None
+ assert client.get(name=f"{gr_user.cache_key}:business_uuids") is not None
+ assert client.get(name=f"{gr_user.cache_key}:product_uuids") is not None
def test_set_cache_gr_user(
self,
gr_user: GRUser,
- gr_user_token: GRToken,
- gr_redis: RedisConfig,
gr_redis_config: RedisConfig,
gr_db: PostgresConfig,
thl_web_rr: PostgresConfig,
@@ -179,6 +177,8 @@ class TestGRUserMethods:
):
from generalresearch.models.gr.authentication import GRUser
+ client = gr_redis_config.create_redis_client()
+
p1 = product_factory(team=team)
membership_factory(team=team, gr_user=gr_user)
@@ -186,7 +186,7 @@ class TestGRUserMethods:
pg_config=gr_db, thl_web_rr=thl_web_rr, redis_config=gr_redis_config
)
- res: str = gr_redis.get(name=gr_user.cache_key)
+ res: str = client.get(name=gr_user.cache_key)
gru2 = GRUser.from_redis(res)
assert gr_user.model_dump_json(
@@ -203,9 +203,6 @@ class TestGRUserMethods:
def test_set_cache_team_uuids(
self,
gr_user: GRUser,
- membership: Membership,
- gr_user_token: GRToken,
- gr_redis: Redis,
gr_db: PostgresConfig,
thl_web_rr: PostgresConfig,
product_factory: Callable[..., Product],
@@ -213,11 +210,12 @@ class TestGRUserMethods:
gr_redis_config: RedisConfig,
):
product_factory(team=team)
+ client = gr_redis_config.create_redis_client()
gr_user.set_cache(
pg_config=gr_db, thl_web_rr=thl_web_rr, redis_config=gr_redis_config
)
- res = json.loads(gr_redis.get(name=f"{gr_user.cache_key}:team_uuids"))
+ res = json.loads(client.get(name=f"{gr_user.cache_key}:team_uuids"))
assert len(res) == 1
assert gr_user.team_uuids == res
@@ -225,29 +223,27 @@ class TestGRUserMethods:
def test_set_cache_business_uuids(
self,
gr_user: GRUser,
- gr_redis: Redis,
gr_db: PostgresConfig,
thl_web_rr: PostgresConfig,
product_factory: Callable[..., Product],
- business: Business,
+ gr_business: Business,
team: Team,
gr_redis_config: RedisConfig,
):
- product_factory(team=team, business=business)
+ product_factory(team=team, business=gr_business)
gr_user.set_cache(
pg_config=gr_db, thl_web_rr=thl_web_rr, redis_config=gr_redis_config
)
- res = json.loads(gr_redis.get(name=f"{gr_user.cache_key}:business_uuids"))
+
+ client = gr_redis_config.create_redis_client()
+ res = json.loads(client.get(name=f"{gr_user.cache_key}:business_uuids"))
assert len(res) == 1
assert gr_user.business_uuids == res
def test_set_cache_product_uuids(
self,
gr_user: GRUser,
- membership: Membership,
- gr_user_token: GRToken,
- gr_redis: Redis,
gr_db: PostgresConfig,
thl_web_rr: PostgresConfig,
product_factory: Callable[..., Product],
@@ -259,7 +255,8 @@ class TestGRUserMethods:
gr_user.set_cache(
pg_config=gr_db, thl_web_rr=thl_web_rr, redis_config=gr_redis_config
)
- res = json.loads(gr_redis.get(name=f"{gr_user.cache_key}:product_uuids"))
+ client = gr_redis_config.create_redis_client()
+ res = json.loads(client.get(name=f"{gr_user.cache_key}:product_uuids"))
assert len(res) == 1
assert gr_user.product_uuids == res
diff --git a/tests/models/gr/test_business.py b/tests/models/gr/test_business.py
index 2c12da1..90e69db 100644
--- a/tests/models/gr/test_business.py
+++ b/tests/models/gr/test_business.py
@@ -64,10 +64,8 @@ class TestBusinessBankAccount:
gr_business: Business,
business_bank_account_manager: BusinessBankAccountManager,
):
- from generalresearch.models.gr.business import (
- BusinessBankAccount,
- TransferMethod,
- )
+ from generalresearch.models.gr.business import BusinessBankAccount
+ from generalresearch.models.gr.definitions import TransferMethod
instance = business_bank_account_manager.create(
business_id=gr_business.id,
@@ -115,7 +113,7 @@ class TestBusiness:
@pytest.fixture
def offset(self) -> str:
- return "30d"
+ return "30D"
@pytest.fixture
def duration(self) -> timedelta | None:
@@ -222,46 +220,46 @@ class TestBusiness:
def test_teams(
self,
- business: Business,
+ gr_business: Business,
team: Team,
team_manager: TeamManager,
gr_db: PostgresConfig,
):
- assert business.teams is None
+ assert gr_business.teams is None
- business.prefetch_teams(pg_config=gr_db)
- assert isinstance(business.teams, list)
- assert len(business.teams) == 0
+ gr_business.prefetch_teams(pg_config=gr_db)
+ assert isinstance(gr_business.teams, list)
+ assert len(gr_business.teams) == 0
- team_manager.add_business(team=team, business=business)
- assert len(business.teams) == 0
- business.prefetch_teams(pg_config=gr_db)
- assert len(business.teams) == 1
+ team_manager.add_business(team=team, business=gr_business)
+ assert len(gr_business.teams) == 0
+ gr_business.prefetch_teams(pg_config=gr_db)
+ assert len(gr_business.teams) == 1
def test_products(
self,
- business: Business,
+ gr_business: Business,
product_factory: Callable[..., Product],
product_manager: ProductManager,
):
- p1 = product_factory(business=business)
- assert business.products is None
+ p1 = product_factory(business=gr_business)
+ assert gr_business.products is None
- business.prefetch_products(product_manager=product_manager)
- assert isinstance(business.products, list)
- assert len(business.products) == 1
- assert isinstance(business.products[0], Product)
+ gr_business.prefetch_products(product_manager=product_manager)
+ assert isinstance(gr_business.products, list)
+ assert len(gr_business.products) == 1
+ assert isinstance(gr_business.products[0], Product)
- assert business.products[0].uuid == p1.uuid
+ assert gr_business.products[0].uuid == p1.uuid
# Add two more, but list is still one until we prefetch
- product_factory(business=business)
- product_factory(business=business)
- assert len(business.products) == 1
+ product_factory(business=gr_business)
+ product_factory(business=gr_business)
+ assert len(gr_business.products) == 1
- business.prefetch_products(product_manager=product_manager)
- assert len(business.products) == 3
+ gr_business.prefetch_products(product_manager=product_manager)
+ assert len(gr_business.products) == 3
def test_bank_accounts(
self,
@@ -306,7 +304,6 @@ class TestBusiness:
self,
gr_business: Business,
product_factory: Callable[..., Product],
- thl_web_rr: PostgresConfig,
thl_ledger_manager: ThlLedgerManager,
business_payout_event_manager: BusinessPayoutEventManager,
):
@@ -322,8 +319,6 @@ class TestBusiness:
thl_ledger_manager.get_account_or_create_bp_wallet(product=p)
gr_business.prebuild_payouts(
- thl_pg_config=thl_web_rr,
- thl_lm=thl_ledger_manager,
bpem=business_payout_event_manager,
)
assert isinstance(gr_business.payouts, list)
@@ -335,7 +330,6 @@ class TestBusiness:
product_factory: Callable[..., Product],
bp_payout_factory: Callable[..., BrokerageProductPayoutEvent],
thl_ledger_manager: ThlLedgerManager,
- thl_web_rr: PostgresConfig,
business_payout_event_manager: BusinessPayoutEventManager,
create_main_accounts: Callable[..., None],
):
@@ -351,8 +345,6 @@ class TestBusiness:
)
gr_business.prebuild_payouts(
- thl_pg_config=thl_web_rr,
- thl_lm=thl_ledger_manager,
bpem=business_payout_event_manager,
)
assert len(gr_business.payouts) == 1
@@ -478,7 +470,7 @@ class TestBusinessBalance:
@pytest.fixture
def offset(self) -> str:
- return "30d"
+ return "30D"
@pytest.fixture
def duration(self) -> timedelta | None:
@@ -1190,15 +1182,14 @@ class TestBusinessMethods:
) -> timedelta | None:
return None
- def test_cache_key(self, business: Business):
- assert isinstance(business.cache_key, str)
- assert ":" in business.cache_key
- assert str(business.uuid) in business.cache_key
+ def test_cache_key(self, gr_business: Business):
+ assert isinstance(gr_business.cache_key, str)
+ assert ":" in gr_business.cache_key
+ assert str(gr_business.uuid) in gr_business.cache_key
def test_set_cache(
self,
gr_business: Business,
- gr_redis: RedisConfig,
gr_db: PostgresConfig,
thl_web_rr: PostgresConfig,
client_no_amm: DaskClient,
@@ -1218,7 +1209,8 @@ class TestBusinessMethods:
gr_redis_config: RedisConfig,
mnt_gr_api_dir: Path,
):
- assert gr_redis.get(name=gr_business.cache_key) is None
+ client = gr_redis_config.create_redis_client()
+ assert client.get(name=gr_business.cache_key) is None
p1 = product_factory(team=team, business=gr_business)
u1 = user_factory(product=p1)
@@ -1244,7 +1236,7 @@ class TestBusinessMethods:
mnt_gr_api=mnt_gr_api_dir,
)
- assert gr_redis.hgetall(name=gr_business.cache_key) is not None
+ assert client.hgetall(name=gr_business.cache_key) is not None
from generalresearch.models.gr.business import Business
# We're going to pull only a specific year, but make sure that
@@ -1367,7 +1359,7 @@ class TestBusinessMethods:
session_factory: Callable[..., Session],
product_factory: Callable[..., Product],
delete_df_collection: Callable[..., None],
- business: Business,
+ gr_business: Business,
mnt_filepath: GRLDatasets,
mnt_gr_api_dir: Path,
):
@@ -1375,8 +1367,8 @@ class TestBusinessMethods:
delete_df_collection(coll=wall_collection)
delete_df_collection(coll=session_collection)
- p1 = product_factory(business=business)
- p2 = product_factory(business=business)
+ p1 = product_factory(business=gr_business)
+ p2 = product_factory(business=gr_business)
for p in [p1, p2]:
u = user_factory(product=p)
@@ -1397,7 +1389,7 @@ class TestBusinessMethods:
pg_config=thl_web_rr,
)
- business.prebuild_enriched_session_parquet(
+ gr_business.prebuild_enriched_session_parquet(
thl_pg_config=thl_web_rr,
ds=mnt_filepath,
client=client_no_amm,
@@ -1407,7 +1399,9 @@ class TestBusinessMethods:
# Now try to read from path
df = pd.read_parquet(
- os.path.join(mnt_gr_api_dir, "pop_session", f"{business.file_key}.parquet")
+ os.path.join(
+ mnt_gr_api_dir, "pop_session", f"{gr_business.file_key}.parquet"
+ )
)
assert isinstance(df, pd.DataFrame)
diff --git a/tests/models/gr/test_team.py b/tests/models/gr/test_team.py
index c1ae6d6..aa2de45 100644
--- a/tests/models/gr/test_team.py
+++ b/tests/models/gr/test_team.py
@@ -152,7 +152,6 @@ class TestTeamMethods:
def test_set_cache(
self,
team: Team,
- gr_redis: RedisConfig,
gr_db: PostgresConfig,
thl_web_rr: PostgresConfig,
gr_redis_config: RedisConfig,
@@ -162,7 +161,8 @@ class TestTeamMethods:
enriched_wall_merge: EnrichedWallMerge,
enriched_session_merge: EnrichedSessionMerge,
):
- assert gr_redis.get(name=team.cache_key) is None
+ client = gr_redis_config.create_redis_client()
+ assert client.get(name=team.cache_key) is None
team.set_cache(
pg_config=gr_db,
@@ -175,7 +175,7 @@ class TestTeamMethods:
enriched_session=enriched_session_merge,
)
- assert gr_redis.hgetall(name=team.cache_key) is not None
+ assert client.hgetall(name=team.cache_key) is not None
def test_set_cache_team(
self,
diff --git a/tests/models/test_finance.py b/tests/models/test_finance.py
index eabc877..c579d78 100644
--- a/tests/models/test_finance.py
+++ b/tests/models/test_finance.py
@@ -760,7 +760,7 @@ class TestPOPFinancialData:
duration: timedelta,
create_main_accounts: Callable[..., None],
session_with_tx_factory: Callable[..., Session],
- thl_lm: ThlLedgerManager,
+ thl_ledger_manager: ThlLedgerManager,
delete_df_collection: Callable[..., None],
delete_ledger_db: Callable[..., None],
):
@@ -798,8 +798,10 @@ class TestPOPFinancialData:
last_item_finish = item_finishes[0]
accounts = []
- for _ in users:
- account = thl_lm.get_account_or_create_bp_wallet(product=u.product)
+ for _u in users:
+ account = thl_ledger_manager.get_account_or_create_bp_wallet(
+ product=_u.product
+ )
accounts.append(account)
account_ids = [a.uuid for a in accounts]
@@ -856,7 +858,7 @@ class TestBusinessBalanceData:
user_factory: Callable[..., User],
product: Product,
create_main_accounts: Callable[..., None],
- thl_lm: ThlLedgerManager,
+ thl_ledger_manager: ThlLedgerManager,
thl_web_rr: PostgresConfig,
delete_df_collection: Callable[..., None],
delete_ledger_db: Callable[..., None],
@@ -886,7 +888,9 @@ class TestBusinessBalanceData:
pop_ledger_merge.build(client=client_no_amm, ledger_coll=ledger_collection)
# assert pop_ledger_merge.progress.has_archive.eq(True).all()
- account: LedgerAccount = thl_lm.get_account_or_create_bp_wallet(product=product)
+ account: LedgerAccount = thl_ledger_manager.get_account_or_create_bp_wallet(
+ product=product
+ )
ddf = pop_ledger_merge.ddf(
force_rr_latest=False,
diff --git a/tests/models/thl/test_payout.py b/tests/models/thl/test_payout.py
index 927687e..cc00f33 100644
--- a/tests/models/thl/test_payout.py
+++ b/tests/models/thl/test_payout.py
@@ -10,8 +10,8 @@ from generalresearch.models.gr import Team
from generalresearch.models.gr.business import (
Business,
BusinessAddress,
- BusinessType,
)
+from generalresearch.models.gr.definitions import BusinessType
from generalresearch.models.thl.payout import (
BrokerageProductPayoutEvent,
BusinessPayoutEvent,
diff --git a/tests/models/thl/test_product.py b/tests/models/thl/test_product.py
index cc0fa8e..a1b3688 100644
--- a/tests/models/thl/test_product.py
+++ b/tests/models/thl/test_product.py
@@ -603,7 +603,7 @@ class TestProductFinancials:
@pytest.fixture
def offset(self) -> str:
- return "30d"
+ return "30D"
@pytest.fixture
def duration(self) -> timedelta | None:
@@ -611,12 +611,12 @@ class TestProductFinancials:
def test_balance(
self,
- business: Business,
+ gr_business: Business,
product_factory: Callable[..., Product],
user_factory: Callable[..., User],
mnt_filepath: GRLDatasets,
bp_payout_factory: Callable[..., BrokerageProductPayoutEvent],
- thl_lm: ThlLedgerManager,
+ thl_ledger_manager: ThlLedgerManager,
start: datetime,
brokerage_product_payout_event_manager: BrokerageProductPayoutEventManager,
session_with_tx_factory: Callable[..., Session],
@@ -633,33 +633,54 @@ class TestProductFinancials:
from generalresearch.currency import USDCent
- p1: Product = product_factory(business=business)
+ p1: Product = product_factory(business=gr_business)
u1: User = user_factory(product=p1)
- bp_wallet = thl_lm.get_account_or_create_bp_wallet(product=p1)
- thl_lm.get_account_or_create_user_wallet(user=u1)
+ bp_wallet = thl_ledger_manager.get_account_or_create_bp_wallet(product=p1)
+ thl_ledger_manager.get_account_or_create_user_wallet(user=u1)
brokerage_product_payout_event_manager.set_account_lookup_table(thl_lm=thl_lm)
- assert len(thl_lm.get_tx_filtered_by_account(account_uuid=bp_wallet.uuid)) == 0
+ assert (
+ len(
+ thl_ledger_manager.get_tx_filtered_by_account(
+ account_uuid=bp_wallet.uuid
+ )
+ )
+ == 0
+ )
session_with_tx_factory(
user=u1,
wall_req_cpi=Decimal(".50"),
started=start + timedelta(days=1),
)
- assert thl_lm.get_account_balance(account=bp_wallet) == 48
- assert len(thl_lm.get_tx_filtered_by_account(account_uuid=bp_wallet.uuid)) == 1
+ assert thl_ledger_manager.get_account_balance(account=bp_wallet) == 48
+ assert (
+ len(
+ thl_ledger_manager.get_tx_filtered_by_account(
+ account_uuid=bp_wallet.uuid
+ )
+ )
+ == 1
+ )
session_with_tx_factory(
user=u1,
wall_req_cpi=Decimal("1.00"),
started=start + timedelta(days=2),
)
- assert thl_lm.get_account_balance(account=bp_wallet) == 143
- assert len(thl_lm.get_tx_filtered_by_account(account_uuid=bp_wallet.uuid)) == 2
+ assert thl_ledger_manager.get_account_balance(account=bp_wallet) == 143
+ assert (
+ len(
+ thl_ledger_manager.get_tx_filtered_by_account(
+ account_uuid=bp_wallet.uuid
+ )
+ )
+ == 2
+ )
with pytest.raises(expected_exception=AssertionError) as cm:
p1.prebuild_balance(
- thl_lm=thl_lm,
+ thl_lm=thl_ledger_manager,
ds=mnt_filepath,
client=client_no_amm,
)
@@ -669,7 +690,7 @@ class TestProductFinancials:
pop_ledger_merge.build(client=client_no_amm, ledger_coll=ledger_collection)
p1.prebuild_balance(
- thl_lm=thl_lm,
+ thl_lm=thl_ledger_manager,
ds=mnt_filepath,
client=client_no_amm,
)
@@ -683,7 +704,7 @@ class TestProductFinancials:
assert p1.balance.available_balance == 108
p1.prebuild_payouts(
- thl_lm=thl_lm,
+ thl_lm=thl_ledger_manager,
bp_pem=brokerage_product_payout_event_manager,
)
assert p1.payouts is not None
@@ -700,7 +721,14 @@ class TestProductFinancials:
skip_wallet_balance_check=True,
skip_one_per_day_check=True,
)
- assert len(thl_lm.get_tx_filtered_by_account(account_uuid=bp_wallet.uuid)) == 3
+ assert (
+ len(
+ thl_ledger_manager.get_tx_filtered_by_account(
+ account_uuid=bp_wallet.uuid
+ )
+ )
+ == 3
+ )
# RM the entire directories
shutil.rmtree(ledger_collection.archive_path)
@@ -712,7 +740,7 @@ class TestProductFinancials:
pop_ledger_merge.build(client=client_no_amm, ledger_coll=ledger_collection)
p1.prebuild_balance(
- thl_lm=thl_lm,
+ thl_lm=thl_ledger_manager,
ds=mnt_filepath,
client=client_no_amm,
)
@@ -726,7 +754,7 @@ class TestProductFinancials:
assert p1.balance.available_balance == 70
p1.prebuild_payouts(
- thl_lm=thl_lm,
+ thl_lm=thl_ledger_manager,
bp_pem=brokerage_product_payout_event_manager,
)
assert p1.payouts is not None
@@ -743,7 +771,14 @@ class TestProductFinancials:
skip_wallet_balance_check=True,
skip_one_per_day_check=True,
)
- assert len(thl_lm.get_tx_filtered_by_account(account_uuid=bp_wallet.uuid)) == 4
+ assert (
+ len(
+ thl_ledger_manager.get_tx_filtered_by_account(
+ account_uuid=bp_wallet.uuid
+ )
+ )
+ == 4
+ )
# RM the entire directories
shutil.rmtree(ledger_collection.archive_path)
@@ -755,7 +790,7 @@ class TestProductFinancials:
pop_ledger_merge.build(client=client_no_amm, ledger_coll=ledger_collection)
p1.prebuild_balance(
- thl_lm=thl_lm,
+ thl_lm=thl_ledger_manager,
ds=mnt_filepath,
client=client_no_amm,
)
@@ -769,7 +804,7 @@ class TestProductFinancials:
assert p1.balance.available_balance == 66
p1.prebuild_payouts(
- thl_lm=thl_lm,
+ thl_lm=thl_ledger_manager,
bp_pem=brokerage_product_payout_event_manager,
)
assert p1.payouts is not None
@@ -786,7 +821,7 @@ class TestProductBalance:
@pytest.fixture
def offset(self) -> str:
- return "30d"
+ return "30D"
@pytest.fixture
def duration(self) -> timedelta | None:
@@ -796,7 +831,7 @@ class TestProductBalance:
self,
product: Product,
mnt_filepath: GRLDatasets,
- thl_lm: ThlLedgerManager,
+ thl_ledger_manager: ThlLedgerManager,
client_no_amm: DaskClient,
delete_ledger_db: Callable[..., None],
create_main_accounts: Callable[..., None],
@@ -826,7 +861,7 @@ class TestProductBalance:
pop_ledger_merge.build(client=client_no_amm, ledger_coll=ledger_collection)
# 2. Payout and build Parquets 2nd time
- payout_event_manager.set_account_lookup_table(thl_lm=thl_lm)
+ payout_event_manager.set_account_lookup_table(thl_lm=thl_ledger_manager)
bp_payout_factory(
product=product,
amount=USDCent(71),
@@ -840,7 +875,7 @@ class TestProductBalance:
with pytest.raises(expected_exception=AssertionError) as cm:
product.prebuild_balance(
- thl_lm=thl_lm, ds=mnt_filepath, client=client_no_amm
+ thl_lm=thl_ledger_manager, ds=mnt_filepath, client=client_no_amm
)
assert "Sql and Parquet Balance inconsistent" in str(cm)
@@ -848,7 +883,7 @@ class TestProductBalance:
self,
product: Product,
mnt_filepath: GRLDatasets,
- thl_lm: ThlLedgerManager,
+ thl_ledger_manager: ThlLedgerManager,
client_no_amm: DaskClient,
delete_ledger_db: Callable[..., None],
create_main_accounts: Callable[..., None],
@@ -885,7 +920,7 @@ class TestProductBalance:
# 2. Payout and build Parquets 2nd time but this payout is "now"
# so it hasn't already been archived
- payout_event_manager.set_account_lookup_table(thl_lm=thl_lm)
+ payout_event_manager.set_account_lookup_table(thl_lm=thl_ledger_manager)
bp_payout_factory(
product=product,
amount=USDCent(71),
@@ -898,7 +933,9 @@ class TestProductBalance:
pop_ledger_merge.build(client=client_no_amm, ledger_coll=ledger_collection)
# We just want to call this to confirm it doesn't raise.
- product.prebuild_balance(thl_lm=thl_lm, ds=mnt_filepath, client=client_no_amm)
+ product.prebuild_balance(
+ thl_lm=thl_ledger_manager, ds=mnt_filepath, client=client_no_amm
+ )
class TestProductPOPFinancial:
@@ -909,7 +946,7 @@ class TestProductPOPFinancial:
@pytest.fixture
def offset(self) -> str:
- return "30d"
+ return "30D"
@pytest.fixture
def duration(self) -> timedelta | None:
@@ -919,7 +956,7 @@ class TestProductPOPFinancial:
self,
product: Product,
mnt_filepath: GRLDatasets,
- thl_lm: ThlLedgerManager,
+ thl_ledger_manager: ThlLedgerManager,
client_no_amm: DaskClient,
delete_ledger_db: Callable[..., None],
create_main_accounts: Callable[..., None],
@@ -955,7 +992,7 @@ class TestProductPOPFinancial:
# --- test ---
assert product.pop_financial is None
product.prebuild_pop_financial(
- thl_lm=thl_lm,
+ thl_lm=thl_ledger_manager,
ds=mnt_filepath,
client=client_no_amm,
pop_ledger=pop_ledger_merge,
@@ -982,7 +1019,7 @@ class TestProductCache:
@pytest.fixture
def offset(self) -> str:
- return "30d"
+ return "30D"
@pytest.fixture
def duration(self) -> timedelta | None: