def test_instance_db_delete_missing_project_id(self, mock_hook, _check_if_db_exists): _check_if_db_exists.return_value = True op = CloudSQLDeleteInstanceDatabaseOperator(instance=INSTANCE_NAME, database=DB_NAME, task_id="id") result = op.execute(None) self.assertTrue(result) mock_hook.assert_called_once_with(api_version="v1beta4", gcp_conn_id="google_cloud_default") mock_hook.return_value.delete_database.assert_called_once_with( project_id=None, instance=INSTANCE_NAME, database=DB_NAME)
def test_instance_db_delete_should_abort_and_succeed_if_not_exists( self, mock_hook, _check_if_db_exists): _check_if_db_exists.return_value = False op = CloudSQLDeleteInstanceDatabaseOperator(project_id=PROJECT_ID, instance=INSTANCE_NAME, database=DB_NAME, task_id="id") result = op.execute(None) self.assertTrue(result) mock_hook.assert_called_once_with(api_version="v1beta4", gcp_conn_id="google_cloud_default") mock_hook.return_value.delete_database.assert_not_called()
sql_import_task = CloudSQLImportInstanceOperator(project_id=GCP_PROJECT_ID, body=import_body, instance=INSTANCE_NAME2, task_id='sql_import_task') sql_import_task2 = CloudSQLImportInstanceOperator( body=import_body, instance=INSTANCE_NAME2, task_id='sql_import_task2') # [END howto_operator_cloudsql_import] # ############################################## # # ### DELETING A DATABASE FROM AN INSTANCE ##### # # ############################################## # # [START howto_operator_cloudsql_db_delete] sql_db_delete_task = CloudSQLDeleteInstanceDatabaseOperator( project_id=GCP_PROJECT_ID, instance=INSTANCE_NAME, database=DB_NAME, task_id='sql_db_delete_task') sql_db_delete_task2 = CloudSQLDeleteInstanceDatabaseOperator( instance=INSTANCE_NAME, database=DB_NAME, task_id='sql_db_delete_task2') # [END howto_operator_cloudsql_db_delete] # ############################################## # # ### INSTANCES TEAR DOWN ###################### # # ############################################## # # [START howto_operator_cloudsql_replicas_delete] sql_instance_failover_replica_delete_task = CloudSQLDeleteInstanceOperator( project_id=GCP_PROJECT_ID,