From e498a30cc1683ffb2d07101769caf91abf77e8b8 Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Wed, 28 Oct 2020 14:41:43 -0700 Subject: [PATCH 1/7] added receive one message and tests --- .../azure/storage/queue/_queue_client.py | 55 ++++ .../storage/queue/aio/_queue_client_async.py | 57 +++- .../test_queue.test_receive_one_message.yaml | 281 ++++++++++++++++++ ..._queue_async.test_receive_one_message.yaml | 219 ++++++++++++++ .../azure-storage-queue/tests/test_queue.py | 31 ++ .../tests/test_queue_async.py | 31 ++ 6 files changed, 673 insertions(+), 1 deletion(-) create mode 100644 sdk/storage/azure-storage-queue/tests/recordings/test_queue.test_receive_one_message.yaml create mode 100644 sdk/storage/azure-storage-queue/tests/recordings/test_queue_async.test_receive_one_message.yaml diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/_queue_client.py b/sdk/storage/azure-storage-queue/azure/storage/queue/_queue_client.py index 56f4207b2a75..c08f5a695fc4 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/_queue_client.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/_queue_client.py @@ -481,6 +481,61 @@ def send_message( # type: ignore except StorageErrorException as error: process_storage_error(error) + @distributed_trace + def receive_one_message(self, **kwargs): + # type: (Optional[Any]) -> QueueMessage + """Removes one message from the front of the queue. + + When the message is retrieved from the queue, the response includes the message + content and a pop_receipt value, which is required to delete the message. + The message is not automatically deleted from the queue, but after it has + been retrieved, it is not visible to other clients for the time interval + specified by the visibility_timeout parameter. + + If the key-encryption-key or resolver field is set on the local service object, the message will be + decrypted before being returned. + + :keyword int visibility_timeout: + If not specified, the default value is 0. Specifies the + new visibility timeout value, in seconds, relative to server time. + The value must be larger than or equal to 0, and cannot be + larger than 7 days. The visibility timeout of a message cannot be + set to a value later than the expiry time. visibility_timeout + should be set to a value smaller than the time-to-live value. + :keyword int timeout: + The server timeout, expressed in seconds. + :return: + Returns a message from the Queue. + :rtype: ~azure.storage.queue.QueueMessage + + .. admonition:: Example: + + .. literalinclude:: ../samples/queue_samples_message.py + :start-after: [START receive_one_message] + :end-before: [END receive_one_message] + :language: python + :dedent: 12 + :caption: Receive one message from the queue. + """ + visibility_timeout = kwargs.pop('visibility_timeout', None) + timeout = kwargs.pop('timeout', None) + self._config.message_decode_policy.configure( + require_encryption=self.require_encryption, + key_encryption_key=self.key_encryption_key, + resolver=self.key_resolver_function) + try: + message = self._client.messages.dequeue( + number_of_messages=1, + visibilitytimeout=visibility_timeout, + timeout=timeout, + cls=self._config.message_decode_policy, + **kwargs + ) + wrapped_message = QueueMessage._from_generated(message[0]) + return wrapped_message + except StorageErrorException as error: + process_storage_error(error) + @distributed_trace def receive_messages(self, **kwargs): # type: (Optional[Any]) -> ItemPaged[QueueMessage] diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_client_async.py b/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_client_async.py index 0bf0b9076763..65f02b1f05c6 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_client_async.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_client_async.py @@ -400,8 +400,63 @@ async def send_message( # type: ignore except StorageErrorException as error: process_storage_error(error) + @distributed_trace_async + async def receive_one_message(self, **kwargs): + # type: (Optional[Any]) -> QueueMessage + """Removes one message from the front of the queue. + + When the message is retrieved from the queue, the response includes the message + content and a pop_receipt value, which is required to delete the message. + The message is not automatically deleted from the queue, but after it has + been retrieved, it is not visible to other clients for the time interval + specified by the visibility_timeout parameter. + + If the key-encryption-key or resolver field is set on the local service object, the message will be + decrypted before being returned. + + :keyword int visibility_timeout: + If not specified, the default value is 0. Specifies the + new visibility timeout value, in seconds, relative to server time. + The value must be larger than or equal to 0, and cannot be + larger than 7 days. The visibility timeout of a message cannot be + set to a value later than the expiry time. visibility_timeout + should be set to a value smaller than the time-to-live value. + :keyword int timeout: + The server timeout, expressed in seconds. + :return: + Returns a message from the Queue. + :rtype: ~azure.storage.queue.QueueMessage + + .. admonition:: Example: + + .. literalinclude:: ../samples/queue_samples_message_async.py + :start-after: [START receive_one_message] + :end-before: [END receive_one_message] + :language: python + :dedent: 12 + :caption: Receive one message from the queue. + """ + visibility_timeout = kwargs.pop('visibility_timeout', None) + timeout = kwargs.pop('timeout', None) + self._config.message_decode_policy.configure( + require_encryption=self.require_encryption, + key_encryption_key=self.key_encryption_key, + resolver=self.key_resolver_function) + try: + message = await self._client.messages.dequeue( + number_of_messages=1, + visibilitytimeout=visibility_timeout, + timeout=timeout, + cls=self._config.message_decode_policy, + **kwargs + ) + wrapped_message = QueueMessage._from_generated(message[0]) + return wrapped_message + except StorageErrorException as error: + process_storage_error(error) + @distributed_trace - def receive_messages(self, **kwargs): + async def receive_messages(self, **kwargs): # type: (Optional[Any]) -> AsyncItemPaged[QueueMessage] """Removes one or more messages from the front of the queue. diff --git a/sdk/storage/azure-storage-queue/tests/recordings/test_queue.test_receive_one_message.yaml b/sdk/storage/azure-storage-queue/tests/recordings/test_queue.test_receive_one_message.yaml new file mode 100644 index 000000000000..e5229e50ba03 --- /dev/null +++ b/sdk/storage/azure-storage-queue/tests/recordings/test_queue.test_receive_one_message.yaml @@ -0,0 +1,281 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Wed, 28 Oct 2020 21:22:05 GMT + x-ms-version: + - '2018-03-28' + method: PUT + uri: https://storagename.queue.core.windows.net/pyqueuesync3a60e5a + response: + body: + string: '' + headers: + content-length: + - '0' + date: + - Wed, 28 Oct 2020 21:22:05 GMT + server: + - Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 + x-ms-version: + - '2018-03-28' + status: + code: 201 + message: Created +- request: + body: ' + + message1' + headers: + Accept: + - application/xml + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '103' + Content-Type: + - application/xml; charset=utf-8 + User-Agent: + - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Wed, 28 Oct 2020 21:22:05 GMT + x-ms-version: + - '2018-03-28' + method: POST + uri: https://storagename.queue.core.windows.net/pyqueuesync3a60e5a/messages + response: + body: + string: "\uFEFFa05e3fee-daca-4f99-b10f-66aa11b0de10Wed, + 28 Oct 2020 21:22:05 GMTWed, 04 Nov 2020 21:22:05 + GMTAgAAAAMAAAAAAAAAjSXPYnCt1gE=Wed, + 28 Oct 2020 21:22:05 GMT" + headers: + content-type: + - application/xml + date: + - Wed, 28 Oct 2020 21:22:05 GMT + server: + - Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 + transfer-encoding: + - chunked + x-ms-version: + - '2018-03-28' + status: + code: 201 + message: Created +- request: + body: ' + + message2' + headers: + Accept: + - application/xml + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '103' + Content-Type: + - application/xml; charset=utf-8 + User-Agent: + - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Wed, 28 Oct 2020 21:22:06 GMT + x-ms-version: + - '2018-03-28' + method: POST + uri: https://storagename.queue.core.windows.net/pyqueuesync3a60e5a/messages + response: + body: + string: "\uFEFF49a60678-55e0-4496-ac7c-f615a7d30e5cWed, + 28 Oct 2020 21:22:06 GMTWed, 04 Nov 2020 21:22:06 + GMTAgAAAAMAAAAAAAAAIg3mYnCt1gE=Wed, + 28 Oct 2020 21:22:06 GMT" + headers: + content-type: + - application/xml + date: + - Wed, 28 Oct 2020 21:22:05 GMT + server: + - Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 + transfer-encoding: + - chunked + x-ms-version: + - '2018-03-28' + status: + code: 201 + message: Created +- request: + body: ' + + message3' + headers: + Accept: + - application/xml + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '103' + Content-Type: + - application/xml; charset=utf-8 + User-Agent: + - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Wed, 28 Oct 2020 21:22:06 GMT + x-ms-version: + - '2018-03-28' + method: POST + uri: https://storagename.queue.core.windows.net/pyqueuesync3a60e5a/messages + response: + body: + string: "\uFEFFeb0e2fd2-4cc2-4d0b-98bb-bff0d848441dWed, + 28 Oct 2020 21:22:06 GMTWed, 04 Nov 2020 21:22:06 + GMTAgAAAAMAAAAAAAAAXgb+YnCt1gE=Wed, + 28 Oct 2020 21:22:06 GMT" + headers: + content-type: + - application/xml + date: + - Wed, 28 Oct 2020 21:22:05 GMT + server: + - Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 + transfer-encoding: + - chunked + x-ms-version: + - '2018-03-28' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/xml + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Wed, 28 Oct 2020 21:22:06 GMT + x-ms-version: + - '2018-03-28' + method: GET + uri: https://storagename.queue.core.windows.net/pyqueuesync3a60e5a/messages?numofmessages=1 + response: + body: + string: "\uFEFFa05e3fee-daca-4f99-b10f-66aa11b0de10Wed, + 28 Oct 2020 21:22:05 GMTWed, 04 Nov 2020 21:22:05 + GMTAgAAAAMAAAAAAAAATy33dHCt1gE=Wed, + 28 Oct 2020 21:22:36 GMT1message1" + headers: + cache-control: + - no-cache + content-type: + - application/xml + date: + - Wed, 28 Oct 2020 21:22:05 GMT + server: + - Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 + transfer-encoding: + - chunked + x-ms-version: + - '2018-03-28' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/xml + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Wed, 28 Oct 2020 21:22:06 GMT + x-ms-version: + - '2018-03-28' + method: GET + uri: https://storagename.queue.core.windows.net/pyqueuesync3a60e5a/messages?numofmessages=1 + response: + body: + string: "\uFEFF49a60678-55e0-4496-ac7c-f615a7d30e5cWed, + 28 Oct 2020 21:22:06 GMTWed, 04 Nov 2020 21:22:06 + GMTAgAAAAMAAAAAAAAAzKUUdXCt1gE=Wed, + 28 Oct 2020 21:22:36 GMT1message2" + headers: + cache-control: + - no-cache + content-type: + - application/xml + date: + - Wed, 28 Oct 2020 21:22:06 GMT + server: + - Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 + transfer-encoding: + - chunked + x-ms-version: + - '2018-03-28' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/xml + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Wed, 28 Oct 2020 21:22:06 GMT + x-ms-version: + - '2018-03-28' + method: GET + uri: https://storagename.queue.core.windows.net/pyqueuesync3a60e5a/messages?peekonly=true + response: + body: + string: "\uFEFFeb0e2fd2-4cc2-4d0b-98bb-bff0d848441dWed, + 28 Oct 2020 21:22:06 GMTWed, 04 Nov 2020 21:22:06 + GMT0message3" + headers: + cache-control: + - no-cache + content-type: + - application/xml + date: + - Wed, 28 Oct 2020 21:22:06 GMT + server: + - Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 + transfer-encoding: + - chunked + x-ms-version: + - '2018-03-28' + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/storage/azure-storage-queue/tests/recordings/test_queue_async.test_receive_one_message.yaml b/sdk/storage/azure-storage-queue/tests/recordings/test_queue_async.test_receive_one_message.yaml new file mode 100644 index 000000000000..2e494c6dd2f4 --- /dev/null +++ b/sdk/storage/azure-storage-queue/tests/recordings/test_queue_async.test_receive_one_message.yaml @@ -0,0 +1,219 @@ +interactions: +- request: + body: null + headers: + User-Agent: + - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Wed, 28 Oct 2020 21:41:16 GMT + x-ms-version: + - '2018-03-28' + method: PUT + uri: https://storagename.queue.core.windows.net/pyqueueasync640e10d7 + response: + body: + string: '' + headers: + content-length: '0' + date: Wed, 28 Oct 2020 21:41:16 GMT + server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 + x-ms-version: '2018-03-28' + status: + code: 201 + message: Created + url: https://seanmcccanary3.queue.core.windows.net/pyqueueasync640e10d7 +- request: + body: ' + + message1' + headers: + Accept: + - application/xml + Content-Length: + - '103' + Content-Type: + - application/xml; charset=utf-8 + User-Agent: + - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Wed, 28 Oct 2020 21:41:16 GMT + x-ms-version: + - '2018-03-28' + method: POST + uri: https://storagename.queue.core.windows.net/pyqueueasync640e10d7/messages + response: + body: + string: "\uFEFFe6af54c5-6054-4146-9ac1-e7b29fe4b3f1Wed, + 28 Oct 2020 21:41:16 GMTWed, 04 Nov 2020 21:41:16 + GMTAgAAAAMAAAAAAAAAACHNEHOt1gE=Wed, + 28 Oct 2020 21:41:16 GMT" + headers: + content-type: application/xml + date: Wed, 28 Oct 2020 21:41:16 GMT + server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 + transfer-encoding: chunked + x-ms-version: '2018-03-28' + status: + code: 201 + message: Created + url: https://seanmcccanary3.queue.core.windows.net/pyqueueasync640e10d7/messages +- request: + body: ' + + message2' + headers: + Accept: + - application/xml + Content-Length: + - '103' + Content-Type: + - application/xml; charset=utf-8 + User-Agent: + - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Wed, 28 Oct 2020 21:41:16 GMT + x-ms-version: + - '2018-03-28' + method: POST + uri: https://storagename.queue.core.windows.net/pyqueueasync640e10d7/messages + response: + body: + string: "\uFEFFc2f17fee-0526-4832-87ad-3c7a25439a53Wed, + 28 Oct 2020 21:41:16 GMTWed, 04 Nov 2020 21:41:16 + GMTAgAAAAMAAAAAAAAAD1zXEHOt1gE=Wed, + 28 Oct 2020 21:41:16 GMT" + headers: + content-type: application/xml + date: Wed, 28 Oct 2020 21:41:16 GMT + server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 + transfer-encoding: chunked + x-ms-version: '2018-03-28' + status: + code: 201 + message: Created + url: https://seanmcccanary3.queue.core.windows.net/pyqueueasync640e10d7/messages +- request: + body: ' + + message3' + headers: + Accept: + - application/xml + Content-Length: + - '103' + Content-Type: + - application/xml; charset=utf-8 + User-Agent: + - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Wed, 28 Oct 2020 21:41:16 GMT + x-ms-version: + - '2018-03-28' + method: POST + uri: https://storagename.queue.core.windows.net/pyqueueasync640e10d7/messages + response: + body: + string: "\uFEFF5dcd17c8-94ac-4d55-922e-308c7974fc3fWed, + 28 Oct 2020 21:41:17 GMTWed, 04 Nov 2020 21:41:17 + GMTAgAAAAMAAAAAAAAApNPgEHOt1gE=Wed, + 28 Oct 2020 21:41:17 GMT" + headers: + content-type: application/xml + date: Wed, 28 Oct 2020 21:41:16 GMT + server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 + transfer-encoding: chunked + x-ms-version: '2018-03-28' + status: + code: 201 + message: Created + url: https://seanmcccanary3.queue.core.windows.net/pyqueueasync640e10d7/messages +- request: + body: null + headers: + Accept: + - application/xml + User-Agent: + - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Wed, 28 Oct 2020 21:41:17 GMT + x-ms-version: + - '2018-03-28' + method: GET + uri: https://storagename.queue.core.windows.net/pyqueueasync640e10d7/messages?numofmessages=1 + response: + body: + string: "\uFEFFe6af54c5-6054-4146-9ac1-e7b29fe4b3f1Wed, + 28 Oct 2020 21:41:16 GMTWed, 04 Nov 2020 21:41:16 + GMTAgAAAAMAAAAAAAAAbDzMInOt1gE=Wed, + 28 Oct 2020 21:41:47 GMT1message1" + headers: + cache-control: no-cache + content-type: application/xml + date: Wed, 28 Oct 2020 21:41:16 GMT + server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 + transfer-encoding: chunked + x-ms-version: '2018-03-28' + status: + code: 200 + message: OK + url: https://seanmcccanary3.queue.core.windows.net/pyqueueasync640e10d7/messages?numofmessages=1 +- request: + body: null + headers: + Accept: + - application/xml + User-Agent: + - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Wed, 28 Oct 2020 21:41:17 GMT + x-ms-version: + - '2018-03-28' + method: GET + uri: https://storagename.queue.core.windows.net/pyqueueasync640e10d7/messages?numofmessages=1 + response: + body: + string: "\uFEFFc2f17fee-0526-4832-87ad-3c7a25439a53Wed, + 28 Oct 2020 21:41:16 GMTWed, 04 Nov 2020 21:41:16 + GMTAgAAAAMAAAAAAAAAYVDWInOt1gE=Wed, + 28 Oct 2020 21:41:47 GMT1message2" + headers: + cache-control: no-cache + content-type: application/xml + date: Wed, 28 Oct 2020 21:41:17 GMT + server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 + transfer-encoding: chunked + x-ms-version: '2018-03-28' + status: + code: 200 + message: OK + url: https://seanmcccanary3.queue.core.windows.net/pyqueueasync640e10d7/messages?numofmessages=1 +- request: + body: null + headers: + Accept: + - application/xml + User-Agent: + - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Wed, 28 Oct 2020 21:41:17 GMT + x-ms-version: + - '2018-03-28' + method: GET + uri: https://storagename.queue.core.windows.net/pyqueueasync640e10d7/messages?peekonly=true + response: + body: + string: "\uFEFF5dcd17c8-94ac-4d55-922e-308c7974fc3fWed, + 28 Oct 2020 21:41:17 GMTWed, 04 Nov 2020 21:41:17 + GMT0message3" + headers: + cache-control: no-cache + content-type: application/xml + date: Wed, 28 Oct 2020 21:41:17 GMT + server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 + transfer-encoding: chunked + x-ms-version: '2018-03-28' + status: + code: 200 + message: OK + url: https://seanmcccanary3.queue.core.windows.net/pyqueueasync640e10d7/messages?peekonly=true +version: 1 diff --git a/sdk/storage/azure-storage-queue/tests/test_queue.py b/sdk/storage/azure-storage-queue/tests/test_queue.py index d556a12c8509..359900204643 100644 --- a/sdk/storage/azure-storage-queue/tests/test_queue.py +++ b/sdk/storage/azure-storage-queue/tests/test_queue.py @@ -322,6 +322,37 @@ def test_get_messages(self, resource_group, location, storage_account, storage_a self.assertIsInstance(message.expires_on, datetime) self.assertIsInstance(message.next_visible_on, datetime) + @GlobalStorageAccountPreparer() + def test_receive_one_message(self, resource_group, location, storage_account, storage_account_key): + # Action + qsc = QueueServiceClient(self.account_url(storage_account, "queue"), storage_account_key) + queue_client = self._get_queue_reference(qsc) + queue_client.create_queue() + queue_client.send_message(u'message1') + queue_client.send_message(u'message2') + queue_client.send_message(u'message3') + + message1 = queue_client.receive_one_message() + message2 = queue_client.receive_one_message() + peeked_message3 = queue_client.peek_messages()[0] + + # Asserts + self.assertIsNotNone(message1) + self.assertNotEqual('', message1.id) + self.assertEqual(u'message1', message1.content) + self.assertNotEqual('', message1.pop_receipt) + self.assertEqual(1, message1.dequeue_count) + + self.assertIsNotNone(message2) + self.assertNotEqual('', message2.id) + self.assertEqual(u'message2', message2.content) + self.assertNotEqual('', message2.pop_receipt) + self.assertEqual(1, message2.dequeue_count) + + self.assertEqual(u'message3', peeked_message3.content) + self.assertEqual(0, peeked_message3.dequeue_count) + + @GlobalStorageAccountPreparer() def test_get_messages_with_options(self, resource_group, location, storage_account, storage_account_key): # Action diff --git a/sdk/storage/azure-storage-queue/tests/test_queue_async.py b/sdk/storage/azure-storage-queue/tests/test_queue_async.py index dfc4d008f4de..933ac338ab21 100644 --- a/sdk/storage/azure-storage-queue/tests/test_queue_async.py +++ b/sdk/storage/azure-storage-queue/tests/test_queue_async.py @@ -353,6 +353,37 @@ async def test_get_messages(self, resource_group, location, storage_account, sto self.assertIsInstance(message.expires_on, datetime) self.assertIsInstance(message.next_visible_on, datetime) + + @GlobalStorageAccountPreparer() + @AsyncStorageTestCase.await_prepared_test + async def test_receive_one_message(self, resource_group, location, storage_account, storage_account_key): + # Action + qsc = QueueServiceClient(self.account_url(storage_account, "queue"), storage_account_key, transport=AiohttpTestTransport()) + queue_client = await self._create_queue(qsc) + await queue_client.send_message(u'message1') + await queue_client.send_message(u'message2') + await queue_client.send_message(u'message3') + + message1 = await queue_client.receive_one_message() + message2 = await queue_client.receive_one_message() + peeked_message3 = await queue_client.peek_messages() + + # Asserts + self.assertIsNotNone(message1) + self.assertNotEqual('', message1.id) + self.assertEqual(u'message1', message1.content) + self.assertNotEqual('', message1.pop_receipt) + self.assertEqual(1, message1.dequeue_count) + + self.assertIsNotNone(message2) + self.assertNotEqual('', message2.id) + self.assertEqual(u'message2', message2.content) + self.assertNotEqual('', message2.pop_receipt) + self.assertEqual(1, message2.dequeue_count) + + self.assertEqual(u'message3', peeked_message3[0].content) + self.assertEqual(0, peeked_message3[0].dequeue_count) + @GlobalStorageAccountPreparer() @AsyncStorageTestCase.await_prepared_test async def test_get_messages_with_options(self, resource_group, location, storage_account, storage_account_key): From 48bdc75c38a1bd814b3acea7660ffa9ee1bdc689 Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Wed, 28 Oct 2020 15:00:10 -0700 Subject: [PATCH 2/7] added samples --- .../storage/queue/aio/_queue_client_async.py | 2 +- .../samples/queue_samples_message.py | 35 +++++++++++++-- .../samples/queue_samples_message_async.py | 43 ++++++++++++++++--- 3 files changed, 70 insertions(+), 10 deletions(-) diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_client_async.py b/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_client_async.py index 65f02b1f05c6..da2e132a1d4f 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_client_async.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_client_async.py @@ -456,7 +456,7 @@ async def receive_one_message(self, **kwargs): process_storage_error(error) @distributed_trace - async def receive_messages(self, **kwargs): + def receive_messages(self, **kwargs): # type: (Optional[Any]) -> AsyncItemPaged[QueueMessage] """Removes one or more messages from the front of the queue. diff --git a/sdk/storage/azure-storage-queue/samples/queue_samples_message.py b/sdk/storage/azure-storage-queue/samples/queue_samples_message.py index f5c72c54a120..881a9f969b93 100644 --- a/sdk/storage/azure-storage-queue/samples/queue_samples_message.py +++ b/sdk/storage/azure-storage-queue/samples/queue_samples_message.py @@ -179,7 +179,7 @@ def list_message_pages(self): finally: queue.delete_queue() - def delete_and_clear_messages(self): + def receive_one_message_from_queue(self): # Instantiate a queue client from azure.storage.queue import QueueClient queue = QueueClient.from_connection_string(self.connection_string, "myqueue5") @@ -187,6 +187,34 @@ def delete_and_clear_messages(self): # Create the queue queue.create_queue() + try: + queue.send_message(u"message1") + queue.send_message(u"message2") + queue.send_message(u"message3") + + # [START receive_one_message] + # Pop two messages from the front of the queue + message1 = queue.receive_one_message() + message2 = queue.receive_one_message() + # We should see message 3 if we peek + message3 = queue.peek_messages()[0] + + print(message1.content) + print(message2.content) + print(message3.content) + # [END receive_one_message] + + finally: + queue.delete_queue() + + def delete_and_clear_messages(self): + # Instantiate a queue client + from azure.storage.queue import QueueClient + queue = QueueClient.from_connection_string(self.connection_string, "myqueue6") + + # Create the queue + queue.create_queue() + try: # Send messages queue.send_message(u"message1") @@ -214,7 +242,7 @@ def delete_and_clear_messages(self): def peek_messages(self): # Instantiate a queue client from azure.storage.queue import QueueClient - queue = QueueClient.from_connection_string(self.connection_string, "myqueue6") + queue = QueueClient.from_connection_string(self.connection_string, "myqueue7") # Create the queue queue.create_queue() @@ -246,7 +274,7 @@ def peek_messages(self): def update_message(self): # Instantiate a queue client from azure.storage.queue import QueueClient - queue = QueueClient.from_connection_string(self.connection_string, "myqueue7") + queue = QueueClient.from_connection_string(self.connection_string, "myqueue8") # Create the queue queue.create_queue() @@ -279,6 +307,7 @@ def update_message(self): sample.queue_metadata() sample.send_and_receive_messages() sample.list_message_pages() + sample.receive_one_message_from_queue() sample.delete_and_clear_messages() sample.peek_messages() sample.update_message() diff --git a/sdk/storage/azure-storage-queue/samples/queue_samples_message_async.py b/sdk/storage/azure-storage-queue/samples/queue_samples_message_async.py index 0a73fc1caf8c..ba47b0a0e2bd 100644 --- a/sdk/storage/azure-storage-queue/samples/queue_samples_message_async.py +++ b/sdk/storage/azure-storage-queue/samples/queue_samples_message_async.py @@ -149,6 +149,36 @@ async def send_and_receive_messages_async(self): # Delete the queue await queue.delete_queue() + async def receive_one_message_from_queue(self): + # Instantiate a queue client + from azure.storage.queue.aio import QueueClient + queue = QueueClient.from_connection_string(self.connection_string, "myqueue3") + + # Create the queue + async with queue: + await queue.create_queue() + + try: + await asyncio.gather( + queue.send_message(u"message1"), + queue.send_message(u"message2"), + queue.send_message(u"message3")) + + # [START receive_one_message] + # Pop two messages from the front of the queue + message1 = await queue.receive_one_message() + message2 = await queue.receive_one_message() + # We should see message 3 if we peek + message3 = await queue.peek_messages() + + print(message1.content) + print(message2.content) + print(message3[0].content) + # [END receive_one_message] + + finally: + await queue.delete_queue() + async def delete_and_clear_messages_async(self): # Instantiate a queue client from azure.storage.queue.aio import QueueClient @@ -253,12 +283,13 @@ async def update_message_async(self): async def main(): sample = QueueMessageSamplesAsync() - await sample.set_access_policy_async() - await sample.queue_metadata_async() - await sample.send_and_receive_messages_async() - await sample.delete_and_clear_messages_async() - await sample.peek_messages_async() - await sample.update_message_async() + # await sample.set_access_policy_async() + # await sample.queue_metadata_async() + # await sample.send_and_receive_messages_async() + await sample.receive_one_message_from_queue() + # await sample.delete_and_clear_messages_async() + # await sample.peek_messages_async() + # await sample.update_message_async() if __name__ == '__main__': loop = asyncio.get_event_loop() From 4a9ec7cad81a2c530aede2698f73be278c0f823d Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Wed, 28 Oct 2020 15:02:19 -0700 Subject: [PATCH 3/7] removed comment --- .../samples/queue_samples_message_async.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sdk/storage/azure-storage-queue/samples/queue_samples_message_async.py b/sdk/storage/azure-storage-queue/samples/queue_samples_message_async.py index ba47b0a0e2bd..3dd9f6c50c57 100644 --- a/sdk/storage/azure-storage-queue/samples/queue_samples_message_async.py +++ b/sdk/storage/azure-storage-queue/samples/queue_samples_message_async.py @@ -283,13 +283,13 @@ async def update_message_async(self): async def main(): sample = QueueMessageSamplesAsync() - # await sample.set_access_policy_async() - # await sample.queue_metadata_async() - # await sample.send_and_receive_messages_async() + await sample.set_access_policy_async() + await sample.queue_metadata_async() + await sample.send_and_receive_messages_async() await sample.receive_one_message_from_queue() - # await sample.delete_and_clear_messages_async() - # await sample.peek_messages_async() - # await sample.update_message_async() + await sample.delete_and_clear_messages_async() + await sample.peek_messages_async() + await sample.update_message_async() if __name__ == '__main__': loop = asyncio.get_event_loop() From 9c7deb2165a770f08467c3814d2fc76a58f7fb95 Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Wed, 28 Oct 2020 15:30:56 -0700 Subject: [PATCH 4/7] linter --- .../azure-storage-queue/azure/storage/queue/_queue_client.py | 2 +- .../azure/storage/queue/aio/_queue_client_async.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/_queue_client.py b/sdk/storage/azure-storage-queue/azure/storage/queue/_queue_client.py index c08f5a695fc4..980e5d23d918 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/_queue_client.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/_queue_client.py @@ -531,7 +531,7 @@ def receive_one_message(self, **kwargs): cls=self._config.message_decode_policy, **kwargs ) - wrapped_message = QueueMessage._from_generated(message[0]) + wrapped_message = QueueMessage._from_generated(message[0]) # pylint: disable=protected-access return wrapped_message except StorageErrorException as error: process_storage_error(error) diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_client_async.py b/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_client_async.py index da2e132a1d4f..355bcaceb8aa 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_client_async.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_client_async.py @@ -450,7 +450,7 @@ async def receive_one_message(self, **kwargs): cls=self._config.message_decode_policy, **kwargs ) - wrapped_message = QueueMessage._from_generated(message[0]) + wrapped_message = QueueMessage._from_generated(message[0]) # pylint: disable=protected-access return wrapped_message except StorageErrorException as error: process_storage_error(error) From 5fe05cc02255da98f20ce1fa5299dc74bd380967 Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Wed, 28 Oct 2020 18:21:04 -0700 Subject: [PATCH 5/7] changed method name and added check --- .../azure-storage-queue/azure/storage/queue/_queue_client.py | 5 +++-- .../azure/storage/queue/aio/_queue_client_async.py | 5 +++-- .../azure-storage-queue/samples/queue_samples_message.py | 4 ++-- .../samples/queue_samples_message_async.py | 4 ++-- sdk/storage/azure-storage-queue/tests/test_queue.py | 4 ++-- sdk/storage/azure-storage-queue/tests/test_queue_async.py | 4 ++-- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/_queue_client.py b/sdk/storage/azure-storage-queue/azure/storage/queue/_queue_client.py index 980e5d23d918..4271bf2a6fc8 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/_queue_client.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/_queue_client.py @@ -482,7 +482,7 @@ def send_message( # type: ignore process_storage_error(error) @distributed_trace - def receive_one_message(self, **kwargs): + def receive_message(self, **kwargs): # type: (Optional[Any]) -> QueueMessage """Removes one message from the front of the queue. @@ -531,7 +531,8 @@ def receive_one_message(self, **kwargs): cls=self._config.message_decode_policy, **kwargs ) - wrapped_message = QueueMessage._from_generated(message[0]) # pylint: disable=protected-access + wrapped_message = QueueMessage._from_generated( # pylint: disable=protected-access + message[0]) if message != [] else None return wrapped_message except StorageErrorException as error: process_storage_error(error) diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_client_async.py b/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_client_async.py index 355bcaceb8aa..d2d3e49af02c 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_client_async.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_client_async.py @@ -401,7 +401,7 @@ async def send_message( # type: ignore process_storage_error(error) @distributed_trace_async - async def receive_one_message(self, **kwargs): + async def receive_message(self, **kwargs): # type: (Optional[Any]) -> QueueMessage """Removes one message from the front of the queue. @@ -450,7 +450,8 @@ async def receive_one_message(self, **kwargs): cls=self._config.message_decode_policy, **kwargs ) - wrapped_message = QueueMessage._from_generated(message[0]) # pylint: disable=protected-access + wrapped_message = QueueMessage._from_generated( # pylint: disable=protected-access + message[0]) if message != [] else None return wrapped_message except StorageErrorException as error: process_storage_error(error) diff --git a/sdk/storage/azure-storage-queue/samples/queue_samples_message.py b/sdk/storage/azure-storage-queue/samples/queue_samples_message.py index 881a9f969b93..79e9a3b4eb23 100644 --- a/sdk/storage/azure-storage-queue/samples/queue_samples_message.py +++ b/sdk/storage/azure-storage-queue/samples/queue_samples_message.py @@ -194,8 +194,8 @@ def receive_one_message_from_queue(self): # [START receive_one_message] # Pop two messages from the front of the queue - message1 = queue.receive_one_message() - message2 = queue.receive_one_message() + message1 = queue.receive_message() + message2 = queue.receive_message() # We should see message 3 if we peek message3 = queue.peek_messages()[0] diff --git a/sdk/storage/azure-storage-queue/samples/queue_samples_message_async.py b/sdk/storage/azure-storage-queue/samples/queue_samples_message_async.py index 3dd9f6c50c57..539869ef3d58 100644 --- a/sdk/storage/azure-storage-queue/samples/queue_samples_message_async.py +++ b/sdk/storage/azure-storage-queue/samples/queue_samples_message_async.py @@ -166,8 +166,8 @@ async def receive_one_message_from_queue(self): # [START receive_one_message] # Pop two messages from the front of the queue - message1 = await queue.receive_one_message() - message2 = await queue.receive_one_message() + message1 = await queue.receive_message() + message2 = await queue.receive_message() # We should see message 3 if we peek message3 = await queue.peek_messages() diff --git a/sdk/storage/azure-storage-queue/tests/test_queue.py b/sdk/storage/azure-storage-queue/tests/test_queue.py index 359900204643..78b4ae30ad04 100644 --- a/sdk/storage/azure-storage-queue/tests/test_queue.py +++ b/sdk/storage/azure-storage-queue/tests/test_queue.py @@ -332,8 +332,8 @@ def test_receive_one_message(self, resource_group, location, storage_account, st queue_client.send_message(u'message2') queue_client.send_message(u'message3') - message1 = queue_client.receive_one_message() - message2 = queue_client.receive_one_message() + message1 = queue_client.receive_message() + message2 = queue_client.receive_message() peeked_message3 = queue_client.peek_messages()[0] # Asserts diff --git a/sdk/storage/azure-storage-queue/tests/test_queue_async.py b/sdk/storage/azure-storage-queue/tests/test_queue_async.py index 933ac338ab21..1892985ce6b6 100644 --- a/sdk/storage/azure-storage-queue/tests/test_queue_async.py +++ b/sdk/storage/azure-storage-queue/tests/test_queue_async.py @@ -364,8 +364,8 @@ async def test_receive_one_message(self, resource_group, location, storage_accou await queue_client.send_message(u'message2') await queue_client.send_message(u'message3') - message1 = await queue_client.receive_one_message() - message2 = await queue_client.receive_one_message() + message1 = await queue_client.receive_message() + message2 = await queue_client.receive_message() peeked_message3 = await queue_client.peek_messages() # Asserts From 5838385227d7cd85ba0d384e74f987f08144870c Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Wed, 28 Oct 2020 18:22:59 -0700 Subject: [PATCH 6/7] rerecorded tests --- .../test_queue.test_receive_one_message.yaml | 72 +++++++++---------- ..._queue_async.test_receive_one_message.yaml | 72 +++++++++---------- 2 files changed, 72 insertions(+), 72 deletions(-) diff --git a/sdk/storage/azure-storage-queue/tests/recordings/test_queue.test_receive_one_message.yaml b/sdk/storage/azure-storage-queue/tests/recordings/test_queue.test_receive_one_message.yaml index e5229e50ba03..1a00878343ae 100644 --- a/sdk/storage/azure-storage-queue/tests/recordings/test_queue.test_receive_one_message.yaml +++ b/sdk/storage/azure-storage-queue/tests/recordings/test_queue.test_receive_one_message.yaml @@ -13,7 +13,7 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Wed, 28 Oct 2020 21:22:05 GMT + - Thu, 29 Oct 2020 01:22:22 GMT x-ms-version: - '2018-03-28' method: PUT @@ -25,7 +25,7 @@ interactions: content-length: - '0' date: - - Wed, 28 Oct 2020 21:22:05 GMT + - Thu, 29 Oct 2020 01:22:23 GMT server: - Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 x-ms-version: @@ -51,22 +51,22 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Wed, 28 Oct 2020 21:22:05 GMT + - Thu, 29 Oct 2020 01:22:23 GMT x-ms-version: - '2018-03-28' method: POST uri: https://storagename.queue.core.windows.net/pyqueuesync3a60e5a/messages response: body: - string: "\uFEFFa05e3fee-daca-4f99-b10f-66aa11b0de10Wed, - 28 Oct 2020 21:22:05 GMTWed, 04 Nov 2020 21:22:05 - GMTAgAAAAMAAAAAAAAAjSXPYnCt1gE=Wed, - 28 Oct 2020 21:22:05 GMT" + string: "\uFEFF6e344ff6-1d34-4513-8c97-5b49cdc8111aThu, + 29 Oct 2020 01:22:23 GMTThu, 05 Nov 2020 01:22:23 + GMTAgAAAAMAAAAAAAAAxbM09JGt1gE=Thu, + 29 Oct 2020 01:22:23 GMT" headers: content-type: - application/xml date: - - Wed, 28 Oct 2020 21:22:05 GMT + - Thu, 29 Oct 2020 01:22:23 GMT server: - Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: @@ -94,22 +94,22 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Wed, 28 Oct 2020 21:22:06 GMT + - Thu, 29 Oct 2020 01:22:23 GMT x-ms-version: - '2018-03-28' method: POST uri: https://storagename.queue.core.windows.net/pyqueuesync3a60e5a/messages response: body: - string: "\uFEFF49a60678-55e0-4496-ac7c-f615a7d30e5cWed, - 28 Oct 2020 21:22:06 GMTWed, 04 Nov 2020 21:22:06 - GMTAgAAAAMAAAAAAAAAIg3mYnCt1gE=Wed, - 28 Oct 2020 21:22:06 GMT" + string: "\uFEFFbf8d431c-8732-4a17-a1d2-56b1c7633477Thu, + 29 Oct 2020 01:22:23 GMTThu, 05 Nov 2020 01:22:23 + GMTAgAAAAMAAAAAAAAAMyJN9JGt1gE=Thu, + 29 Oct 2020 01:22:23 GMT" headers: content-type: - application/xml date: - - Wed, 28 Oct 2020 21:22:05 GMT + - Thu, 29 Oct 2020 01:22:23 GMT server: - Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: @@ -137,22 +137,22 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Wed, 28 Oct 2020 21:22:06 GMT + - Thu, 29 Oct 2020 01:22:23 GMT x-ms-version: - '2018-03-28' method: POST uri: https://storagename.queue.core.windows.net/pyqueuesync3a60e5a/messages response: body: - string: "\uFEFFeb0e2fd2-4cc2-4d0b-98bb-bff0d848441dWed, - 28 Oct 2020 21:22:06 GMTWed, 04 Nov 2020 21:22:06 - GMTAgAAAAMAAAAAAAAAXgb+YnCt1gE=Wed, - 28 Oct 2020 21:22:06 GMT" + string: "\uFEFF701932ae-8bdb-476c-a1d7-f17d4a0416c1Thu, + 29 Oct 2020 01:22:23 GMTThu, 05 Nov 2020 01:22:23 + GMTAgAAAAMAAAAAAAAAA9tn9JGt1gE=Thu, + 29 Oct 2020 01:22:23 GMT" headers: content-type: - application/xml date: - - Wed, 28 Oct 2020 21:22:05 GMT + - Thu, 29 Oct 2020 01:22:23 GMT server: - Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: @@ -174,24 +174,24 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Wed, 28 Oct 2020 21:22:06 GMT + - Thu, 29 Oct 2020 01:22:23 GMT x-ms-version: - '2018-03-28' method: GET uri: https://storagename.queue.core.windows.net/pyqueuesync3a60e5a/messages?numofmessages=1 response: body: - string: "\uFEFFa05e3fee-daca-4f99-b10f-66aa11b0de10Wed, - 28 Oct 2020 21:22:05 GMTWed, 04 Nov 2020 21:22:05 - GMTAgAAAAMAAAAAAAAATy33dHCt1gE=Wed, - 28 Oct 2020 21:22:36 GMT1message1" + string: "\uFEFF6e344ff6-1d34-4513-8c97-5b49cdc8111aThu, + 29 Oct 2020 01:22:23 GMTThu, 05 Nov 2020 01:22:23 + GMTAgAAAAMAAAAAAAAAFqxkBpKt1gE=Thu, + 29 Oct 2020 01:22:53 GMT1message1" headers: cache-control: - no-cache content-type: - application/xml date: - - Wed, 28 Oct 2020 21:22:05 GMT + - Thu, 29 Oct 2020 01:22:23 GMT server: - Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: @@ -213,24 +213,24 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Wed, 28 Oct 2020 21:22:06 GMT + - Thu, 29 Oct 2020 01:22:23 GMT x-ms-version: - '2018-03-28' method: GET uri: https://storagename.queue.core.windows.net/pyqueuesync3a60e5a/messages?numofmessages=1 response: body: - string: "\uFEFF49a60678-55e0-4496-ac7c-f615a7d30e5cWed, - 28 Oct 2020 21:22:06 GMTWed, 04 Nov 2020 21:22:06 - GMTAgAAAAMAAAAAAAAAzKUUdXCt1gE=Wed, - 28 Oct 2020 21:22:36 GMT1message2" + string: "\uFEFFbf8d431c-8732-4a17-a1d2-56b1c7633477Thu, + 29 Oct 2020 01:22:23 GMTThu, 05 Nov 2020 01:22:23 + GMTAgAAAAMAAAAAAAAAIFd8BpKt1gE=Thu, + 29 Oct 2020 01:22:53 GMT1message2" headers: cache-control: - no-cache content-type: - application/xml date: - - Wed, 28 Oct 2020 21:22:06 GMT + - Thu, 29 Oct 2020 01:22:23 GMT server: - Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: @@ -252,15 +252,15 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Wed, 28 Oct 2020 21:22:06 GMT + - Thu, 29 Oct 2020 01:22:24 GMT x-ms-version: - '2018-03-28' method: GET uri: https://storagename.queue.core.windows.net/pyqueuesync3a60e5a/messages?peekonly=true response: body: - string: "\uFEFFeb0e2fd2-4cc2-4d0b-98bb-bff0d848441dWed, - 28 Oct 2020 21:22:06 GMTWed, 04 Nov 2020 21:22:06 + string: "\uFEFF701932ae-8bdb-476c-a1d7-f17d4a0416c1Thu, + 29 Oct 2020 01:22:23 GMTThu, 05 Nov 2020 01:22:23 GMT0message3" headers: cache-control: @@ -268,7 +268,7 @@ interactions: content-type: - application/xml date: - - Wed, 28 Oct 2020 21:22:06 GMT + - Thu, 29 Oct 2020 01:22:24 GMT server: - Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: diff --git a/sdk/storage/azure-storage-queue/tests/recordings/test_queue_async.test_receive_one_message.yaml b/sdk/storage/azure-storage-queue/tests/recordings/test_queue_async.test_receive_one_message.yaml index 2e494c6dd2f4..524014bc2f7c 100644 --- a/sdk/storage/azure-storage-queue/tests/recordings/test_queue_async.test_receive_one_message.yaml +++ b/sdk/storage/azure-storage-queue/tests/recordings/test_queue_async.test_receive_one_message.yaml @@ -5,7 +5,7 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Wed, 28 Oct 2020 21:41:16 GMT + - Thu, 29 Oct 2020 01:22:46 GMT x-ms-version: - '2018-03-28' method: PUT @@ -15,7 +15,7 @@ interactions: string: '' headers: content-length: '0' - date: Wed, 28 Oct 2020 21:41:16 GMT + date: Thu, 29 Oct 2020 01:22:45 GMT server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 x-ms-version: '2018-03-28' status: @@ -36,20 +36,20 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Wed, 28 Oct 2020 21:41:16 GMT + - Thu, 29 Oct 2020 01:22:46 GMT x-ms-version: - '2018-03-28' method: POST uri: https://storagename.queue.core.windows.net/pyqueueasync640e10d7/messages response: body: - string: "\uFEFFe6af54c5-6054-4146-9ac1-e7b29fe4b3f1Wed, - 28 Oct 2020 21:41:16 GMTWed, 04 Nov 2020 21:41:16 - GMTAgAAAAMAAAAAAAAAACHNEHOt1gE=Wed, - 28 Oct 2020 21:41:16 GMT" + string: "\uFEFF3d553eb4-d825-4265-a262-7f5690045462Thu, + 29 Oct 2020 01:22:46 GMTThu, 05 Nov 2020 01:22:46 + GMTAgAAAAMAAAAAAAAAsU38AZKt1gE=Thu, + 29 Oct 2020 01:22:46 GMT" headers: content-type: application/xml - date: Wed, 28 Oct 2020 21:41:16 GMT + date: Thu, 29 Oct 2020 01:22:46 GMT server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: chunked x-ms-version: '2018-03-28' @@ -71,20 +71,20 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Wed, 28 Oct 2020 21:41:16 GMT + - Thu, 29 Oct 2020 01:22:46 GMT x-ms-version: - '2018-03-28' method: POST uri: https://storagename.queue.core.windows.net/pyqueueasync640e10d7/messages response: body: - string: "\uFEFFc2f17fee-0526-4832-87ad-3c7a25439a53Wed, - 28 Oct 2020 21:41:16 GMTWed, 04 Nov 2020 21:41:16 - GMTAgAAAAMAAAAAAAAAD1zXEHOt1gE=Wed, - 28 Oct 2020 21:41:16 GMT" + string: "\uFEFF498a8f7f-d9cc-4d0c-902a-1008f636fee0Thu, + 29 Oct 2020 01:22:46 GMTThu, 05 Nov 2020 01:22:46 + GMTAgAAAAMAAAAAAAAA2q8GApKt1gE=Thu, + 29 Oct 2020 01:22:46 GMT" headers: content-type: application/xml - date: Wed, 28 Oct 2020 21:41:16 GMT + date: Thu, 29 Oct 2020 01:22:46 GMT server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: chunked x-ms-version: '2018-03-28' @@ -106,20 +106,20 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Wed, 28 Oct 2020 21:41:16 GMT + - Thu, 29 Oct 2020 01:22:46 GMT x-ms-version: - '2018-03-28' method: POST uri: https://storagename.queue.core.windows.net/pyqueueasync640e10d7/messages response: body: - string: "\uFEFF5dcd17c8-94ac-4d55-922e-308c7974fc3fWed, - 28 Oct 2020 21:41:17 GMTWed, 04 Nov 2020 21:41:17 - GMTAgAAAAMAAAAAAAAApNPgEHOt1gE=Wed, - 28 Oct 2020 21:41:17 GMT" + string: "\uFEFFef2713ef-79ee-4376-ae0b-8f70d08ef7c6Thu, + 29 Oct 2020 01:22:46 GMTThu, 05 Nov 2020 01:22:46 + GMTAgAAAAMAAAAAAAAAdycQApKt1gE=Thu, + 29 Oct 2020 01:22:46 GMT" headers: content-type: application/xml - date: Wed, 28 Oct 2020 21:41:16 GMT + date: Thu, 29 Oct 2020 01:22:46 GMT server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: chunked x-ms-version: '2018-03-28' @@ -135,21 +135,21 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Wed, 28 Oct 2020 21:41:17 GMT + - Thu, 29 Oct 2020 01:22:46 GMT x-ms-version: - '2018-03-28' method: GET uri: https://storagename.queue.core.windows.net/pyqueueasync640e10d7/messages?numofmessages=1 response: body: - string: "\uFEFFe6af54c5-6054-4146-9ac1-e7b29fe4b3f1Wed, - 28 Oct 2020 21:41:16 GMTWed, 04 Nov 2020 21:41:16 - GMTAgAAAAMAAAAAAAAAbDzMInOt1gE=Wed, - 28 Oct 2020 21:41:47 GMT1message1" + string: "\uFEFF3d553eb4-d825-4265-a262-7f5690045462Thu, + 29 Oct 2020 01:22:46 GMTThu, 05 Nov 2020 01:22:46 + GMTAgAAAAMAAAAAAAAA6KH8E5Kt1gE=Thu, + 29 Oct 2020 01:23:16 GMT1message1" headers: cache-control: no-cache content-type: application/xml - date: Wed, 28 Oct 2020 21:41:16 GMT + date: Thu, 29 Oct 2020 01:22:46 GMT server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: chunked x-ms-version: '2018-03-28' @@ -165,21 +165,21 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Wed, 28 Oct 2020 21:41:17 GMT + - Thu, 29 Oct 2020 01:22:46 GMT x-ms-version: - '2018-03-28' method: GET uri: https://storagename.queue.core.windows.net/pyqueueasync640e10d7/messages?numofmessages=1 response: body: - string: "\uFEFFc2f17fee-0526-4832-87ad-3c7a25439a53Wed, - 28 Oct 2020 21:41:16 GMTWed, 04 Nov 2020 21:41:16 - GMTAgAAAAMAAAAAAAAAYVDWInOt1gE=Wed, - 28 Oct 2020 21:41:47 GMT1message2" + string: "\uFEFF498a8f7f-d9cc-4d0c-902a-1008f636fee0Thu, + 29 Oct 2020 01:22:46 GMTThu, 05 Nov 2020 01:22:46 + GMTAgAAAAMAAAAAAAAAr2cGFJKt1gE=Thu, + 29 Oct 2020 01:23:16 GMT1message2" headers: cache-control: no-cache content-type: application/xml - date: Wed, 28 Oct 2020 21:41:17 GMT + date: Thu, 29 Oct 2020 01:22:46 GMT server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: chunked x-ms-version: '2018-03-28' @@ -195,20 +195,20 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Wed, 28 Oct 2020 21:41:17 GMT + - Thu, 29 Oct 2020 01:22:46 GMT x-ms-version: - '2018-03-28' method: GET uri: https://storagename.queue.core.windows.net/pyqueueasync640e10d7/messages?peekonly=true response: body: - string: "\uFEFF5dcd17c8-94ac-4d55-922e-308c7974fc3fWed, - 28 Oct 2020 21:41:17 GMTWed, 04 Nov 2020 21:41:17 + string: "\uFEFFef2713ef-79ee-4376-ae0b-8f70d08ef7c6Thu, + 29 Oct 2020 01:22:46 GMTThu, 05 Nov 2020 01:22:46 GMT0message3" headers: cache-control: no-cache content-type: application/xml - date: Wed, 28 Oct 2020 21:41:17 GMT + date: Thu, 29 Oct 2020 01:22:46 GMT server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: chunked x-ms-version: '2018-03-28' From 89001d5dd29d5df9cc51c24ba6aa580f039eed6e Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Wed, 28 Oct 2020 19:48:40 -0700 Subject: [PATCH 7/7] added empty q test --- .../test_queue.test_receive_one_message.yaml | 109 ++++++++++++------ ..._queue_async.test_receive_one_message.yaml | 100 ++++++++++------ .../azure-storage-queue/tests/test_queue.py | 5 +- .../tests/test_queue_async.py | 5 +- 4 files changed, 143 insertions(+), 76 deletions(-) diff --git a/sdk/storage/azure-storage-queue/tests/recordings/test_queue.test_receive_one_message.yaml b/sdk/storage/azure-storage-queue/tests/recordings/test_queue.test_receive_one_message.yaml index 1a00878343ae..1873e79653f5 100644 --- a/sdk/storage/azure-storage-queue/tests/recordings/test_queue.test_receive_one_message.yaml +++ b/sdk/storage/azure-storage-queue/tests/recordings/test_queue.test_receive_one_message.yaml @@ -13,7 +13,7 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Thu, 29 Oct 2020 01:22:22 GMT + - Thu, 29 Oct 2020 02:48:17 GMT x-ms-version: - '2018-03-28' method: PUT @@ -25,7 +25,7 @@ interactions: content-length: - '0' date: - - Thu, 29 Oct 2020 01:22:23 GMT + - Thu, 29 Oct 2020 02:48:17 GMT server: - Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 x-ms-version: @@ -33,6 +33,43 @@ interactions: status: code: 201 message: Created +- request: + body: null + headers: + Accept: + - application/xml + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Thu, 29 Oct 2020 02:48:18 GMT + x-ms-version: + - '2018-03-28' + method: GET + uri: https://storagename.queue.core.windows.net/pyqueuesync3a60e5a/messages?numofmessages=1 + response: + body: + string: "\uFEFF" + headers: + cache-control: + - no-cache + content-type: + - application/xml + date: + - Thu, 29 Oct 2020 02:48:17 GMT + server: + - Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 + transfer-encoding: + - chunked + x-ms-version: + - '2018-03-28' + status: + code: 200 + message: OK - request: body: ' @@ -51,22 +88,22 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Thu, 29 Oct 2020 01:22:23 GMT + - Thu, 29 Oct 2020 02:48:18 GMT x-ms-version: - '2018-03-28' method: POST uri: https://storagename.queue.core.windows.net/pyqueuesync3a60e5a/messages response: body: - string: "\uFEFF6e344ff6-1d34-4513-8c97-5b49cdc8111aThu, - 29 Oct 2020 01:22:23 GMTThu, 05 Nov 2020 01:22:23 - GMTAgAAAAMAAAAAAAAAxbM09JGt1gE=Thu, - 29 Oct 2020 01:22:23 GMT" + string: "\uFEFF78d04178-05f5-4c46-af2e-d184e4dfb298Thu, + 29 Oct 2020 02:48:18 GMTThu, 05 Nov 2020 02:48:18 + GMTAgAAAAMAAAAAAAAAUo399J2t1gE=Thu, + 29 Oct 2020 02:48:18 GMT" headers: content-type: - application/xml date: - - Thu, 29 Oct 2020 01:22:23 GMT + - Thu, 29 Oct 2020 02:48:17 GMT server: - Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: @@ -94,22 +131,22 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Thu, 29 Oct 2020 01:22:23 GMT + - Thu, 29 Oct 2020 02:48:18 GMT x-ms-version: - '2018-03-28' method: POST uri: https://storagename.queue.core.windows.net/pyqueuesync3a60e5a/messages response: body: - string: "\uFEFFbf8d431c-8732-4a17-a1d2-56b1c7633477Thu, - 29 Oct 2020 01:22:23 GMTThu, 05 Nov 2020 01:22:23 - GMTAgAAAAMAAAAAAAAAMyJN9JGt1gE=Thu, - 29 Oct 2020 01:22:23 GMT" + string: "\uFEFF0902bc9d-169b-4e22-9ba2-b81fac7ada71Thu, + 29 Oct 2020 02:48:18 GMTThu, 05 Nov 2020 02:48:18 + GMTAgAAAAMAAAAAAAAA4FES9Z2t1gE=Thu, + 29 Oct 2020 02:48:18 GMT" headers: content-type: - application/xml date: - - Thu, 29 Oct 2020 01:22:23 GMT + - Thu, 29 Oct 2020 02:48:18 GMT server: - Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: @@ -137,22 +174,22 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Thu, 29 Oct 2020 01:22:23 GMT + - Thu, 29 Oct 2020 02:48:18 GMT x-ms-version: - '2018-03-28' method: POST uri: https://storagename.queue.core.windows.net/pyqueuesync3a60e5a/messages response: body: - string: "\uFEFF701932ae-8bdb-476c-a1d7-f17d4a0416c1Thu, - 29 Oct 2020 01:22:23 GMTThu, 05 Nov 2020 01:22:23 - GMTAgAAAAMAAAAAAAAAA9tn9JGt1gE=Thu, - 29 Oct 2020 01:22:23 GMT" + string: "\uFEFF095ce0f7-470d-4c97-8512-69eb14a36ff3Thu, + 29 Oct 2020 02:48:18 GMTThu, 05 Nov 2020 02:48:18 + GMTAgAAAAMAAAAAAAAAJIQr9Z2t1gE=Thu, + 29 Oct 2020 02:48:18 GMT" headers: content-type: - application/xml date: - - Thu, 29 Oct 2020 01:22:23 GMT + - Thu, 29 Oct 2020 02:48:18 GMT server: - Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: @@ -174,24 +211,24 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Thu, 29 Oct 2020 01:22:23 GMT + - Thu, 29 Oct 2020 02:48:19 GMT x-ms-version: - '2018-03-28' method: GET uri: https://storagename.queue.core.windows.net/pyqueuesync3a60e5a/messages?numofmessages=1 response: body: - string: "\uFEFF6e344ff6-1d34-4513-8c97-5b49cdc8111aThu, - 29 Oct 2020 01:22:23 GMTThu, 05 Nov 2020 01:22:23 - GMTAgAAAAMAAAAAAAAAFqxkBpKt1gE=Thu, - 29 Oct 2020 01:22:53 GMT1message1" + string: "\uFEFF78d04178-05f5-4c46-af2e-d184e4dfb298Thu, + 29 Oct 2020 02:48:18 GMTThu, 05 Nov 2020 02:48:18 + GMTAgAAAAMAAAAAAAAArXIjB56t1gE=Thu, + 29 Oct 2020 02:48:49 GMT1message1" headers: cache-control: - no-cache content-type: - application/xml date: - - Thu, 29 Oct 2020 01:22:23 GMT + - Thu, 29 Oct 2020 02:48:18 GMT server: - Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: @@ -213,24 +250,24 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Thu, 29 Oct 2020 01:22:23 GMT + - Thu, 29 Oct 2020 02:48:19 GMT x-ms-version: - '2018-03-28' method: GET uri: https://storagename.queue.core.windows.net/pyqueuesync3a60e5a/messages?numofmessages=1 response: body: - string: "\uFEFFbf8d431c-8732-4a17-a1d2-56b1c7633477Thu, - 29 Oct 2020 01:22:23 GMTThu, 05 Nov 2020 01:22:23 - GMTAgAAAAMAAAAAAAAAIFd8BpKt1gE=Thu, - 29 Oct 2020 01:22:53 GMT1message2" + string: "\uFEFF0902bc9d-169b-4e22-9ba2-b81fac7ada71Thu, + 29 Oct 2020 02:48:18 GMTThu, 05 Nov 2020 02:48:18 + GMTAgAAAAMAAAAAAAAAPzc4B56t1gE=Thu, + 29 Oct 2020 02:48:49 GMT1message2" headers: cache-control: - no-cache content-type: - application/xml date: - - Thu, 29 Oct 2020 01:22:23 GMT + - Thu, 29 Oct 2020 02:48:18 GMT server: - Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: @@ -252,15 +289,15 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Thu, 29 Oct 2020 01:22:24 GMT + - Thu, 29 Oct 2020 02:48:19 GMT x-ms-version: - '2018-03-28' method: GET uri: https://storagename.queue.core.windows.net/pyqueuesync3a60e5a/messages?peekonly=true response: body: - string: "\uFEFF701932ae-8bdb-476c-a1d7-f17d4a0416c1Thu, - 29 Oct 2020 01:22:23 GMTThu, 05 Nov 2020 01:22:23 + string: "\uFEFF095ce0f7-470d-4c97-8512-69eb14a36ff3Thu, + 29 Oct 2020 02:48:18 GMTThu, 05 Nov 2020 02:48:18 GMT0message3" headers: cache-control: @@ -268,7 +305,7 @@ interactions: content-type: - application/xml date: - - Thu, 29 Oct 2020 01:22:24 GMT + - Thu, 29 Oct 2020 02:48:18 GMT server: - Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: diff --git a/sdk/storage/azure-storage-queue/tests/recordings/test_queue_async.test_receive_one_message.yaml b/sdk/storage/azure-storage-queue/tests/recordings/test_queue_async.test_receive_one_message.yaml index 524014bc2f7c..bc9191e8d665 100644 --- a/sdk/storage/azure-storage-queue/tests/recordings/test_queue_async.test_receive_one_message.yaml +++ b/sdk/storage/azure-storage-queue/tests/recordings/test_queue_async.test_receive_one_message.yaml @@ -5,7 +5,7 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Thu, 29 Oct 2020 01:22:46 GMT + - Thu, 29 Oct 2020 02:48:29 GMT x-ms-version: - '2018-03-28' method: PUT @@ -15,13 +15,41 @@ interactions: string: '' headers: content-length: '0' - date: Thu, 29 Oct 2020 01:22:45 GMT + date: Thu, 29 Oct 2020 02:48:29 GMT server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 x-ms-version: '2018-03-28' status: code: 201 message: Created url: https://seanmcccanary3.queue.core.windows.net/pyqueueasync640e10d7 +- request: + body: null + headers: + Accept: + - application/xml + User-Agent: + - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Thu, 29 Oct 2020 02:48:30 GMT + x-ms-version: + - '2018-03-28' + method: GET + uri: https://storagename.queue.core.windows.net/pyqueueasync640e10d7/messages?numofmessages=1 + response: + body: + string: "\uFEFF" + headers: + cache-control: no-cache + content-type: application/xml + date: Thu, 29 Oct 2020 02:48:29 GMT + server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 + transfer-encoding: chunked + x-ms-version: '2018-03-28' + status: + code: 200 + message: OK + url: https://seanmcccanary3.queue.core.windows.net/pyqueueasync640e10d7/messages?numofmessages=1 - request: body: ' @@ -36,20 +64,20 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Thu, 29 Oct 2020 01:22:46 GMT + - Thu, 29 Oct 2020 02:48:30 GMT x-ms-version: - '2018-03-28' method: POST uri: https://storagename.queue.core.windows.net/pyqueueasync640e10d7/messages response: body: - string: "\uFEFF3d553eb4-d825-4265-a262-7f5690045462Thu, - 29 Oct 2020 01:22:46 GMTThu, 05 Nov 2020 01:22:46 - GMTAgAAAAMAAAAAAAAAsU38AZKt1gE=Thu, - 29 Oct 2020 01:22:46 GMT" + string: "\uFEFFc25fa1f7-cb36-4d2a-bf09-6f75389bbc98Thu, + 29 Oct 2020 02:48:30 GMTThu, 05 Nov 2020 02:48:30 + GMTAgAAAAMAAAAAAAAAv+re+52t1gE=Thu, + 29 Oct 2020 02:48:30 GMT" headers: content-type: application/xml - date: Thu, 29 Oct 2020 01:22:46 GMT + date: Thu, 29 Oct 2020 02:48:29 GMT server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: chunked x-ms-version: '2018-03-28' @@ -71,20 +99,20 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Thu, 29 Oct 2020 01:22:46 GMT + - Thu, 29 Oct 2020 02:48:30 GMT x-ms-version: - '2018-03-28' method: POST uri: https://storagename.queue.core.windows.net/pyqueueasync640e10d7/messages response: body: - string: "\uFEFF498a8f7f-d9cc-4d0c-902a-1008f636fee0Thu, - 29 Oct 2020 01:22:46 GMTThu, 05 Nov 2020 01:22:46 - GMTAgAAAAMAAAAAAAAA2q8GApKt1gE=Thu, - 29 Oct 2020 01:22:46 GMT" + string: "\uFEFF9159ff30-0b69-4916-8efb-7624a7b1acdbThu, + 29 Oct 2020 02:48:30 GMTThu, 05 Nov 2020 02:48:30 + GMTAgAAAAMAAAAAAAAAi7Do+52t1gE=Thu, + 29 Oct 2020 02:48:30 GMT" headers: content-type: application/xml - date: Thu, 29 Oct 2020 01:22:46 GMT + date: Thu, 29 Oct 2020 02:48:29 GMT server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: chunked x-ms-version: '2018-03-28' @@ -106,20 +134,20 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Thu, 29 Oct 2020 01:22:46 GMT + - Thu, 29 Oct 2020 02:48:30 GMT x-ms-version: - '2018-03-28' method: POST uri: https://storagename.queue.core.windows.net/pyqueueasync640e10d7/messages response: body: - string: "\uFEFFef2713ef-79ee-4376-ae0b-8f70d08ef7c6Thu, - 29 Oct 2020 01:22:46 GMTThu, 05 Nov 2020 01:22:46 - GMTAgAAAAMAAAAAAAAAdycQApKt1gE=Thu, - 29 Oct 2020 01:22:46 GMT" + string: "\uFEFFd39f0f34-a85b-4488-924c-d5cf002f4b68Thu, + 29 Oct 2020 02:48:30 GMTThu, 05 Nov 2020 02:48:30 + GMTAgAAAAMAAAAAAAAAFyjy+52t1gE=Thu, + 29 Oct 2020 02:48:30 GMT" headers: content-type: application/xml - date: Thu, 29 Oct 2020 01:22:46 GMT + date: Thu, 29 Oct 2020 02:48:29 GMT server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: chunked x-ms-version: '2018-03-28' @@ -135,21 +163,21 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Thu, 29 Oct 2020 01:22:46 GMT + - Thu, 29 Oct 2020 02:48:30 GMT x-ms-version: - '2018-03-28' method: GET uri: https://storagename.queue.core.windows.net/pyqueueasync640e10d7/messages?numofmessages=1 response: body: - string: "\uFEFF3d553eb4-d825-4265-a262-7f5690045462Thu, - 29 Oct 2020 01:22:46 GMTThu, 05 Nov 2020 01:22:46 - GMTAgAAAAMAAAAAAAAA6KH8E5Kt1gE=Thu, - 29 Oct 2020 01:23:16 GMT1message1" + string: "\uFEFFc25fa1f7-cb36-4d2a-bf09-6f75389bbc98Thu, + 29 Oct 2020 02:48:30 GMTThu, 05 Nov 2020 02:48:30 + GMTAgAAAAMAAAAAAAAAyWndDZ6t1gE=Thu, + 29 Oct 2020 02:49:00 GMT1message1" headers: cache-control: no-cache content-type: application/xml - date: Thu, 29 Oct 2020 01:22:46 GMT + date: Thu, 29 Oct 2020 02:48:29 GMT server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: chunked x-ms-version: '2018-03-28' @@ -165,21 +193,21 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Thu, 29 Oct 2020 01:22:46 GMT + - Thu, 29 Oct 2020 02:48:30 GMT x-ms-version: - '2018-03-28' method: GET uri: https://storagename.queue.core.windows.net/pyqueueasync640e10d7/messages?numofmessages=1 response: body: - string: "\uFEFF498a8f7f-d9cc-4d0c-902a-1008f636fee0Thu, - 29 Oct 2020 01:22:46 GMTThu, 05 Nov 2020 01:22:46 - GMTAgAAAAMAAAAAAAAAr2cGFJKt1gE=Thu, - 29 Oct 2020 01:23:16 GMT1message2" + string: "\uFEFF9159ff30-0b69-4916-8efb-7624a7b1acdbThu, + 29 Oct 2020 02:48:30 GMTThu, 05 Nov 2020 02:48:30 + GMTAgAAAAMAAAAAAAAAs1bnDZ6t1gE=Thu, + 29 Oct 2020 02:49:00 GMT1message2" headers: cache-control: no-cache content-type: application/xml - date: Thu, 29 Oct 2020 01:22:46 GMT + date: Thu, 29 Oct 2020 02:48:29 GMT server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: chunked x-ms-version: '2018-03-28' @@ -195,20 +223,20 @@ interactions: User-Agent: - azsdk-python-storage-queue/12.1.4 Python/3.8.5 (Windows-10-10.0.19041-SP0) x-ms-date: - - Thu, 29 Oct 2020 01:22:46 GMT + - Thu, 29 Oct 2020 02:48:30 GMT x-ms-version: - '2018-03-28' method: GET uri: https://storagename.queue.core.windows.net/pyqueueasync640e10d7/messages?peekonly=true response: body: - string: "\uFEFFef2713ef-79ee-4376-ae0b-8f70d08ef7c6Thu, - 29 Oct 2020 01:22:46 GMTThu, 05 Nov 2020 01:22:46 + string: "\uFEFFd39f0f34-a85b-4488-924c-d5cf002f4b68Thu, + 29 Oct 2020 02:48:30 GMTThu, 05 Nov 2020 02:48:30 GMT0message3" headers: cache-control: no-cache content-type: application/xml - date: Thu, 29 Oct 2020 01:22:46 GMT + date: Thu, 29 Oct 2020 02:48:29 GMT server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: chunked x-ms-version: '2018-03-28' diff --git a/sdk/storage/azure-storage-queue/tests/test_queue.py b/sdk/storage/azure-storage-queue/tests/test_queue.py index 78b4ae30ad04..d6f21a3f03f8 100644 --- a/sdk/storage/azure-storage-queue/tests/test_queue.py +++ b/sdk/storage/azure-storage-queue/tests/test_queue.py @@ -50,7 +50,7 @@ def _get_queue_reference(self, qsc, prefix=TEST_QUEUE_PREFIX): queue = qsc.get_queue_client(queue_name) return queue - def _create_queue(self, qsc, prefix=TEST_QUEUE_PREFIX, queue_list = None): + def _create_queue(self, qsc, prefix=TEST_QUEUE_PREFIX, queue_list=None): queue = self._get_queue_reference(qsc, prefix) created = queue.create_queue() if queue_list is not None: @@ -328,6 +328,8 @@ def test_receive_one_message(self, resource_group, location, storage_account, st qsc = QueueServiceClient(self.account_url(storage_account, "queue"), storage_account_key) queue_client = self._get_queue_reference(qsc) queue_client.create_queue() + self.assertIsNone(queue_client.receive_message()) + queue_client.send_message(u'message1') queue_client.send_message(u'message2') queue_client.send_message(u'message3') @@ -352,7 +354,6 @@ def test_receive_one_message(self, resource_group, location, storage_account, st self.assertEqual(u'message3', peeked_message3.content) self.assertEqual(0, peeked_message3.dequeue_count) - @GlobalStorageAccountPreparer() def test_get_messages_with_options(self, resource_group, location, storage_account, storage_account_key): # Action diff --git a/sdk/storage/azure-storage-queue/tests/test_queue_async.py b/sdk/storage/azure-storage-queue/tests/test_queue_async.py index 1892985ce6b6..eea4e4c9f114 100644 --- a/sdk/storage/azure-storage-queue/tests/test_queue_async.py +++ b/sdk/storage/azure-storage-queue/tests/test_queue_async.py @@ -62,7 +62,7 @@ def _get_queue_reference(self, qsc, prefix=TEST_QUEUE_PREFIX): queue = qsc.get_queue_client(queue_name) return queue - async def _create_queue(self, qsc, prefix=TEST_QUEUE_PREFIX, queue_list = None): + async def _create_queue(self, qsc, prefix=TEST_QUEUE_PREFIX, queue_list=None): queue = self._get_queue_reference(qsc, prefix) created = await queue.create_queue() if queue_list: @@ -353,13 +353,14 @@ async def test_get_messages(self, resource_group, location, storage_account, sto self.assertIsInstance(message.expires_on, datetime) self.assertIsInstance(message.next_visible_on, datetime) - @GlobalStorageAccountPreparer() @AsyncStorageTestCase.await_prepared_test async def test_receive_one_message(self, resource_group, location, storage_account, storage_account_key): # Action qsc = QueueServiceClient(self.account_url(storage_account, "queue"), storage_account_key, transport=AiohttpTestTransport()) queue_client = await self._create_queue(qsc) + self.assertIsNone(await queue_client.receive_message()) + await queue_client.send_message(u'message1') await queue_client.send_message(u'message2') await queue_client.send_message(u'message3')