File: conftest.py

package info (click to toggle)
python-azure 20251118%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 783,356 kB
  • sloc: python: 6,474,533; ansic: 804; javascript: 287; sh: 205; makefile: 198; xml: 109
file content (35 lines) | stat: -rw-r--r-- 1,117 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
import pytest
from devtools_testutils.sanitizers import (
    add_header_regex_sanitizer,
    add_oauth_response_sanitizer,
)

ENV_ENDPOINT = "AZURE_QUESTIONANSWERING_ENDPOINT"
ENV_KEY = "AZURE_QUESTIONANSWERING_KEY"
ENV_PROJECT = "AZURE_QUESTIONANSWERING_PROJECT"

TEST_ENDPOINT = "https://test-resource.cognitiveservices.azure.com/"
TEST_KEY = "0000000000000000"
TEST_PROJECT = "test-project"


@pytest.fixture(scope="session", autouse=True)
def add_sanitizers(test_proxy, environment_variables):  # type: ignore[name-defined]
    environment_variables.sanitize_batch(
        {
            ENV_ENDPOINT: TEST_ENDPOINT,
            ENV_KEY: TEST_KEY,
            ENV_PROJECT: TEST_PROJECT,
        }
    )
    add_oauth_response_sanitizer()
    add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]")


@pytest.fixture(scope="session")
def qna_authoring_creds(environment_variables):  # type: ignore[name-defined]
    yield {
        "endpoint": environment_variables.get(ENV_ENDPOINT),
        "key": environment_variables.get(ENV_KEY),
        "project": environment_variables.get(ENV_PROJECT),
    }