def test_deletes_data_while_worker_pool_is_running( self, database: Database) -> None: """Test delete of data while worker pool is running.""" mocked_worker_pool: MagicMock = MagicMock() mocked_worker_pool.get_status.return_value = "running" mocked_background_scheduler: MagicMock = MagicMock() mocked_background_scheduler.delete_tables.return_value = True database._worker_pool = mocked_worker_pool database._background_scheduler = mocked_background_scheduler result: bool = database.delete_data(default_tables) mocked_worker_pool.get_status.assert_called_once() mocked_background_scheduler.delete_tables.assert_not_called() assert type(result) is bool assert not result
def test_deletes_data_while_worker_pool_is_closed_and_load_table_is_successful( self, database: Database) -> None: """Test delete of data while worker pool is closed and background scheduler is returning true.""" mocked_worker_pool: MagicMock = MagicMock() mocked_worker_pool.get_status.return_value = "closed" mocked_background_scheduler: MagicMock = MagicMock() mocked_background_scheduler.delete_tables.return_value = True database._worker_pool = mocked_worker_pool database._background_scheduler = mocked_background_scheduler result: bool = database.delete_data(default_tables) mocked_worker_pool.get_status.assert_called_once() mocked_background_scheduler.delete_tables.assert_called_once_with( default_tables) assert type(result) is bool assert result