Esempio n. 1
0
 def test_instance_patch_should_bubble_up_ex_if_not_exists(
         self, mock_hook, _check_if_instance_exists):
     _check_if_instance_exists.return_value = False
     with self.assertRaises(AirflowException) as cm:
         op = CloudSQLInstancePatchOperator(project_id=PROJECT_ID,
                                            body=PATCH_BODY,
                                            instance=INSTANCE_NAME,
                                            task_id="id")
         op.execute(None)
     err = cm.exception
     self.assertIn('specify another instance to patch', str(err))
     mock_hook.assert_called_once_with(api_version="v1beta4",
                                       gcp_conn_id="google_cloud_default")
     mock_hook.return_value.patch_instance.assert_not_called()
Esempio n. 2
0
 def test_instance_patch_missing_project_id(self, mock_hook):
     mock_hook.return_value.patch_instance.return_value = True
     op = CloudSQLInstancePatchOperator(body=PATCH_BODY,
                                        instance=INSTANCE_NAME,
                                        task_id="id")
     result = op.execute(None)
     mock_hook.assert_called_once_with(api_version="v1beta4",
                                       gcp_conn_id="google_cloud_default")
     mock_hook.return_value.patch_instance.assert_called_once_with(
         project_id=None, body=PATCH_BODY, instance=INSTANCE_NAME)
     self.assertTrue(result)
Esempio n. 3
0
 def test_instance_patch(self, mock_hook):
     mock_hook.return_value.patch_instance.return_value = True
     op = CloudSQLInstancePatchOperator(project_id=PROJECT_ID,
                                        body=PATCH_BODY,
                                        instance=INSTANCE_NAME,
                                        task_id="id")
     result = op.execute(None)
     mock_hook.assert_called_once_with(
         api_version="v1beta4",
         gcp_conn_id="google_cloud_default",
         impersonation_chain=None,
     )
     mock_hook.return_value.patch_instance.assert_called_once_with(
         project_id=PROJECT_ID, body=PATCH_BODY, instance=INSTANCE_NAME)
     assert result