Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added: add_df_index with max_rows test #264

Merged
merged 1 commit into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions tests/test_data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
8 changes: 8 additions & 0 deletions tests/test_data/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down