Ejemplo n.º 1
0
 def test_instance_delete_missing_project_id(self, mock_hook,
                                             _check_if_instance_exists):
     _check_if_instance_exists.return_value = True
     op = CloudSQLDeleteInstanceOperator(instance=INSTANCE_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_instance.assert_called_once_with(
         project_id=None, instance=INSTANCE_NAME)
Ejemplo n.º 2
0
 def test_instance_delete_should_abort_and_succeed_if_not_exists(
         self, mock_hook, _check_if_instance_exists):
     _check_if_instance_exists.return_value = False
     op = CloudSQLDeleteInstanceOperator(project_id=PROJECT_ID,
                                         instance=INSTANCE_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_instance.assert_not_called()
Ejemplo n.º 3
0
 def test_instance_delete(self, mock_hook, _check_if_instance_exists):
     _check_if_instance_exists.return_value = True
     op = CloudSQLDeleteInstanceOperator(project_id=PROJECT_ID,
                                         instance=INSTANCE_NAME,
                                         task_id="id")
     result = op.execute(None)
     assert result
     mock_hook.assert_called_once_with(
         api_version="v1beta4",
         gcp_conn_id="google_cloud_default",
         impersonation_chain=None,
     )
     mock_hook.return_value.delete_instance.assert_called_once_with(
         project_id=PROJECT_ID, instance=INSTANCE_NAME)