feluelle commented on a change in pull request #8895:
URL: https://github.com/apache/airflow/pull/8895#discussion_r429663166



##########
File path: tests/providers/amazon/aws/hooks/test_s3.py
##########
@@ -313,6 +313,25 @@ def test_copy_object_acl(self, s3_bucket):
             assert ((response['Grants'][0]['Permission'] == 'FULL_CONTROL') and
                     (len(response['Grants']) == 1))
 
+    @mock_s3
+    def test_delete_bucket(self, s3_bucket):
+        # assert if the bucket is created
+        mock_hook = S3Hook()
+        mock_hook.create_bucket(bucket_name=s3_bucket)
+        assert mock_hook.check_for_bucket(bucket_name=s3_bucket)
+        # add keys to bucket
+        for i in range(0, 3):
+            mock_hook.load_file_obj(

Review comment:
       You should assert for the mock call - not call the mock here. 
`mock_hook.load_string.assert_called_once_with`

##########
File path: tests/providers/amazon/aws/operators/test_s3_bucket.py
##########
@@ -0,0 +1,63 @@
+#
+# 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 io
+import os
+import unittest
+
+from moto import mock_s3
+
+from airflow.providers.amazon.aws.hooks.s3 import S3Hook
+from airflow.providers.amazon.aws.operators.s3_bucket import 
S3CreateBucketOperator, S3DeleteBucketOperator
+
+BUCKET_NAME = os.environ.get("BUCKET_NAME", "test-airflow-bucket")
+TASK_ID = os.environ.get("TASK_ID", "test-s3-operator")
+
+
+class TestS3CreateBucketOperator(unittest.TestCase):
+    @mock_s3
+    def test_execute(self):
+        mock_hook = S3Hook()
+        # execute s3 bucket create operator
+        op = S3CreateBucketOperator(bucket_name=BUCKET_NAME, task_id=TASK_ID)
+        op.execute({})
+        # assert if the bucket has been created
+        self.assertTrue(mock_hook.check_for_bucket(bucket_name=BUCKET_NAME))
+
+
+class TestS3DeleteBucketOperator(unittest.TestCase):
+    @mock_s3
+    def test_execute(self):
+        # assert if the bucket is created
+        mock_hook = S3Hook()
+        mock_hook.create_bucket(bucket_name=BUCKET_NAME)
+        self.assertTrue(mock_hook.check_for_bucket(bucket_name=BUCKET_NAME))
+        # add keys to bucket
+        for i in range(0, 3):
+            mock_hook.load_file_obj(

Review comment:
       same here.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to