text: # -*- coding: utf-8 -*-
  #
  # Licensed to the Apache Software Foundation (ASF) under one
  # or more contributor license agreements.  See the NOTICE file
  # distributed with this work for additional information
  # regarding copyright ownership.  The ASF licenses this file
  # to you under the Apache License, Version 2.0 (the
  # "License"); you may not use this file except in compliance
  # with the License.  You may obtain a copy of the License at
  #
  #   http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing,
  # software distributed under the License is distributed on an
  # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  # KIND, either express or implied.  See the License for the
  # specific language governing permissions and limitations
  # under the License.
  
  import unittest
  
  from airflow.contrib.operators.gcs_acl_operator import \
      GoogleCloudStorageBucketCreateAclEntryOperator, \
      GoogleCloudStorageObjectCreateAclEntryOperator
  from tests.contrib.operators.test_gcp_base import BaseGcpIntegrationTestCase, \
      SKIP_TEST_WARNING, GCP_GCS_KEY
  
  try:
      from unittest import mock
  except ImportError:
      try:
          import mock
      except ImportError:
          mock = None
  
  
  class GoogleCloudStorageAclTest(unittest.TestCase):
      @mock.patch('airflow.contrib.operators.gcs_acl_operator.GoogleCloudStorageHook')
      def test_bucket_create_acl(self, mock_hook):
          operator = GoogleCloudStorageBucketCreateAclEntryOperator(
              bucket="test-bucket",
              entity="test-entity",
              role="test-role",
              user_project="test-user-project",
              task_id="id"
          )
          operator.execute(None)
          mock_hook.return_value.insert_bucket_acl.assert_called_once_with(
              bucket="test-bucket",
              entity="test-entity",
              role="test-role",
              user_project="test-user-project"
          )
  
      @mock.patch('airflow.contrib.operators.gcs_acl_operator.GoogleCloudStorageHook')
      def test_object_create_acl(self, mock_hook):
          operator = GoogleCloudStorageObjectCreateAclEntryOperator(
              bucket="test-bucket",
              object_name="test-object",
              entity="test-entity",
              role="test-role",
              generation="test-generation",
              user_project="test-user-project",
              task_id="id"
          )
          operator.execute(None)
          mock_hook.return_value.insert_object_acl.assert_called_once_with(
              bucket="test-bucket",
              object_name="test-object",
              entity="test-entity",
              role="test-role",
              generation="test-generation",
              user_project="test-user-project"
          )
  
  
  @unittest.skipIf(
      BaseGcpIntegrationTestCase.skip_check(GCP_GCS_KEY), SKIP_TEST_WARNING)
  class CloudStorageExampleDagsIntegrationTest(BaseGcpIntegrationTestCase):
      def __init__(self, method_name='runTest'):
          super(CloudStorageExampleDagsIntegrationTest, self).__init__(
              method_name,
              dag_id='example_gcs_acl',
              gcp_key=GCP_GCS_KEY)
  
      def test_run_example_dag_gcs_acl(self):
          self._run_dag()
  