diff options
author | David Bossanyi <davebossanyi@gmail.com> | 2022-10-16 15:43:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-16 20:43:15 +0600 |
commit | 22b559684f62417d47a0370e5f8f65b9278a9903 (patch) | |
tree | 8a41bf32a34a25c6938d2512c4dc4d41cc30907c /t | |
parent | c7615fc537430f897febfffd0dbe20b15e6c2b2a (diff) | |
download | kombu-22b559684f62417d47a0370e5f8f65b9278a9903.tar.gz |
Allow azurestoragequeues transport to be used with Azurite emulator in docker-compose (#1611)
* Parse credential as a dict when using Azurite emulator
This more flexible credential allows the use of Azurite for integration testing in local docker-compose configurations.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix some lint errors
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Diffstat (limited to 't')
-rw-r--r-- | t/unit/transport/test_azurestoragequeues.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/t/unit/transport/test_azurestoragequeues.py b/t/unit/transport/test_azurestoragequeues.py index d5568cbb..44fa859b 100644 --- a/t/unit/transport/test_azurestoragequeues.py +++ b/t/unit/transport/test_azurestoragequeues.py @@ -11,6 +11,8 @@ from kombu.transport import azurestoragequeues # noqa URL_NOCREDS = 'azurestoragequeues://' URL_CREDS = 'azurestoragequeues://sas/key%@https://STORAGE_ACCOUNT_NAME.queue.core.windows.net/' # noqa +AZURITE_CREDS = 'azurestoragequeues://Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==@http://localhost:10001/devstoreaccount1' # noqa +AZURITE_CREDS_DOCKER_COMPOSE = 'azurestoragequeues://Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==@http://azurite:10001/devstoreaccount1' # noqa def test_queue_service_nocredentials(): @@ -31,3 +33,22 @@ def test_queue_service(): # Check the SAS token "sas/key%" has been parsed from the url correctly assert channel._credential == 'sas/key%' assert channel._url == 'https://STORAGE_ACCOUNT_NAME.queue.core.windows.net/' # noqa + + +@pytest.mark.parametrize( + "creds, hostname", + [ + (AZURITE_CREDS, 'localhost'), + (AZURITE_CREDS_DOCKER_COMPOSE, 'azurite'), + ] +) +def test_queue_service_works_for_azurite(creds, hostname): + conn = Connection(creds, transport=azurestoragequeues.Transport) + with patch('kombu.transport.azurestoragequeues.QueueServiceClient'): + channel = conn.channel() + + assert channel._credential == { + 'account_name': 'devstoreaccount1', + 'account_key': 'Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==' # noqa + } + assert channel._url == f'http://{hostname}:10001/devstoreaccount1' # noqa |