|
| 1 | +#------------------------------------------------------------------------- |
| 2 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 | +# Licensed under the MIT License. See License.txt in the project root for |
| 4 | +# license information. |
| 5 | +#-------------------------------------------------------------------------- |
| 6 | +import pytest |
| 7 | +import os |
| 8 | +import sys |
| 9 | +from azure.servicebus import ServiceBusClient |
| 10 | +from dotenv import load_dotenv |
| 11 | + |
| 12 | +LOGGING_ENABLE = False |
| 13 | +ENV_FILE = os.environ.get('ENV_FILE') |
| 14 | +load_dotenv(dotenv_path=ENV_FILE, override=True) |
| 15 | + |
| 16 | +# Allow us to pass stress_test_duration from the command line. TODO: may not actually be using this. |
| 17 | +def pytest_addoption(parser): |
| 18 | + parser.addoption('--stress_test_duration_seconds', action="store", default=None) |
| 19 | + |
| 20 | +# Note: This is duplicated between here and the basic conftest, so that it does not throw warnings if you're |
| 21 | +# running locally to this SDK. (Everything works properly, pytest just makes a bit of noise.) |
| 22 | +def pytest_configure(config): |
| 23 | + # register an additional marker |
| 24 | + config.addinivalue_line( |
| 25 | + "markers", "liveTest: mark test to be a live test only" |
| 26 | + ) |
| 27 | + config.addinivalue_line( |
| 28 | + "markers", "live_test_only: mark test to be a live test only" |
| 29 | + ) |
| 30 | + config.addinivalue_line( |
| 31 | + "markers", "playback_test_only: mark test to be a playback test only" |
| 32 | + ) |
| 33 | + |
| 34 | +# fixture needs to be visible from conftest |
| 35 | + |
| 36 | +@pytest.fixture(scope="session", autouse=True) |
| 37 | +def sb_client(): |
| 38 | + service_bus_connection_str = os.environ['SERVICE_BUS_CONNECTION_STR'] |
| 39 | + client = ServiceBusClient.from_connection_string( |
| 40 | + service_bus_connection_str, logging_enable=LOGGING_ENABLE) |
| 41 | + return client |
| 42 | + |
| 43 | +@pytest.fixture() |
| 44 | +def servicebus_queue_name(sb_client): |
| 45 | + sb_queue_name = os.environ['SERVICE_BUS_QUEUE_NAME'] |
| 46 | + return sb_queue_name |
0 commit comments