Ejemplo n.º 1
0
 def test_delete_execute_empty_project_id(self, mock_hook):
     op = BigtableDeleteInstanceOperator(instance_id=INSTANCE_ID,
                                         task_id="id",
                                         gcp_conn_id=GCP_CONN_ID)
     op.execute(None)
     mock_hook.assert_called_once_with(gcp_conn_id=GCP_CONN_ID)
     mock_hook.return_value.delete_instance.assert_called_once_with(
         project_id=None, instance_id=INSTANCE_ID)
Ejemplo n.º 2
0
 def test_deleting_instance_that_doesnt_exists_empty_project_id(
         self, mock_hook):
     op = BigtableDeleteInstanceOperator(instance_id=INSTANCE_ID,
                                         task_id="id",
                                         gcp_conn_id=GCP_CONN_ID)
     mock_hook.return_value.delete_instance.side_effect = mock.Mock(
         side_effect=google.api_core.exceptions.NotFound(
             "Instance not found."))
     op.execute(None)
     mock_hook.assert_called_once_with(gcp_conn_id=GCP_CONN_ID)
     mock_hook.return_value.delete_instance.assert_called_once_with(
         project_id=None, instance_id=INSTANCE_ID)
Ejemplo n.º 3
0
    def test_different_error_reraised(self, mock_hook):
        op = BigtableDeleteInstanceOperator(project_id=PROJECT_ID,
                                            instance_id=INSTANCE_ID,
                                            task_id="id",
                                            gcp_conn_id=GCP_CONN_ID)
        mock_hook.return_value.delete_instance.side_effect = mock.Mock(
            side_effect=google.api_core.exceptions.GoogleAPICallError('error'))

        with self.assertRaises(google.api_core.exceptions.GoogleAPICallError):
            op.execute(None)

        mock_hook.assert_called_once_with(gcp_conn_id=GCP_CONN_ID)
        mock_hook.return_value.delete_instance.assert_called_once_with(
            project_id=PROJECT_ID, instance_id=INSTANCE_ID)