def test_drop_database( self, mock_logger, mock_pg_engine, mock_pg_execute, connection, ): database = connection.engine.url.database mock_pg_engine.return_value = connection.engine drop_database(database, echo=True) assert mock_logger.debug.call_count == 2 mock_logger.debug.assert_any_call(f"Dropping database: {database}") mock_logger.debug.assert_any_call(f"Dropped database: {database}") mock_pg_engine.assert_any_call(database="postgres", echo=True) mock_pg_execute.assert_any_call( connection.engine, f"DROP DATABASE IF EXISTS {database}", )
def engine(dns): engine = sa.create_engine(dns) drop_database("testdb") create_database("testdb") yield engine engine.dispose()