@@ -203,105 +203,105 @@ def test_check_database_changes(to_delete, expected_to_delete_rows):
203203 )
204204
205205
206- def test_store_database_with_rows_to_update_and_delete (syn ):
207- """Test store_database function"""
208- database_synid = "syn123"
209- all_updates = pd .DataFrame (
210- {"test" : ["test" , "test2" ], "foo" : [1 , 3 ], "baz" : ["" , 5 ]}
211- )
212- to_delete_rows = pd .DataFrame ({0 : ["3" ], 1 : ["5" ]})
213- mock_database_ent = Mock ()
214- mock_database_ent .name = "test_table"
215- # get the table entity
216- with (
217- patch .object (syn , "get" , return_value = mock_database_ent ) as patch_get ,
218- patch .object (Table , "store_rows" ) as patch_store_rows ,
219- patch .object (Table , "delete_rows" ) as patch_delete_rows ,
220- patch .object (load .logger , "info" ) as patch_info ,
221- ):
222- load .store_database (syn , database_synid , all_updates , to_delete_rows )
223- patch_get .assert_called_once_with (database_synid )
224- patch_store_rows .assert_called_once_with (all_updates )
225- patch_delete_rows .assert_called_once_with (to_delete_rows )
226- patch_info .assert_has_calls (
227- [
228- call (
229- f"Upserting { len (all_updates )} rows from { mock_database_ent .name } table"
230- ),
231- call (
232- f"Deleting { len (to_delete_rows )} rows from { mock_database_ent .name } table"
233- ),
234- ]
235- )
236-
237-
238- def test_store_database_only_rows_to_update (syn ):
239- """Test store_database function"""
240- database_synid = "syn123"
241- all_updates = pd .DataFrame (
242- {"test" : ["test" , "test2" ], "foo" : [1 , 3 ], "baz" : ["" , 5 ]}
243- )
244- to_delete_rows = pd .DataFrame ()
245- mock_database_ent = Mock ()
246- mock_database_ent .name = "test_table"
247- # get the table entity
248- with (
249- patch .object (syn , "get" , return_value = mock_database_ent ) as patch_get ,
250- patch .object (Table , "store_rows" ) as patch_store_rows ,
251- patch .object (Table , "delete_rows" ) as patch_delete_rows ,
252- patch .object (load .logger , "info" ) as patch_info ,
253- ):
254- load .store_database (syn , database_synid , all_updates , to_delete_rows )
255- patch_get .assert_called_once_with (database_synid )
256- patch_store_rows .assert_called_once_with (all_updates )
257- patch_delete_rows .assert_not_called ()
258- patch_info .assert_called_once_with (
259- f"Upserting { len (all_updates )} rows from { mock_database_ent .name } table"
260- )
261-
262-
263- def test_store_database_only_rows_to_delete (syn ):
264- """Test store_database function"""
265- database_synid = "syn123"
266- all_updates = pd .DataFrame ()
267- to_delete_rows = pd .DataFrame ({0 : ["3" ], 1 : ["5" ]})
268- mock_database_ent = Mock ()
269- mock_database_ent .name = "test_table"
270- # get the table entity
271- with (
272- patch .object (syn , "get" , return_value = mock_database_ent ) as patch_get ,
273- patch .object (Table , "store_rows" ) as patch_store_rows ,
274- patch .object (Table , "delete_rows" ) as patch_delete_rows ,
275- patch .object (load .logger , "info" ) as patch_info ,
276- ):
277- load .store_database (syn , database_synid , all_updates , to_delete_rows )
278- patch_get .assert_called_once_with (database_synid )
279- patch_store_rows .assert_not_called ()
280- patch_delete_rows .assert_called_once_with (to_delete_rows )
281- patch_info .assert_called_once_with (
282- f"Deleting { len (to_delete_rows )} rows from { mock_database_ent .name } table"
283- )
284-
285-
286- def test_store_database_no_rows_to_update_and_delete (syn ):
287- """Test store_database function"""
288- database_synid = "syn123"
289- all_updates = pd .DataFrame ()
290- to_delete_rows = pd .DataFrame ()
291- mock_database_ent = Mock ()
292- mock_database_ent .name = "test_table"
293- # get the table entity
294- with (
295- patch .object (syn , "get" , return_value = mock_database_ent ) as patch_get ,
296- patch .object (Table , "store_rows" ) as patch_store_rows ,
297- patch .object (Table , "delete_rows" ) as patch_delete_rows ,
298- patch .object (load .logger , "info" ) as patch_info ,
299- ):
300- load .store_database (syn , database_synid , all_updates , to_delete_rows )
301- patch_get .assert_called_once_with (database_synid )
302- patch_store_rows .assert_not_called ()
303- patch_delete_rows .assert_not_called ()
304- patch_info .assert_not_called ()
206+ # def test_store_database_with_rows_to_update_and_delete(syn):
207+ # """Test store_database function"""
208+ # database_synid = "syn123"
209+ # all_updates = pd.DataFrame(
210+ # {"test": ["test", "test2"], "foo": [1, 3], "baz": ["", 5]}
211+ # )
212+ # to_delete_rows = pd.DataFrame({0: ["3"], 1: ["5"]})
213+ # mock_database_ent = Mock()
214+ # mock_database_ent.name = "test_table"
215+ # # get the table entity
216+ # with (
217+ # patch.object(syn, "get", return_value=mock_database_ent) as patch_get,
218+ # patch.object(Table, "store_rows") as patch_store_rows,
219+ # patch.object(Table, "delete_rows") as patch_delete_rows,
220+ # patch.object(load.logger, "info") as patch_info,
221+ # ):
222+ # load.store_database(syn, database_synid, all_updates, to_delete_rows)
223+ # patch_get.assert_called_once_with(database_synid)
224+ # patch_store_rows.assert_called_once_with(all_updates)
225+ # patch_delete_rows.assert_called_once_with(to_delete_rows)
226+ # patch_info.assert_has_calls(
227+ # [
228+ # call(
229+ # f"Upserting {len(all_updates)} rows from {mock_database_ent.name} table"
230+ # ),
231+ # call(
232+ # f"Deleting {len(to_delete_rows)} rows from {mock_database_ent.name} table"
233+ # ),
234+ # ]
235+ # )
236+
237+
238+ # def test_store_database_only_rows_to_update(syn):
239+ # """Test store_database function"""
240+ # database_synid = "syn123"
241+ # all_updates = pd.DataFrame(
242+ # {"test": ["test", "test2"], "foo": [1, 3], "baz": ["", 5]}
243+ # )
244+ # to_delete_rows = pd.DataFrame()
245+ # mock_database_ent = Mock()
246+ # mock_database_ent.name = "test_table"
247+ # # get the table entity
248+ # with (
249+ # patch.object(syn, "get", return_value=mock_database_ent) as patch_get,
250+ # patch.object(Table, "store_rows") as patch_store_rows,
251+ # patch.object(Table, "delete_rows") as patch_delete_rows,
252+ # patch.object(load.logger, "info") as patch_info,
253+ # ):
254+ # load.store_database(syn, database_synid, all_updates, to_delete_rows)
255+ # patch_get.assert_called_once_with(database_synid)
256+ # patch_store_rows.assert_called_once_with(all_updates)
257+ # patch_delete_rows.assert_not_called()
258+ # patch_info.assert_called_once_with(
259+ # f"Upserting {len(all_updates)} rows from {mock_database_ent.name} table"
260+ # )
261+
262+
263+ # def test_store_database_only_rows_to_delete(syn):
264+ # """Test store_database function"""
265+ # database_synid = "syn123"
266+ # all_updates = pd.DataFrame()
267+ # to_delete_rows = pd.DataFrame({0: ["3"], 1: ["5"]})
268+ # mock_database_ent = Mock()
269+ # mock_database_ent.name = "test_table"
270+ # # get the table entity
271+ # with (
272+ # patch.object(syn, "get", return_value=mock_database_ent) as patch_get,
273+ # patch.object(Table, "store_rows") as patch_store_rows,
274+ # patch.object(Table, "delete_rows") as patch_delete_rows,
275+ # patch.object(load.logger, "info") as patch_info,
276+ # ):
277+ # load.store_database(syn, database_synid, all_updates, to_delete_rows)
278+ # patch_get.assert_called_once_with(database_synid)
279+ # patch_store_rows.assert_not_called()
280+ # patch_delete_rows.assert_called_once_with(to_delete_rows)
281+ # patch_info.assert_called_once_with(
282+ # f"Deleting {len(to_delete_rows)} rows from {mock_database_ent.name} table"
283+ # )
284+
285+
286+ # def test_store_database_no_rows_to_update_and_delete(syn):
287+ # """Test store_database function"""
288+ # database_synid = "syn123"
289+ # all_updates = pd.DataFrame()
290+ # to_delete_rows = pd.DataFrame()
291+ # mock_database_ent = Mock()
292+ # mock_database_ent.name = "test_table"
293+ # # get the table entity
294+ # with (
295+ # patch.object(syn, "get", return_value=mock_database_ent) as patch_get,
296+ # patch.object(Table, "store_rows") as patch_store_rows,
297+ # patch.object(Table, "delete_rows") as patch_delete_rows,
298+ # patch.object(load.logger, "info") as patch_info,
299+ # ):
300+ # load.store_database(syn, database_synid, all_updates, to_delete_rows)
301+ # patch_get.assert_called_once_with(database_synid)
302+ # patch_store_rows.assert_not_called()
303+ # patch_delete_rows.assert_not_called()
304+ # patch_info.assert_not_called()
305305
306306
307307@pytest .mark .parametrize (
0 commit comments