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
68
69
70
71
72
73
74
75
76
77
78
|
#!/usr/bin/python
# coding: utf-8 -*-
# pylint: disable=logger-format-interpolation
# pylint: disable=dangerous-default-value
# flake8: noqa: W503
# flake8: noqa: W1202
from __future__ import absolute_import, division, print_function
import os
from typing import Any, Dict, List
import pytest
import eos_downloader
from tests.lib.dataset import (
eos_dataset_invalid,
eos_dataset_valid,
eos_token,
eos_token_invalid,
)
@pytest.fixture
@pytest.mark.parametrize("DOWNLOAD_INFO", eos_dataset_valid)
def create_download_instance(request, DOWNLOAD_INFO):
# logger.info("Execute fixture to create class elements")
request.cls.eos_downloader = eos_downloader.eos.EOSDownloader(
image=DOWNLOAD_INFO["image"],
software=DOWNLOAD_INFO["software"],
version=DOWNLOAD_INFO["version"],
token=eos_token,
hash_method="sha512sum",
)
yield
# logger.info('Cleanup test environment')
os.system("rm -f {}*".format(DOWNLOAD_INFO["filename"]))
def generate_test_ids_dict(val: Dict[str, Any], key: str = "name") -> str:
"""
generate_test_ids Helper to generate test ID for parametrize
Only related to SYSTEM_CONFIGLETS_TESTS structure
Parameters
----------
val : dict
A configlet test structure
Returns
-------
str
Name of the configlet
"""
if key in val.keys():
# note this wouldn't show any hours/minutes/seconds
return val[key]
return "undefined_test"
def generate_test_ids_list(val: List[Dict[str, Any]], key: str = "name") -> str:
"""
generate_test_ids Helper to generate test ID for parametrize
Only related to SYSTEM_CONFIGLETS_TESTS structure
Parameters
----------
val : dict
A configlet test structure
Returns
-------
str
Name of the configlet
"""
return [entry[key] if key in entry.keys() else "unset_entry" for entry in val]
|