-
Notifications
You must be signed in to change notification settings - Fork 544
Expand file tree
/
Copy pathconftest.py
More file actions
58 lines (49 loc) · 1.62 KB
/
conftest.py
File metadata and controls
58 lines (49 loc) · 1.62 KB
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
import json
import os
import pytest
import requests
from packaging.version import Version
API_URL = (
"https://packages.broadcom.com/artifactory/api/storage/saltproject-generic/windows"
)
@pytest.fixture(scope="session")
def target_python_version():
return 3
@pytest.fixture(scope="session")
def target_salt_version():
target_salt = os.environ.get("SaltVersion", "")
html_response = requests.get(API_URL)
content = json.loads(html_response.text)
folders = content["children"]
versions = {}
for folder in folders:
if folder["folder"]:
version = folder["uri"].strip("/")
versions[version] = version
# We're trying to get the latest major version and latest overall
maj_ver, _ = version.split(".")
if maj_ver in versions:
if Version(version) > Version(versions[maj_ver]):
versions[maj_ver] = version
else:
versions[maj_ver] = version
if "latest" in versions:
if Version(version) > Version(versions["latest"]):
versions["latest"] = version
else:
versions["latest"] = version
if target_salt.startswith("v"):
target_salt = target_salt[1:]
if target_salt not in versions:
pytest.skip(f"Invalid testing version: {target_salt}")
if target_salt in (
"default",
"latest",
"master",
"nightly",
"stable",
"onedir",
"git",
):
pytest.skip("Don't have a specific salt version to test against")
return versions[target_salt]