Skip to content

Commit

Permalink
Merge pull request #264 from vizzuhq/add_df_index_test
Browse files Browse the repository at this point in the history
added: `add_df_index` with `max_rows` test
  • Loading branch information
veghdev committed Aug 22, 2023
2 parents f1c1841 + d23bc04 commit e5da924
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
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

0 comments on commit e5da924

Please sign in to comment.