pankajastro commented on code in PR #24038:
URL: https://github.com/apache/airflow/pull/24038#discussion_r887615082


##########
tests/providers/microsoft/azure/operators/test_azure_service_bus_queue.py:
##########
@@ -0,0 +1,199 @@
+# 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.
+
+from unittest import mock
+
+import pytest
+from azure.servicebus import ServiceBusMessage
+
+from airflow.providers.microsoft.azure.operators.azure_service_bus_queue 
import (
+    AzureServiceBusCreateQueueOperator,
+    AzureServiceBusDeleteQueueOperator,
+    AzureServiceBusReceiveMessageOperator,
+    AzureServiceBusSendMessageOperator,
+)
+
+QUEUE_NAME = "test_queue"
+MESSAGE = "Test Message"
+MESSAGE_LIST = [MESSAGE + " " + str(n) for n in range(0, 10)]
+
+
+class TestAzureServiceBusCreateQueueOperator:
+    @pytest.mark.parametrize(
+        "mock_dl_msg_expiration, mock_batched_operation",
+        [
+            (True, True),
+            (True, False),
+            (False, True),
+            (False, False),
+        ],
+    )
+    def test_init(self, mock_dl_msg_expiration, mock_batched_operation):
+        """
+        Test init by creating AzureServiceBusCreateQueueOperator with task id, 
queue_name and
+         asserting with value
+        """
+        asb_create_queue_operator = AzureServiceBusCreateQueueOperator(
+            task_id="asb_create_queue",
+            queue_name=QUEUE_NAME,
+            max_delivery_count=10,
+            dead_lettering_on_message_expiration=mock_dl_msg_expiration,
+            enable_batched_operations=mock_batched_operation,
+        )
+        assert asb_create_queue_operator.task_id == "asb_create_queue"
+        assert asb_create_queue_operator.queue_name == QUEUE_NAME
+        assert asb_create_queue_operator.max_delivery_count == 10
+        assert asb_create_queue_operator.dead_lettering_on_message_expiration 
is mock_dl_msg_expiration
+        assert asb_create_queue_operator.enable_batched_operations is 
mock_batched_operation
+
+    @mock.patch(
+        
"airflow.providers.microsoft.azure.hooks.asb_admin_client.AzureServiceBusAdminClientHook.get_conn"
+    )
+    def test_create_queue(self, mock_get_conn):
+        """
+        Test AzureServiceBusCreateQueueOperator passed with the queue name,
+        mocking the connection details, hook create_queue function
+        """
+        asb_create_queue_operator = AzureServiceBusCreateQueueOperator(
+            task_id="asb_create_queue_operator",
+            queue_name=QUEUE_NAME,
+            max_delivery_count=10,
+            dead_lettering_on_message_expiration=True,
+            enable_batched_operations=True,
+        )
+        asb_create_queue_operator.execute(None)
+        
mock_get_conn.return_value.__enter__.return_value.create_queue.assert_called_once_with(
+            QUEUE_NAME,
+            max_delivery_count=10,
+            dead_lettering_on_message_expiration=True,
+            enable_batched_operations=True,
+        )
+
+
+class TestAzureServiceBusDeleteQueueOperator:
+    def test_init(self):
+        """
+        Test init by creating AzureServiceBusDeleteQueueOperator with task id, 
queue_name and
+         asserting with values

Review Comment:
   nit: Delete extra starting space



##########
tests/providers/microsoft/azure/operators/test_azure_service_bus_queue.py:
##########
@@ -0,0 +1,199 @@
+# 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.
+
+from unittest import mock
+
+import pytest
+from azure.servicebus import ServiceBusMessage
+
+from airflow.providers.microsoft.azure.operators.azure_service_bus_queue 
import (
+    AzureServiceBusCreateQueueOperator,
+    AzureServiceBusDeleteQueueOperator,
+    AzureServiceBusReceiveMessageOperator,
+    AzureServiceBusSendMessageOperator,
+)
+
+QUEUE_NAME = "test_queue"
+MESSAGE = "Test Message"
+MESSAGE_LIST = [MESSAGE + " " + str(n) for n in range(0, 10)]
+
+
+class TestAzureServiceBusCreateQueueOperator:
+    @pytest.mark.parametrize(
+        "mock_dl_msg_expiration, mock_batched_operation",
+        [
+            (True, True),
+            (True, False),
+            (False, True),
+            (False, False),
+        ],
+    )
+    def test_init(self, mock_dl_msg_expiration, mock_batched_operation):
+        """
+        Test init by creating AzureServiceBusCreateQueueOperator with task id, 
queue_name and
+         asserting with value

Review Comment:
   nit: Delete extra starting space



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to