@@ -146,6 +146,7 @@ def test_get_table_metadata(self):
146146 self .assertEqual (table_info ['fields' ][0 ]['name' ], 'col1' )
147147
148148
149+
149150 def test_get_columns_name_id (self ):
150151 name_id_mapping = mb .get_columns_name_id (table_id = 101 )
151152 self .assertEqual (name_id_mapping ['col1' ], 490 )
@@ -154,6 +155,7 @@ def test_get_columns_name_id(self):
154155 self .assertEqual (id_name_mapping [490 ], 'col1' )
155156
156157
158+
157159 def test_friendly_names_is_disabled (self ):
158160 res = mb .friendly_names_is_disabled ()
159161 self .assertEqual (res , True )
@@ -215,6 +217,7 @@ def test_create_card(self):
215217 Metabase_API_Test .cleanup_objects ['card' ].extend ([ res1 ['id' ], res3 ['id' ], res3 ['id' ] ])
216218
217219
220+
218221 def test_create_collection (self ):
219222 t = datetime .datetime .now ().strftime ('%Y-%m-%d %H:%M:%S' )
220223 res = mb .create_collection (f'test_create_collection { t } ' , parent_collection_id = 28 , return_results = True )
@@ -227,6 +230,7 @@ def test_create_collection(self):
227230 Metabase_API_Test .cleanup_objects ['collection' ].append (res ['id' ])
228231
229232
233+
230234 def test_create_segment (self ):
231235 t = datetime .datetime .now ().strftime ('%Y-%m-%d %H:%M:%S' )
232236 res = mb .create_segment (segment_name = 'test_create_segment_{}' .format (t ), table_name = 'test_table' , column_name = 'col2' , column_values = [1 , 2 ], return_segment = True )
@@ -235,6 +239,7 @@ def test_create_segment(self):
235239 Metabase_API_Test .cleanup_objects ['segment' ].append (res ['id' ])
236240
237241
242+
238243 def test_copy_card (self ):
239244 t = datetime .datetime .now ().strftime ('%Y-%m-%d %H:%M:%S' )
240245 newCard_id = mb .copy_card (source_card_id = 166 , destination_collection_id = 29 , destination_card_name = 'test_copy_card_{}' .format (t ))
@@ -284,11 +289,13 @@ def test_search(self):
284289 def test_get_card_data (self ):
285290 # json
286291 res = mb .get_card_data (card_id = 166 )
287- json_data = [{'col1' : 'row1 cell1' , 'col2' : 1 },
288- {'col1' : None , 'col2' : 2 },
289- {'col1' : 'row3 cell1' , 'col2' : None },
290- {'col1' : None , 'col2' : None },
291- {'col1' : 'row5 cell1' , 'col2' : 5 }]
292+ json_data = [
293+ {'col1' : 'row1 cell1' , 'col2' : 1 },
294+ {'col1' : None , 'col2' : 2 },
295+ {'col1' : 'row3 cell1' , 'col2' : None },
296+ {'col1' : None , 'col2' : None },
297+ {'col1' : 'row5 cell1' , 'col2' : 5 }
298+ ]
292299 self .assertEqual (res , json_data )
293300
294301 # csv
@@ -302,14 +309,25 @@ def test_get_card_data(self):
302309 self .assertEqual (res , filtered_data )
303310
304311
312+
305313 def test_clone_card (self ):
306314 # native question
307315 res = mb .clone_card (273 , 101 , 103 , new_card_name = 'test_clone_native' , new_card_collection_id = 29 , return_card = True )
308316 # simple/custom question
309- res2 = mb .clone_card (274 , 101 , 103 , new_card_name = 'test_clone_simple' , new_card_collection_id = 29 , return_card = True )
317+ res2 = mb .clone_card (274 , 101 , 103 , new_card_name = 'test_clone_simple1' , new_card_collection_id = 29 , return_card = True )
318+ res3 = mb .clone_card (491 , 101 , 103 , new_card_name = 'test_clone_simple2' , new_card_collection_id = 29 , return_card = True )
319+ expected_res3_query = { 'database' : 5 ,
320+ 'query' : {'source-table' : 103 ,
321+ 'aggregation' : [['avg' , ['field' , 493 , None ]]],
322+ 'breakout' : [['field' , 494 , None ]],
323+ 'order-by' : [['desc' , ['aggregation' , 0 , None ]]]
324+ },
325+ 'type' : 'query'
326+ }
327+ self .assertEqual (res3 ['dataset_query' ], expected_res3_query )
310328
311329 # add to cleanup list
312- Metabase_API_Test .cleanup_objects ['card' ].extend ([res ['id' ], res2 ['id' ]])
330+ Metabase_API_Test .cleanup_objects ['card' ].extend ([res ['id' ], res2 ['id' ], res3 [ 'id' ] ])
313331
314332
315333
0 commit comments