File: test_optional_functionality.py

package info (click to toggle)
python-azure 20250603%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 851,724 kB
  • sloc: python: 7,362,925; ansic: 804; javascript: 287; makefile: 195; sh: 145; xml: 109
file content (67 lines) | stat: -rw-r--r-- 1,989 bytes parent folder | download | duplicates (2)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import os
import pytest

from ci_tools.parsing import ParsedSetup
from ci_tools.functions import get_config_setting

integration_folder = os.path.join(os.path.dirname(__file__), "integration")


def test_toml_result():
    package_with_toml = os.path.join(integration_folder, "scenarios", "optional_environment_two_options")
    parsed_setup = ParsedSetup.from_path(package_with_toml)
    actual = parsed_setup.get_build_config()

    expected = {
        "mypy": True,
        "type_check_samples": True,
        "verifytypes": True,
        "pyright": True,
        "pylint": True,
        "black": True,
        "optional": [
            {
                "name": "no_requests",
                "install": [],
                "uninstall": ["requests"],
                "additional_pytest_args": ["-k", "*_async.py"],
            },
            {
                "name": "no_aiohttp",
                "install": [],
                "uninstall": ["aiohttp"],
                "additional_pytest_args": ["-k", "not *_async.py"],
            },
        ],
    }

    assert actual == expected


def test_optional_specific_get():
    package_with_toml = os.path.join(integration_folder, "scenarios", "optional_environment_two_options")
    actual = get_config_setting(package_with_toml, "optional")
    expected = [
        {
            "name": "no_requests",
            "install": [],
            "uninstall": ["requests"],
            "additional_pytest_args": ["-k", "*_async.py"],
        },
        {
            "name": "no_aiohttp",
            "install": [],
            "uninstall": ["aiohttp"],
            "additional_pytest_args": ["-k", "not *_async.py"],
        },
    ]

    assert expected == actual


def test_optional_specific_get_no_result():
    package_with_toml = os.path.join(integration_folder, "scenarios", "optional_environment_zero_options")
    actual = get_config_setting(package_with_toml, "optional", None)
    expected = None

    assert expected == actual