Skip to content

Commit 245f533

Browse files
committed
add test for data object generation
Signed-off-by: Itay Dafna <[email protected]>
1 parent deaa7e3 commit 245f533

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/test_datagrid.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,20 @@ def test_get_cell_value_by_numerical_index(
106106
assert DataGrid._get_cell_value_by_numerical_index(data_object, 2, 2) is None
107107
else:
108108
assert DataGrid._get_cell_value_by_numerical_index(data_object, 1, 0) == 4
109+
110+
def test_data_object_generation(dataframe: pd.DataFrame) -> None:
111+
data_object = DataGrid.generate_data_object(dataframe, "ipydguuid")
112+
expected_output = {
113+
'data': [{'index': 'One', 'A': 1, 'B': 4, 'ipydguuid': 0},
114+
{'index': 'Two', 'A': 2, 'B': 5, 'ipydguuid': 1},
115+
{'index': 'Three', 'A': 3, 'B': 6, 'ipydguuid': 2}],
116+
'schema': {'fields': [{'name': 'index', 'type': 'string'},
117+
{'name': 'A', 'type': 'integer'},
118+
{'name': 'B', 'type': 'integer'},
119+
{'name': 'ipydguuid', 'type': 'integer'}],
120+
'primaryKey': ['index', 'ipydguuid'],
121+
'pandas_version': '0.20.0',
122+
'primaryKeyUuid': 'ipydguuid'},
123+
'fields': [{'index': None}, {'A': None}, {'B': None}, {'ipydguuid': None}]}
124+
125+
assert data_object == expected_output

0 commit comments

Comments
 (0)