Skip to content

Commit

Permalink
add unittest for format_rows option of get_card_data function
Browse files Browse the repository at this point in the history
  • Loading branch information
vvaezian committed Jun 1, 2024
1 parent 627b53a commit b673acd
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/test_metabase_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,22 @@ def test_search(self):
def test_get_card_data(self):
# json
res = mb.get_card_data(card_id=1)
json_data = [
{'col1': 'row1 cell1', 'col2': 1},
{'col1': None, 'col2': 2},
{'col1': 'row3 cell1', 'col2': None},
{'col1': None, 'col2': None},
{'col1': 'row5 cell1', 'col2': 5}
]
self.assertEqual(res, json_data)

# formatted rows (in json export mode, None become '' and numbers become strings, e.g. 123 -> '123')
res = mb.get_card_data(card_id=1, format_rows=True)
json_data = [
{'col1': 'row1 cell1', 'col2': '1'},
{'col1': '', 'col2': '2'},
{'col1': 'row3 cell1', 'col2': None},
{'col1': '', 'col2': None},
{'col1': 'row3 cell1', 'col2': ''},
{'col1': '', 'col2': ''},
{'col1': 'row5 cell1', 'col2': '5'}
]
self.assertEqual(res, json_data)
Expand Down

0 comments on commit b673acd

Please sign in to comment.