diff options
| author | Max Nanis | 2026-09-03 11:20:32 -0700 |
|---|---|---|
| committer | Max Nanis | 2026-09-03 11:20:32 -0700 |
| commit | b2450fa8be202941bb1b3770267fe6b9215d4c27 (patch) | |
| tree | bee446198b8aa2f6472e99e17765a8f101d5cf2b | |
| parent | 3c4fdaf7804999bcadc32bc6bb6fce2ad0435a61 (diff) | |
| download | generalresearch-b2450fa8be202941bb1b3770267fe6b9215d4c27.tar.gz generalresearch-b2450fa8be202941bb1b3770267fe6b9215d4c27.zip | |
pytest tests -vs RUNS, but obv doesn't all PASS
| -rw-r--r-- | generalresearch/incite/collections/base.py | 8 | ||||
| -rw-r--r-- | generalresearch/managers/marketplace/__init__.py | 23 | ||||
| -rw-r--r-- | generalresearch/managers/marketplace/managers.py | 23 | ||||
| -rw-r--r-- | generalresearch/models/cint/question.py | 5 | ||||
| -rw-r--r-- | generalresearch/models/precision/question.py | 5 | ||||
| -rw-r--r-- | generalresearch/models/sago/question.py | 7 | ||||
| -rw-r--r-- | generalresearch/models/spectrum/question.py | 9 | ||||
| -rw-r--r-- | generalresearch/thl_django/app/test_settings.py | 2 | ||||
| -rw-r--r-- | tests/incite/collections/test_df_collection_item_thl_web.py | 126 | ||||
| -rw-r--r-- | tests/incite/collections/test_df_collection_thl_marketplaces.py | 8 | ||||
| -rw-r--r-- | tests/incite/collections/test_df_collection_thl_web.py | 7 | ||||
| -rw-r--r-- | tests/incite/mergers/test_merge_collection.py | 8 | ||||
| -rw-r--r-- | tests/models/test_finance.py | 43 |
13 files changed, 143 insertions, 131 deletions
diff --git a/generalresearch/incite/collections/base.py b/generalresearch/incite/collections/base.py index bf6d9ce..47bb70a 100644 --- a/generalresearch/incite/collections/base.py +++ b/generalresearch/incite/collections/base.py @@ -3,6 +3,7 @@ from __future__ import annotations import os import subprocess import time +import warnings from datetime import datetime from enum import StrEnum from sys import platform @@ -644,9 +645,14 @@ class DFCollection(CollectionBase): return items @property - def _schema(self) -> DataFrameSchema: + def type_schema(self) -> DataFrameSchema: return DFCollectionTypeSchemas[self.data_type] + @property + def _schema(self) -> DataFrameSchema: + warnings.deprecated("The _schema attribute on DFCollection is Deprecated") + return self.type_schema + # --- Methods --- def initial_load( diff --git a/generalresearch/managers/marketplace/__init__.py b/generalresearch/managers/marketplace/__init__.py index 3349434..e69de29 100644 --- a/generalresearch/managers/marketplace/__init__.py +++ b/generalresearch/managers/marketplace/__init__.py @@ -1,23 +0,0 @@ -from generalresearch.managers.cint.user_pid import CintUserPidManager -from generalresearch.managers.dynata.user_pid import DynataUserPidManager -from generalresearch.managers.innovate.user_pid import InnovateUserPidManager -from generalresearch.managers.morning.user_pid import MorningUserPidManager -from generalresearch.managers.precision.user_pid import PrecisionUserPidManager -from generalresearch.managers.prodege.user_pid import ProdegeUserPidManager -from generalresearch.managers.repdata.user_pid import RepdataUserPidManager -from generalresearch.managers.sago.user_pid import SagoUserPidManager -from generalresearch.managers.spectrum.user_pid import SpectrumUserPidManager - -_managers = [ - CintUserPidManager, - DynataUserPidManager, - InnovateUserPidManager, - MorningUserPidManager, - PrecisionUserPidManager, - ProdegeUserPidManager, - RepdataUserPidManager, - SagoUserPidManager, - SpectrumUserPidManager, -] - -USER_PID_MANAGERS = {x.SOURCE: x for x in _managers} diff --git a/generalresearch/managers/marketplace/managers.py b/generalresearch/managers/marketplace/managers.py new file mode 100644 index 0000000..3349434 --- /dev/null +++ b/generalresearch/managers/marketplace/managers.py @@ -0,0 +1,23 @@ +from generalresearch.managers.cint.user_pid import CintUserPidManager +from generalresearch.managers.dynata.user_pid import DynataUserPidManager +from generalresearch.managers.innovate.user_pid import InnovateUserPidManager +from generalresearch.managers.morning.user_pid import MorningUserPidManager +from generalresearch.managers.precision.user_pid import PrecisionUserPidManager +from generalresearch.managers.prodege.user_pid import ProdegeUserPidManager +from generalresearch.managers.repdata.user_pid import RepdataUserPidManager +from generalresearch.managers.sago.user_pid import SagoUserPidManager +from generalresearch.managers.spectrum.user_pid import SpectrumUserPidManager + +_managers = [ + CintUserPidManager, + DynataUserPidManager, + InnovateUserPidManager, + MorningUserPidManager, + PrecisionUserPidManager, + ProdegeUserPidManager, + RepdataUserPidManager, + SagoUserPidManager, + SpectrumUserPidManager, +] + +USER_PID_MANAGERS = {x.SOURCE: x for x in _managers} diff --git a/generalresearch/models/cint/question.py b/generalresearch/models/cint/question.py index 5f703ee..0f5453b 100644 --- a/generalresearch/models/cint/question.py +++ b/generalresearch/models/cint/question.py @@ -9,7 +9,8 @@ from uuid import UUID from pydantic import BaseModel, Field, field_validator, model_validator from generalresearch.models.custom_types import AwareDatetimeISO -from generalresearch.models.definitions import Source, string_utils +from generalresearch.models.definitions import Source +from generalresearch.models.string_utils import remove_nbsp from generalresearch.models.thl.profiling.marketplace import ( MarketplaceQuestion, MarketplaceUserQuestionAnswer, @@ -106,7 +107,7 @@ class CintQuestion(MarketplaceQuestion): @field_validator("question_name", "question_text", mode="after") def remove_nbsp(cls, s: str | None) -> str | None: - return string_utils.remove_nbsp(s) + return remove_nbsp(s) @model_validator(mode="after") def check_type_options_agreement(self) -> Self: diff --git a/generalresearch/models/precision/question.py b/generalresearch/models/precision/question.py index 6ed6bbd..3e39124 100644 --- a/generalresearch/models/precision/question.py +++ b/generalresearch/models/precision/question.py @@ -8,7 +8,8 @@ from typing import TYPE_CHECKING, Any, Literal from pydantic import BaseModel, Field, ValidationError, field_validator, model_validator -from generalresearch.models.definitions import Source, string_utils +from generalresearch.models.definitions import Source +from generalresearch.models.string_utils import remove_nbsp from generalresearch.models.thl.profiling.marketplace import ( MarketplaceQuestion, MarketplaceUserQuestionAnswer, @@ -94,7 +95,7 @@ class PrecisionQuestion(MarketplaceQuestion): @field_validator("question_text", mode="after") def remove_nbsp(cls, s: str | None): - return string_utils.remove_nbsp(s) + return remove_nbsp(s) @model_validator(mode="after") def check_type_options_agreement(self): diff --git a/generalresearch/models/sago/question.py b/generalresearch/models/sago/question.py index bb51d31..216b278 100644 --- a/generalresearch/models/sago/question.py +++ b/generalresearch/models/sago/question.py @@ -18,7 +18,8 @@ from pydantic import ( model_validator, ) -from generalresearch.models.definitions import MAX_INT32, Source, string_utils +from generalresearch.models.definitions import MAX_INT32, Source +from generalresearch.models.string_utils import remove_nbsp from generalresearch.models.thl.profiling.marketplace import MarketplaceQuestion if TYPE_CHECKING: @@ -55,7 +56,7 @@ class SagoQuestionOption(BaseModel): @field_validator("text", mode="after") def remove_nbsp(cls, s: str): - return string_utils.remove_nbsp(s) + return remove_nbsp(s) class SagoQuestionType(StrEnum): @@ -169,7 +170,7 @@ class SagoQuestion(MarketplaceQuestion): @field_validator("question_name", "question_text", "tags", mode="after") def remove_nbsp(cls, s: str | None): - return string_utils.remove_nbsp(s) + return remove_nbsp(s) @classmethod def from_api( diff --git a/generalresearch/models/spectrum/question.py b/generalresearch/models/spectrum/question.py index 9c9bfa0..4b854fb 100644 --- a/generalresearch/models/spectrum/question.py +++ b/generalresearch/models/spectrum/question.py @@ -18,7 +18,8 @@ from pydantic import ( model_validator, ) -from generalresearch.models.definitions import MAX_INT32, Source, string_utils +from generalresearch.models.definitions import MAX_INT32, Source +from generalresearch.models.string_utils import remove_nbsp from generalresearch.models.thl.profiling.marketplace import ( MarketplaceQuestion, ) @@ -91,7 +92,9 @@ class SpectrumQuestionOption(BaseModel): @field_validator("text", mode="after") def remove_nbsp(cls, s: str) -> str: - return string_utils.remove_nbsp(s) + res = remove_nbsp(s) + assert isinstance(res, str), "Spectrum Question Option text must be str" + return res class SpectrumQuestionType(StrEnum): @@ -206,7 +209,7 @@ class SpectrumQuestion(MarketplaceQuestion): @field_validator("question_name", "question_text", "tags", mode="after") def remove_nbsp(cls, s: str | None): - return string_utils.remove_nbsp(s) + return remove_nbsp(s) @model_validator(mode="before") @classmethod diff --git a/generalresearch/thl_django/app/test_settings.py b/generalresearch/thl_django/app/test_settings.py index 57cb9b9..4168513 100644 --- a/generalresearch/thl_django/app/test_settings.py +++ b/generalresearch/thl_django/app/test_settings.py @@ -1,7 +1,7 @@ DATABASES = { "default": { "ENGINE": "django.db.backends.postgresql", - "NAME": 'unittest-2026-09-03-a0a584', + "NAME": 'unittest-2026-09-03-38dbfc', "USER": 'jenkins', "PASSWORD": '123456789', "HOST": 'unittest-postgresql.fmt2.grl.internal', diff --git a/tests/incite/collections/test_df_collection_item_thl_web.py b/tests/incite/collections/test_df_collection_item_thl_web.py index 061c576..b8b955f 100644 --- a/tests/incite/collections/test_df_collection_item_thl_web.py +++ b/tests/incite/collections/test_df_collection_item_thl_web.py @@ -12,7 +12,8 @@ import dask.dataframe as dd import pandas as pd import pytest from dask.distributed import Client as DaskClient -from distributed import Client, Scheduler, Worker +from dask.distributed import Scheduler as DaskScheduler +from dask.distributed import Worker as DaskWorker # noinspection PyUnresolvedReferences from distributed.utils_test import ( @@ -36,7 +37,6 @@ if TYPE_CHECKING: DFCollection, DFCollectionItem, ) - from generalresearch.managers.thl.ledger_manager.thl_ledger import ThlLedgerManager from generalresearch.models.thl.product import Product from generalresearch.models.thl.user import User @@ -57,12 +57,11 @@ unsupported_mock_types = { } -def combo_object() -> Generator[str]: - for x in iter_product( +def combo_object() -> Generator[tuple[DFCollectionType, str]]: + yield from iter_product( df_collections, ["15min", "45min", "1H"], - ): - yield from x + ) class TestDFCollectionItemBase: @@ -170,9 +169,12 @@ class TestDFCollectionItemMethod: def test_has_mysql( self, + df_collection_data_type: DFCollectionType, + offset: str, + duration: timedelta, + delete_df_collection: Callable[..., None], df_collection: DFCollection, thl_web_rr: PostgresConfig, - delete_df_collection: Callable[..., None], ): delete_df_collection(coll=df_collection) @@ -197,6 +199,9 @@ class TestDFCollectionItemMethod: @pytest.mark.skip def test_update_partial_archive( self, + df_collection_data_type: DFCollectionType, + offset: str, + duration: timedelta, ): # for i in collection.items: # assert i.update_partial_archive() @@ -206,8 +211,11 @@ class TestDFCollectionItemMethod: @pytest.mark.skip def test_create_partial_archive( self, + df_collection_data_type: DFCollectionType, + offset: str, + duration: timedelta, ): - assert 1 + 1 == 2 + pass def test_dict( self, @@ -262,14 +270,14 @@ class TestDFCollectionItemMethod: else: assert isinstance(df, pd.DataFrame) assert df.empty - assert set(df.columns) == set(df_collection._schema.columns.keys()) + assert set(df.columns) == set(df_collection.type_schema.columns.keys()) incite_item_factory(user=u1, item=item) df = item.from_db() assert isinstance(df, pd.DataFrame) assert not df.empty - assert set(df.columns) == set(df_collection._schema.columns.keys()) + assert set(df.columns) == set(df_collection.type_schema.columns.keys()) if df_collection.data_type == DFCollectionType.LEDGER: # The number of rows in this dataframe will change depending # on the mocking of data. It's because if the account has @@ -315,32 +323,23 @@ class TestDFCollectionItemMethod: df = item.from_mysql_standard() assert isinstance(df, pd.DataFrame) assert df.empty - assert set(df.columns) == set(df_collection._schema.columns.keys()) + assert set(df.columns) == set(df_collection.type_schema.columns.keys()) incite_item_factory(user=u1, item=item) df = item.from_mysql_standard() assert isinstance(df, pd.DataFrame) assert not df.empty - assert set(df.columns) == set(df_collection._schema.columns.keys()) + assert set(df.columns) == set(df_collection.type_schema.columns.keys()) assert df.shape[0] > 0 def test_from_mysql_ledger( self, df_collection: DFCollection, - user: User, - create_main_accounts: Callable[..., None], - offset: str, - duration: timedelta, - thl_web_rw: PostgresConfig, - thl_ledger_manager: ThlLedgerManager, - df_collection_data_type: DFCollectionType, user_factory: Callable[..., User], product: Product, - client_no_amm: DaskClient, incite_item_factory: Callable[..., None], delete_df_collection: Callable[..., None], - mnt_filepath: GRLDatasets, ): if df_collection.data_type != DFCollectionType.LEDGER: @@ -382,16 +381,10 @@ class TestDFCollectionItemMethod: def test_to_archive( self, df_collection: DFCollection, - user: User, - offset: str, - duration: timedelta, - df_collection_data_type: DFCollectionType, user_factory: Callable[..., User], product: Product, - client_no_amm: DaskClient, incite_item_factory: Callable[..., None], delete_df_collection: Callable[..., None], - mnt_filepath: GRLDatasets, ): if df_collection.data_type in unsupported_mock_types: @@ -418,14 +411,9 @@ class TestDFCollectionItemMethod: def test__to_archive( self, - df_collection_data_type: DFCollectionType, df_collection: DFCollection, user_factory: Callable[..., User], product: Product, - offset: str, - duration: timedelta, - client_no_amm: DaskClient, - user: User, incite_item_factory: Callable[..., None], delete_df_collection: Callable[..., None], mnt_filepath: GRLDatasets, @@ -492,18 +480,27 @@ class TestDFCollectionItemMethod: @pytest.mark.skip def test_to_archive_numbered_partial( self, + df_collection_data_type: DFCollectionType, + offset: str, + duration: timedelta, ): pass @pytest.mark.skip def test_initial_load( self, + df_collection_data_type: DFCollectionType, + offset: str, + duration: timedelta, ): pass @pytest.mark.skip def test_clear_corrupt_archive( self, + df_collection_data_type: DFCollectionType, + offset: str, + duration: timedelta, ): pass @@ -515,18 +512,6 @@ class TestDFCollectionItemMethod: class TestDFCollectionItemMethodBase: @pytest.mark.skip - def test_path_exists( - self, - ): - pass - - @pytest.mark.skip - def test_next_numbered_path( - self, - ): - pass - - @pytest.mark.skip def test_search_highest_numbered_path( self, df_collection_data_type: DFCollectionType, @@ -538,12 +523,18 @@ class TestDFCollectionItemMethodBase: @pytest.mark.skip def test_tmp_filename( self, + df_collection_data_type: DFCollectionType, + offset: str, + duration: timedelta, ): pass @pytest.mark.skip def test_tmp_path( self, + df_collection_data_type: DFCollectionType, + offset: str, + duration: timedelta, ): pass @@ -640,7 +631,8 @@ class TestDFCollectionItemMethodBase: self, df_collection: DFCollection, ): - schema: DataFrameSchema = df_collection._schema + schema: DataFrameSchema = df_collection.type_schema + assert schema.metadata aa = schema.metadata[ARCHIVE_AFTER] # It shouldn't be None, it can be timedelta(seconds=0) @@ -657,6 +649,9 @@ class TestDFCollectionItemMethodBase: @pytest.mark.skip def test_set_empty( self, + df_collection_data_type: DFCollectionType, + offset: str, + duration: timedelta, ): pass @@ -687,17 +682,26 @@ class TestDFCollectionItemMethodBase: @pytest.mark.skip def test_validate_df( self, + df_collection_data_type: DFCollectionType, + offset: str, + duration: timedelta, ): pass @pytest.mark.skip def test_from_archive( self, + df_collection_data_type: DFCollectionType, + offset: str, + duration: timedelta, ): pass def test__to_dict( self, + df_collection_data_type: DFCollectionType, + offset: str, + duration: timedelta, df_collection: DFCollection, ): @@ -718,29 +722,38 @@ class TestDFCollectionItemMethodBase: @pytest.mark.skip def test_delete_partial( self, + df_collection_data_type: DFCollectionType, + offset: str, + duration: timedelta, ): pass @pytest.mark.skip def test_cleanup_partials( self, + df_collection_data_type: DFCollectionType, + offset: str, + duration: timedelta, ): pass @pytest.mark.skip def test_delete_dangling_partials( self, + df_collection_data_type: DFCollectionType, + offset: str, + duration: timedelta, ): pass @gen_cluster(client=True, nthreads=[("127.0.0.1", 1)]) -async def test_client(client, s, worker): +async def test_client(client: DaskClient, s: DaskScheduler, worker: DaskWorker): """c,s,a are all required - the secondary Worker (b) is not required""" - assert isinstance(client, Client) - assert isinstance(s, Scheduler) - assert isinstance(worker, Worker) + assert isinstance(client, DaskClient) + assert isinstance(s, DaskScheduler) + assert isinstance(worker, DaskWorker) @pytest.mark.parametrize( @@ -750,13 +763,17 @@ async def test_client(client, s, worker): @gen_cluster(client=True, nthreads=[("127.0.0.1", 1)]) @pytest.mark.anyio async def test_client_parametrize( - c, s, w, df_collection_data_type: DFCollectionType, offset: str + c: DaskClient, + s: DaskScheduler, + w: DaskWorker, + df_collection_data_type: DFCollectionType, + offset: str, ): """c,s,a are all required - the secondary Worker (b) is not required""" - assert isinstance(c, Client), f"c is not Client, it's {type(c)}" - assert isinstance(s, Scheduler), f"s is not Scheduler, it's {type(s)}" - assert isinstance(w, Worker), f"w is not Worker, it's {type(w)}" + assert isinstance(c, DaskClient), f"c is not Client, it's {type(c)}" + assert isinstance(s, DaskScheduler), f"s is not Scheduler, it's {type(s)}" + assert isinstance(w, DaskWorker), f"w is not Worker, it's {type(w)}" assert df_collection_data_type is not None assert isinstance(offset, str) @@ -923,7 +940,8 @@ class TestDFCollectionItemFunctionalTest: return u1: User = user_factory(product=product) - schema: DataFrameSchema = df_collection._schema + schema: DataFrameSchema = df_collection.type_schema + assert schema.metadata aa = schema.metadata[ARCHIVE_AFTER] assert isinstance(aa, timedelta) diff --git a/tests/incite/collections/test_df_collection_thl_marketplaces.py b/tests/incite/collections/test_df_collection_thl_marketplaces.py index 6ad0cb4..0f79b81 100644 --- a/tests/incite/collections/test_df_collection_thl_marketplaces.py +++ b/tests/incite/collections/test_df_collection_thl_marketplaces.py @@ -1,3 +1,4 @@ +from collections.abc import Generator from datetime import UTC, datetime from itertools import product from typing import TYPE_CHECKING @@ -18,8 +19,8 @@ if TYPE_CHECKING: from generalresearch.pg_helper import PostgresConfig -def combo_object(): - for x in product( +def combo_object() -> Generator[tuple[type, str]]: + yield from product( [ InnovateSurveyHistoryCollection, MorningSurveyTimeseriesCollection, @@ -27,8 +28,7 @@ def combo_object(): SpectrumSurveyTimeseriesCollection, ], ["5min", "6H", "30D"], - ): - yield from x + ) @pytest.mark.parametrize("df_coll, offset", combo_object()) diff --git a/tests/incite/collections/test_df_collection_thl_web.py b/tests/incite/collections/test_df_collection_thl_web.py index 20d7187..3c5e41b 100644 --- a/tests/incite/collections/test_df_collection_thl_web.py +++ b/tests/incite/collections/test_df_collection_thl_web.py @@ -15,8 +15,8 @@ from generalresearch.incite.collections.base import ( ) -def combo_object() -> Generator[tuple]: - for x in product( +def combo_object() -> Generator[tuple[DFCollectionType, str]]: + yield from product( [ DFCollectionType.USER, DFCollectionType.WALL, @@ -26,8 +26,7 @@ def combo_object() -> Generator[tuple]: DFCollectionType.LEDGER, ], ["30min", "1H"], - ): - yield from x + ) @pytest.mark.parametrize( diff --git a/tests/incite/mergers/test_merge_collection.py b/tests/incite/mergers/test_merge_collection.py index 3f478bd..7ed3996 100644 --- a/tests/incite/mergers/test_merge_collection.py +++ b/tests/incite/mergers/test_merge_collection.py @@ -34,8 +34,11 @@ class TestMergeCollection: def test_init( self, - mnt_filepath: GRLDatasets, merge_type: MergeType, + offset: str, + duration: timedelta, + start: datetime, + mnt_filepath: GRLDatasets, ): with pytest.raises(expected_exception=ValueError) as cm: MergeCollection(archive_path=mnt_filepath.data_src) @@ -88,6 +91,9 @@ class TestMergeCollection: def test_schema( self, + offset: str, + duration: timedelta, + start: datetime, mnt_filepath: GRLDatasets, merge_type: MergeType, ): diff --git a/tests/models/test_finance.py b/tests/models/test_finance.py index c579d78..502c596 100644 --- a/tests/models/test_finance.py +++ b/tests/models/test_finance.py @@ -7,6 +7,7 @@ from random import randint from typing import TYPE_CHECKING from uuid import uuid4 +import dask.dataframe as dd import pandas as pd import pytest from dask.distributed import Client as DaskClient @@ -32,11 +33,11 @@ if TYPE_CHECKING: from generalresearch.incite.collections.thl_web import LedgerDFCollection from generalresearch.incite.mergers.pop_ledger import PopLedgerMerge from generalresearch.managers.thl.ledger_manager.thl_ledger import ThlLedgerManager + from generalresearch.managers.thl.product import ProductManager from generalresearch.models.thl.ledger import LedgerAccount from generalresearch.models.thl.product import Product from generalresearch.models.thl.session import Session from generalresearch.models.thl.user import User - from generalresearch.pg_helper import PostgresConfig fake = Faker() @@ -659,10 +660,9 @@ class TestBusinessBalanceInitialize: @pytest.mark.parametrize( - argnames="offset, duration", + argnames="duration", argvalues=list( iter_product( - ["12h", "2D"], [timedelta(days=2), timedelta(days=5)], ) ), @@ -671,17 +671,15 @@ class TestProductFinanceData: def test_base( self, + duration: timedelta, product: Product, user_factory: Callable[..., User], start: datetime, - duration: timedelta, thl_ledger_manager: ThlLedgerManager, session_with_tx_factory: Callable[..., None], ): # -- Build & Setup - # assert ledger_collection.start is None - # assert ledger_collection.offset is None u: User = user_factory(product=product, created=ledger_collection.start) for item in ledger_collection.items: @@ -738,15 +736,6 @@ class TestProductFinanceData: assert len(res) == len({i.time for i in res}) -@pytest.mark.parametrize( - argnames="offset, duration", - argvalues=list( - iter_product( - ["12h", "2D"], - [timedelta(days=2), timedelta(days=5)], - ) - ), -) class TestPOPFinancialData: def test_base( @@ -757,7 +746,6 @@ class TestPOPFinancialData: user_factory: Callable[..., User], product: Product, start: datetime, - duration: timedelta, create_main_accounts: Callable[..., None], session_with_tx_factory: Callable[..., Session], thl_ledger_manager: ThlLedgerManager, @@ -768,8 +756,6 @@ class TestPOPFinancialData: delete_ledger_db() create_main_accounts() delete_df_collection(coll=ledger_collection) - # assert ledger_collection.start is None - # assert ledger_collection.offset is None users = [] for _ in range(5): @@ -833,22 +819,10 @@ class TestPOPFinancialData: # 1 product: Product, multiple Users assert len(users) == len(accounts) - # We group on days, and duration is a parameter to parametrize - assert isinstance(duration, timedelta) - # -- Teardown delete_df_collection(ledger_collection) -@pytest.mark.parametrize( - argnames="offset, duration", - argvalues=list( - iter_product( - ["12h", "1D"], - [timedelta(days=2), timedelta(days=3)], - ) - ), -) class TestBusinessBalanceData: def test_from_pandas( self, @@ -859,7 +833,7 @@ class TestBusinessBalanceData: product: Product, create_main_accounts: Callable[..., None], thl_ledger_manager: ThlLedgerManager, - thl_web_rr: PostgresConfig, + product_manager: ProductManager, delete_df_collection: Callable[..., None], delete_ledger_db: Callable[..., None], session_with_tx_factory: Callable[..., Session], @@ -898,15 +872,18 @@ class TestBusinessBalanceData: columns=numerical_col_names + ["account_id"], filters=[("account_id", "in", [account.uuid])], ) + assert isinstance(ddf, dd.DataFrame) ddf = ddf.groupby("account_id").sum() df: pd.DataFrame = client_no_amm.compute(collections=ddf, sync=True) assert isinstance(df, pd.DataFrame) instance = BusinessBalances.from_pandas( - input_data=df, accounts=[account], thl_pg_config=thl_web_rr + product_manager=product_manager, + input_data=df, + accounts=[account], ) - balance: int = thl_lm.get_account_balance(account=account) + balance: int = thl_ledger_manager.get_account_balance(account=account) assert instance.balance == balance assert instance.net == balance |
