From d23bc0459d63b838e83acefbe40d5204d6a01b72 Mon Sep 17 00:00:00 2001 From: David Vegh Date: Tue, 22 Aug 2023 09:02:59 +0200 Subject: [PATCH] added: `add_df_index` with `max_rows` test --- tests/test_data/__init__.py | 11 +++++++++++ tests/test_data/test_pandas.py | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/tests/test_data/__init__.py b/tests/test_data/__init__.py index 61235ddf..b132d2e3 100644 --- a/tests/test_data/__init__.py +++ b/tests/test_data/__init__.py @@ -22,6 +22,7 @@ class DataWithAssets(unittest.TestCase): in_pd_df_by_series_with_index: pd.DataFrame ref_pd_df_by_series_with_index: dict ref_pd_df_by_series_only_index: dict + ref_pd_df_by_series_only_index_max_rows: dict ref_pd_df_by_series_max_rows: dict in_pd_series_dimension: pd.Series @@ -112,6 +113,16 @@ def set_up_pd_df(cls) -> None: "series" ] = cls.ref_pd_df_by_series_only_index["data"]["series"][:1] + cls.ref_pd_df_by_series_only_index_max_rows = copy.deepcopy( + cls.ref_pd_df_by_series_only_index + ) + cls.ref_pd_df_by_series_only_index_max_rows["data"]["series"][0][ + "values" + ] = [ + "111", + "110", + ] + @classmethod def set_up_pd_series(cls) -> None: cls.in_pd_series_dimension = pd.Series(["1", "2"], name="DimensionSeries") diff --git a/tests/test_data/test_pandas.py b/tests/test_data/test_pandas.py index 96f0decc..6b9cd3f1 100644 --- a/tests/test_data/test_pandas.py +++ b/tests/test_data/test_pandas.py @@ -171,6 +171,14 @@ def test_add_df_index_with_df(self) -> None: self.data.build(), ) + def test_add_df_index_with_df_and_max_rows(self) -> None: + df = self.in_pd_df_by_series_with_index + self.data.add_df_index(df, max_rows=2) + self.assertEqual( + self.ref_pd_df_by_series_only_index_max_rows, + self.data.build(), + ) + class TestDataFrameIndex(DataWithAssets): def test_add_data_frame_index_with_none(self) -> None: