-
Notifications
You must be signed in to change notification settings - Fork 115
Expand file tree
/
Copy pathro_cli_test.py
More file actions
134 lines (98 loc) · 4.86 KB
/
Copy pathro_cli_test.py
File metadata and controls
134 lines (98 loc) · 4.86 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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# Ignoring pytest-related warnings:
# pylint: disable=unused-argument
import re
from urllib.parse import urljoin, urlparse, urlunparse
from ..utils import open_bz
from . import TEST_URL, TEST_PRODUCTS, TEST_SUSE_COMPONENTS, TEST_OWNER
def test_fails(mocked_responses, run_cli, backends):
bz = open_bz(url=TEST_URL, **backends)
out = run_cli("bugzilla query --field=IDONTEXIST=FOO", bzinstance=bz, expectfail=True)
assert "Server error:" in out
out = run_cli("bugzilla --bugzilla https://example.com/xmlrpc.cgi query --field=IDONTEXIST=FOO",
bzinstance=None, expectfail=True)
assert "Connection lost/failed" in out
parsed = urlparse(TEST_URL)
netloc = parsed.netloc
if not re.search(r":\d+$", netloc):
netloc += ":80"
https_test_url = urlunparse(("https", netloc, parsed.path, parsed.params, parsed.query,
parsed.fragment))
out = run_cli(f"bugzilla --bugzilla {https_test_url} query --bug_id 1234",
bzinstance=None, expectfail=True)
assert "trust the remote server" in out
assert "--nosslverify" in out
def test_get_products(mocked_responses, run_cli, backends):
bz = open_bz(url=TEST_URL, **backends)
out = run_cli("bugzilla info --products", bzinstance=bz)
assert len(out.strip().split("\n")) == 3
for product in TEST_PRODUCTS:
assert product in out
def test_get_components(mocked_responses, run_cli, backends):
bz = open_bz(url=TEST_URL, **backends)
out = run_cli("bugzilla info --components 'SUSE Linux Enterprise Server 15 SP6'", bzinstance=bz)
assert len(out.strip().split("\n")) == 2
for comp in TEST_SUSE_COMPONENTS:
assert comp in out
def test_get_active_components(mocked_responses, run_cli, backends):
bz = open_bz(url=TEST_URL, **backends)
out = run_cli("bugzilla info --components 'SUSE Linux Enterprise Server 15 SP6' "
"--active-components", bzinstance=bz)
assert "Containers" in out
assert "Kernel" in out
def test_get_component_owners(mocked_responses, run_cli, backends):
bz = open_bz(url=TEST_URL, **backends)
out = run_cli("bugzilla info --component_owners 'SUSE Linux Enterprise Server 15 SP6'",
bzinstance=bz)
assert TEST_OWNER in out
def test_get_versions(mocked_responses, run_cli, backends):
bz = open_bz(url=TEST_URL, **backends)
out = run_cli("bugzilla info --versions 'Red Hat Enterprise Linux 9'", bzinstance=bz)
versions = set(out.strip().split("\n"))
assert versions == {"unspecified", "9.0", "9.1"}
def test_query(mocked_responses, run_cli, backends):
bz = open_bz(url=TEST_URL, **backends)
out = run_cli("bugzilla query --product 'Red Hat Enterprise Linux 9' "
"--component 'python-bugzilla'", bzinstance=bz)
lines = out.strip().splitlines()
assert len(lines) == 1
assert lines[0].startswith("#2")
assert "Expect the Spanish inquisition" in lines[0]
def test_query_full(mocked_responses, run_cli, backends):
bz = open_bz(url=TEST_URL, **backends)
out = run_cli("bugzilla query --full --bug_id 2", bzinstance=bz)
lines = out.strip().splitlines()
assert len(lines) == 5
for name in ('Component', 'CC', 'Blocked', 'Depends'):
assert name in out
assert "Status Whiteboard" not in out
def test_query_raw(mocked_responses, run_cli, backends):
bz = open_bz(url=TEST_URL, **backends)
out = run_cli("bugzilla query --raw --bug_id 2", bzinstance=bz)
assert "ATTRIBUTE[whiteboard]: lorem ipsum" in out
assert "ATTRIBUTE[id]: 2" in out
def test_query_oneline(mocked_responses, run_cli, backends):
bz = open_bz(url=TEST_URL, **backends)
out = run_cli("bugzilla query --oneline --bug_id 2", bzinstance=bz)
lines = out.strip().splitlines()
assert len(lines) == 1
assert "python-bugzilla" in lines[0]
def test_query_extra(mocked_responses, run_cli, backends):
bz = open_bz(url=TEST_URL, **backends)
out = run_cli("bugzilla query --extra --bug_id 2", bzinstance=bz)
lines = out.strip().splitlines()
assert len(lines) == 5
assert "Keywords: FooBar" in out
assert "Status Whiteboard: lorem ipsum" in out
def test_query_format(mocked_responses, run_cli, backends):
bz = open_bz(url=TEST_URL, **backends)
out = run_cli("bugzilla query --outputformat=\"id=%{bug_id} "
"sw=%{whiteboard:status} needinfo=%{flag:needinfo} "
"sum=%{summary}\" --bug_id 2", bzinstance=bz)
lines = out.strip().splitlines()
assert len(lines) == 1
assert out.strip() == "id=2 sw=lorem ipsum needinfo=? sum=Expect the Spanish inquisition"
def test_query_url(mocked_responses, run_cli, backends):
url = urljoin(TEST_URL, "/buglist.cgi?version=9.1")
bz = open_bz(url=TEST_URL, **backends)
out = run_cli(f"bugzilla query --from-url \"{url}\"", bzinstance=bz)
assert re.search(r"#2\s+CONFIRMED", out)