Example #1
0
 def test_instance_export_ex(self):
     # Mocking __init__ with an empty anonymous function
     with mock.patch.object(CloudSqlHook, "__init__", lambda x, y, z: None):
         hook = CloudSqlHook(None, None)
         # Simulating HttpError inside export_instance
         hook.get_conn = mock.Mock(
             side_effect=HttpError(resp={'status': '400'},
                                   content='Error content'.encode('utf-8')))
         with self.assertRaises(AirflowException) as cm:
             hook.export_instance(None, None, None)
         err = cm.exception
         self.assertIn("Exporting instance ", str(err))
Example #2
0
 def __init__(self,
              instance,
              project_id=None,
              gcp_conn_id='google_cloud_default',
              api_version='v1beta4',
              *args, **kwargs):
     self.project_id = project_id
     self.instance = instance
     self.gcp_conn_id = gcp_conn_id
     self.api_version = api_version
     self._validate_inputs()
     self._hook = CloudSqlHook(gcp_conn_id=self.gcp_conn_id,
                               api_version=self.api_version)
     super().__init__(*args, **kwargs)