Skip to content

Commit b673acd

Browse files
committed
add unittest for format_rows option of get_card_data function
1 parent 627b53a commit b673acd

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

tests/test_metabase_api.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,22 @@ def test_search(self):
251251
def test_get_card_data(self):
252252
# json
253253
res = mb.get_card_data(card_id=1)
254+
json_data = [
255+
{'col1': 'row1 cell1', 'col2': 1},
256+
{'col1': None, 'col2': 2},
257+
{'col1': 'row3 cell1', 'col2': None},
258+
{'col1': None, 'col2': None},
259+
{'col1': 'row5 cell1', 'col2': 5}
260+
]
261+
self.assertEqual(res, json_data)
262+
263+
# formatted rows (in json export mode, None become '' and numbers become strings, e.g. 123 -> '123')
264+
res = mb.get_card_data(card_id=1, format_rows=True)
254265
json_data = [
255266
{'col1': 'row1 cell1', 'col2': '1'},
256267
{'col1': '', 'col2': '2'},
257-
{'col1': 'row3 cell1', 'col2': None},
258-
{'col1': '', 'col2': None},
268+
{'col1': 'row3 cell1', 'col2': ''},
269+
{'col1': '', 'col2': ''},
259270
{'col1': 'row5 cell1', 'col2': '5'}
260271
]
261272
self.assertEqual(res, json_data)

0 commit comments

Comments
 (0)