aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/models/gr/test_business.py6
-rw-r--r--tests/models/gr/test_team.py4
-rw-r--r--tests/models/test_finance.py11
-rw-r--r--tests/models/thl/test_user_iphistory.py7
4 files changed, 18 insertions, 10 deletions
diff --git a/tests/models/gr/test_business.py b/tests/models/gr/test_business.py
index e38850d..8de2a47 100644
--- a/tests/models/gr/test_business.py
+++ b/tests/models/gr/test_business.py
@@ -11,11 +11,6 @@ from uuid import uuid4
import pandas as pd
import pytest
from dask.distributed import Client as DaskClient
-
-# noinspection PyUnresolvedReferences
-from distributed.utils_test import (
- client_no_amm,
-)
from pytest import approx
from generalresearch.currency import USDCent
@@ -699,6 +694,7 @@ class TestBusinessBalance:
pop_ledger_merge: PopLedgerMerge,
adj_to_fail_with_tx_factory: Callable[..., None],
delete_df_collection: Callable[..., None],
+ client_no_amm: DaskClient,
):
"""
- Product 1 $2.50 Complete
diff --git a/tests/models/gr/test_team.py b/tests/models/gr/test_team.py
index e853817..7c93209 100644
--- a/tests/models/gr/test_team.py
+++ b/tests/models/gr/test_team.py
@@ -107,7 +107,7 @@ class TestTeam:
self,
gr_team: Team,
gr_business: Business,
- team_manager: TeamManager,
+ gr_team_manager: TeamManager,
gr_business_manager: BusinessManager,
):
@@ -117,7 +117,7 @@ class TestTeam:
assert isinstance(gr_team.businesses, list)
assert len(gr_team.businesses) == 0
- team_manager.add_business(team=gr_team, business=gr_business)
+ gr_team_manager.add_business(team=gr_team, business=gr_business)
assert len(gr_team.businesses) == 0
gr_team.prefetch_businesses(gr_business_manager=gr_business_manager)
assert len(gr_team.businesses) == 1
diff --git a/tests/models/test_finance.py b/tests/models/test_finance.py
index a1da961..53df014 100644
--- a/tests/models/test_finance.py
+++ b/tests/models/test_finance.py
@@ -2,6 +2,7 @@ from __future__ import annotations
from collections.abc import Callable
from datetime import UTC, datetime, timedelta
+from decimal import Decimal
from itertools import product as iter_product
from random import randint
from typing import TYPE_CHECKING
@@ -839,16 +840,22 @@ class TestBusinessBalanceData:
delete_df_collection(coll=ledger_collection)
rm_ledger_collection()
+ # We're expecting 5 time periods x 5 $.50 complete (minus 5% commission = $0.48)
+ # = $12.00
for _ in range(5):
u: User = user_factory(product=product, created=ledger_collection.start)
for item in ledger_collection.items:
+ # A time may be randomly outside the date range, as the
+ # session_with_tx_factory adds time to each wall event it creates
item_time = fake.date_time_between(
start_date=item.start,
- end_date=item.finish,
+ end_date=item.finish - timedelta(minutes=10),
tzinfo=UTC,
)
- session_with_tx_factory(started=item_time, user=u)
+ session_with_tx_factory(
+ started=item_time, user=u, wall_req_cpi=Decimal("0.50")
+ )
item.initial_load(overwrite=True)
# Confirm any of the items are archived
diff --git a/tests/models/thl/test_user_iphistory.py b/tests/models/thl/test_user_iphistory.py
index b8a0be3..efd5168 100644
--- a/tests/models/thl/test_user_iphistory.py
+++ b/tests/models/thl/test_user_iphistory.py
@@ -1,11 +1,13 @@
from __future__ import annotations
from datetime import UTC, datetime, timedelta
+from uuid import uuid4
from generalresearch.models.thl.user_iphistory import (
UserIPHistory,
UserIPRecord,
)
+from generalresearch.models.thl.user_ref import UserRef
def test_collapse_ip_records():
@@ -33,7 +35,10 @@ def test_collapse_ip_records():
),
UserIPRecord(ip="1.2.3.6", created=now + timedelta(minutes=7)),
]
- iph = UserIPHistory(user_id=1, ips=records)
+ iph = UserIPHistory(
+ user=UserRef(user_id=1, product_user_id=uuid4().hex, product_id=uuid4().hex),
+ ips=records,
+ )
res = iph.collapse_ip_records()
# We should be left with one of the 1.2.3.5 ipv4s,