aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstuppie2026-09-04 11:08:53 -0600
committerstuppie2026-09-04 11:08:53 -0600
commit044ba3a4f5f10e22d41a8fc5b810e33e7aabbf26 (patch)
treec2008a85db1c9791c8dd3039c1235a66f4480a1e
parentd65c35ba4090a14e32ec88fb503f80a2ba1338e3 (diff)
downloadgeneralresearch-044ba3a4f5f10e22d41a8fc5b810e33e7aabbf26.tar.gz
generalresearch-044ba3a4f5f10e22d41a8fc5b810e33e7aabbf26.zip
from db fix in tests. '1H' -> '1h'. remove mysql from non-mysql items
-rw-r--r--tests/incite/collections/test_df_collection_item_base.py13
-rw-r--r--tests/incite/collections/test_df_collection_item_thl_web.py44
-rw-r--r--tests/incite/collections/test_df_collection_thl_web.py2
3 files changed, 24 insertions, 35 deletions
diff --git a/tests/incite/collections/test_df_collection_item_base.py b/tests/incite/collections/test_df_collection_item_base.py
index 83d4973..7a8793d 100644
--- a/tests/incite/collections/test_df_collection_item_base.py
+++ b/tests/incite/collections/test_df_collection_item_base.py
@@ -6,6 +6,7 @@ from typing import TYPE_CHECKING
import pytest
from generalresearch.incite.collections.base import (
+ MYSQL_ALLOWED_COLL_TYPES,
DFCollection,
DFCollectionItem,
DFCollectionType,
@@ -16,12 +17,8 @@ if TYPE_CHECKING:
from generalresearch.pg_helper import PostgresConfig
-df_collection_types = [e for e in DFCollectionType if e is not DFCollectionType.TEST]
-
-
-@pytest.mark.parametrize("df_coll_type", df_collection_types)
+@pytest.mark.parametrize("df_coll_type", MYSQL_ALLOWED_COLL_TYPES)
class TestDFCollectionItemBase:
-
def test_init(self, mnt_filepath: GRLDatasets, df_coll_type: DFCollectionType):
collection = DFCollection(
data_type=df_coll_type,
@@ -37,17 +34,15 @@ class TestDFCollectionItemBase:
assert isinstance(item, DFCollectionItem)
-@pytest.mark.parametrize("df_coll_type", df_collection_types)
+@pytest.mark.parametrize("df_coll_type", MYSQL_ALLOWED_COLL_TYPES)
class TestDFCollectionItemProperties:
-
@pytest.mark.skip
def test_filename(self, df_coll_type: DFCollectionType):
pass
-@pytest.mark.parametrize("df_coll_type", df_collection_types)
+@pytest.mark.parametrize("df_coll_type", MYSQL_ALLOWED_COLL_TYPES)
class TestDFCollectionItemMethods:
-
def test_has_mysql_false(
self, mnt_filepath: GRLDatasets, df_coll_type: DFCollectionType
):
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 b8b955f..9e00bca 100644
--- a/tests/incite/collections/test_df_collection_item_thl_web.py
+++ b/tests/incite/collections/test_df_collection_item_thl_web.py
@@ -60,7 +60,7 @@ unsupported_mock_types = {
def combo_object() -> Generator[tuple[DFCollectionType, str]]:
yield from iter_product(
df_collections,
- ["15min", "45min", "1H"],
+ ["15min", "45min", "1h"],
)
@@ -167,7 +167,7 @@ class TestDFCollectionItemPropertiesBase:
)
class TestDFCollectionItemMethod:
- def test_has_mysql(
+ def test_has_postgres(
self,
df_collection_data_type: DFCollectionType,
offset: str,
@@ -180,12 +180,12 @@ class TestDFCollectionItemMethod:
df_collection.pg_config = None
for i in df_collection.items:
- assert not i.has_mysql()
+ assert not i.has_postgres()
# Confirm that the regular connection should work as expected
df_collection.pg_config = thl_web_rr
for i in df_collection.items:
- assert i.has_mysql()
+ assert i.has_postgres()
# Make a fake connection and confirm it does NOT work
df_collection.pg_config = PostgresConfig(
@@ -194,7 +194,7 @@ class TestDFCollectionItemMethod:
statement_timeout=1,
)
for i in df_collection.items:
- assert not i.has_mysql()
+ assert not i.has_postgres()
@pytest.mark.skip
def test_update_partial_archive(
@@ -263,29 +263,23 @@ class TestDFCollectionItemMethod:
for item in df_collection.items:
# Unlike .from_mysql_ledger(), .from_mysql_standard() will return
# back and empty df with the correct columns in place
- delete_df_collection(coll=df_collection)
- df = item.from_db()
if df_collection.data_type == DFCollectionType.LEDGER:
- assert df is None
- else:
- assert isinstance(df, pd.DataFrame)
- assert df.empty
- assert set(df.columns) == set(df_collection.type_schema.columns.keys())
+ continue
+ delete_df_collection(coll=df_collection)
+ df = item.from_postgres_standard()
+ assert isinstance(df, pd.DataFrame)
+ assert df.empty
+ assert set(df.columns) == set(df_collection.type_schema.columns.keys())
incite_item_factory(user=u1, item=item)
- df = item.from_db()
+ df = item.from_postgres_standard()
assert isinstance(df, pd.DataFrame)
assert not df.empty
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
- # user wallet on, then there will be more transactions for
- # example.
- assert df.shape[0] > 0
- def test_from_mysql_standard(
+
+ def test_from_postgres_standard(
self,
df_collection_data_type: DFCollectionType,
df_collection: DFCollection,
@@ -333,7 +327,7 @@ class TestDFCollectionItemMethod:
assert set(df.columns) == set(df_collection.type_schema.columns.keys())
assert df.shape[0] > 0
- def test_from_mysql_ledger(
+ def test_from_postgres_ledger(
self,
df_collection: DFCollection,
user_factory: Callable[..., User],
@@ -355,14 +349,14 @@ class TestDFCollectionItemMethod:
# Okay, now continue with the actual Ledger Item tests... we need
# to ensure that this item.start - item.finish range hasn't had
# any prior transactions created within that range.
- assert item.from_mysql_ledger() is None
+ assert item.from_postgres_ledger() is None
# Create main accounts doesn't matter because it doesn't
# add any transactions to the db
- assert item.from_mysql_ledger() is None
+ assert item.from_postgres_ledger() is None
incite_item_factory(user=u1, item=item)
- df = item.from_mysql_ledger()
+ df = item.from_postgres_ledger()
assert isinstance(df, pd.DataFrame)
# Not only is this a np.int64 to int comparison, but I also know it
@@ -400,7 +394,7 @@ class TestDFCollectionItemMethod:
# Load up the data that we'll be using for various to_archive
# methods.
- df = item.from_db()
+ df = item.from_postgres_standard()
ddf = dd.from_pandas(df, npartitions=1)
# (1) Write the basic archive, the issue is that because it's
diff --git a/tests/incite/collections/test_df_collection_thl_web.py b/tests/incite/collections/test_df_collection_thl_web.py
index 3c5e41b..7253dd0 100644
--- a/tests/incite/collections/test_df_collection_thl_web.py
+++ b/tests/incite/collections/test_df_collection_thl_web.py
@@ -25,7 +25,7 @@ def combo_object() -> Generator[tuple[DFCollectionType, str]]:
DFCollectionType.AUDIT_LOG,
DFCollectionType.LEDGER,
],
- ["30min", "1H"],
+ ["30min", "1h"],
)