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()
 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. 3
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)
 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")
     mock_hook.return_value.patch_instance.assert_called_once_with(
         PROJECT_ID, PATCH_BODY, INSTANCE_NAME
     )
     self.assertTrue(result)