-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathconftest.py
106 lines (84 loc) · 2.87 KB
/
conftest.py
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# pylint: disable=missing-docstring,no-self-use
import copy
import io
import logging
import os
from collections import OrderedDict
from typing import Any, Dict
import pytest
from tests import conf
GENERIC_CONF = {
"xunit_target": "https://polarion.example.com/import/xunit",
"testcase_taget": "https://polarion.example.com/import/testcase",
"requirement_target": "https://polarion.example.com/import/requirement",
"xunit_queue": "https://polarion.example.com/import/xunit-queue",
"testcase_queue": "https://polarion.example.com/import/testcase-queue",
"requirement_queue": "https://polarion.example.com/import/requirement-queue",
"repo_address": "https://foo/bar/baz",
"cfme_run_id": "id123",
} # type: Dict[str, Any]
VALID_CASELEVELS = {
"valid_values": {"caselevel": ["component", "integration", "system", "acceptance"]}
}
RHCF3_XUNIT_PROPS = OrderedDict(
(
("polarion-dry-run", False),
("polarion-testrun-status-id", "inprogress"),
("polarion-response-test", "test"),
)
)
POLARION_DEFAULT_FIELDS = OrderedDict(
(
("assignee", ""),
("casecomponent", ""),
("initialEstimate", "1m"),
("caseimportance", "high"),
("caselevel", "component"),
("caseposneg", "positive"),
("caseautomation", "automated"),
("testtype", "functional"),
("subtype1", "-"),
("subtype2", "-"),
("tags", ""),
("setup", ""),
("teardown", ""),
("description", ""),
("linkedWorkItems", ""),
("testSteps", ""),
("expectedResults", ""),
("title", ""),
("work_item_id", ""),
)
)
REQUIREMENTS_DEFAULT_FIELDS = OrderedDict((("reqtype", "system"),))
RHCF3_TESTCASE_PROPS = OrderedDict((("lookup-method", "name"),))
RHCF3_CONF = GENERIC_CONF.copy()
RHCF3_CONF["polarion-project-id"] = "RHCF3"
RHCF3_CONF["xunit_import_properties"] = RHCF3_XUNIT_PROPS
RHCF3_CONF["testcase_import_properties"] = RHCF3_TESTCASE_PROPS
RHCF3_CONF["default_fields"] = POLARION_DEFAULT_FIELDS
RHCF3_CONF["requirements_default_fields"] = REQUIREMENTS_DEFAULT_FIELDS
RHCF3_CONF["docstrings"] = VALID_CASELEVELS
@pytest.fixture(scope="session")
def config_prop():
return copy.deepcopy(RHCF3_CONF)
@pytest.fixture(scope="function")
def config_e2e():
conf_file = os.path.join(conf.DATA_PATH, "polarion_tools.yaml")
return str(conf_file)
class SimpleFormatter:
def format(self, record):
message = record.getMessage()
if isinstance(message, bytes):
message = message.decode("utf-8")
return message
@pytest.yield_fixture
def captured_log():
buff = io.StringIO()
handler = logging.StreamHandler(buff)
handler.setFormatter(SimpleFormatter())
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
logger.addHandler(handler)
yield buff
logger.handlers.remove(handler)