File: conftest.py

package info (click to toggle)
python-azure 20250829%2Bgit-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 756,824 kB
  • sloc: python: 6,224,989; ansic: 804; javascript: 287; makefile: 198; sh: 195; xml: 109
file content (37 lines) | stat: -rw-r--r-- 1,330 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See LICENSE.txt in the project root for
# license information.
# -------------------------------------------------------------------------
import pytest

from devtools_testutils.sanitizers import add_header_regex_sanitizer


# Environment variable keys
ENV_METRICS_RESOURCE_ID = "METRICS_RESOURCE_ID"
ENV_SUBSCRIPTION_ID = "MONITOR_SUBSCRIPTION_ID"
ENV_TENANT_ID = "AZURE_MONITOR_TENANT_ID"

# Fake values
TEST_ID = "00000000-0000-0000-0000-000000000000"
TEST_RESOURCE_ID = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fake-resource"
TEST_TABLE_NAME = "test-table"


@pytest.fixture(scope="session", autouse=True)
def add_sanitizers(test_proxy, environment_variables):
    sanitization_mapping = {
        ENV_METRICS_RESOURCE_ID: TEST_RESOURCE_ID,
        ENV_SUBSCRIPTION_ID: TEST_ID,
        ENV_TENANT_ID: TEST_ID,
    }
    environment_variables.sanitize_batch(sanitization_mapping)
    add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]")


@pytest.fixture(scope="session")
def monitor_info(environment_variables):
    yield {
        "metrics_resource_id": environment_variables.get(ENV_METRICS_RESOURCE_ID),
    }