forked from umeshrege/python-bugzilla
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_modify.py
More file actions
197 lines (170 loc) · 6.38 KB
/
Copy pathtest_modify.py
File metadata and controls
197 lines (170 loc) · 6.38 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#
# Copyright Red Hat, Inc. 2013
#
# This work is licensed under the terms of the GNU GPL, version 2 or later.
# See the COPYING file in the top-level directory.
#
"""
Unit tests for building update dictionaries with 'bugzilla modify'
"""
import unittest
import pytest
import tests
rhbz = tests.make_bz("4.4.0", rhbz=True)
class ModifyTest(unittest.TestCase):
bz = rhbz
def clicomm(self, argstr, out, wbout=None, tags_add=None, tags_rm=None):
comm = "bugzilla modify --__test-return-result 123456 224466 " + argstr
(mdict, wdict, tagsa, tagsr) = tests.clicomm(
comm, self.bz, returnmain=True)
if wbout:
assert wbout == wdict
if out:
assert out == mdict
if tags_add:
assert tags_add == tagsa
if tags_rm:
assert tags_rm == tagsr
def testBasic(self):
self.clicomm(
"--component foocomp --product barprod --status ASSIGNED "
"--assignee foo@example.com --qa_contact bar@example.com "
"--comment 'hey some comment'",
{'assigned_to': 'foo@example.com',
'comment': {'comment': 'hey some comment'},
'component': 'foocomp',
'product': 'barprod',
'qa_contact': 'bar@example.com',
'status': 'ASSIGNED'}
)
def testPrivateComment(self):
self.clicomm(
"--comment 'hey private comment' --private",
{'comment': {'comment': 'hey private comment', 'is_private': True}}
)
def testClose(self):
self.clicomm(
"--close CANTFIX",
{'resolution': 'CANTFIX', 'status': 'CLOSED'}
)
self.clicomm(
"--dupeid 111333",
{'dupe_of': 111333, 'resolution': 'DUPLICATE', 'status': 'CLOSED'}
)
def testFlags(self):
self.clicomm(
"--flag needinfoX --flag dev_ack+ --flag qa_ack-",
{"flags": [
{'status': 'X', 'name': 'needinfo'},
{'status': '+', 'name': 'dev_ack'},
{'status': '-', 'name': 'qa_ack'}
]}
)
def testWhiteboard(self):
self.clicomm(
"--whiteboard tagfoo --whiteboard=-tagbar",
{}, wbout={"whiteboard": (["tagfoo"], ["tagbar"])}
)
self.clicomm(
"--whiteboard =foo --whiteboard =thisone",
{'whiteboard': 'thisone'}
)
self.clicomm(
"--qa_whiteboard =yo-qa --qa_whiteboard=-foo "
"--internal_whiteboard =internal-hey --internal_whiteboard +bar "
"--devel_whiteboard =devel-duh --devel_whiteboard=-yay "
"--tags foo1 --tags=-remove2",
{'cf_devel_whiteboard': 'devel-duh',
'cf_internal_whiteboard': 'internal-hey',
'cf_qa_whiteboard': 'yo-qa'}, wbout={
"qa_whiteboard": ([], ["foo"]),
"internal_whiteboard": (["bar"], []),
"devel_whiteboard": ([], ["yay"])
}, tags_add=["foo1"], tags_rm=["remove2"],
)
def testMisc(self):
self.clicomm(
"--fixed_in foo-bar-1.2.3 --reset-qa-contact --reset-assignee",
{"cf_fixed_in": "foo-bar-1.2.3",
'reset_assigned_to': True,
'reset_qa_contact': True}
)
self.clicomm(
"--groups +foo --groups=-bar,baz --groups fribby",
{'groups': {'add': ['foo', 'fribby'], 'remove': ['bar', 'baz']}}
)
self.clicomm(
"--target_milestone foomile --target_release relfoo",
{"target_milestone": "foomile", "target_release": "relfoo"},
)
self.clicomm(
"--priority medium --severity high",
{"priority": "medium", "severity": "high"},
)
self.clicomm(
"--os Windows --arch ia64 --version 1000 --url http://example.com "
"--summary 'foo summary'",
{"op_sys": "Windows", "platform": "ia64", "version": "1000",
"url": "http://example.com", "summary": 'foo summary'},
)
self.clicomm(
"--alias some-alias",
{"alias": "some-alias"}
)
self.clicomm("--comment 'foo bar' --comment-tag tag1 ",
{'comment': {'comment': 'foo bar'}, 'comment_tags': ['tag1']})
def testField(self):
self.clicomm(
"--field cf_fixed_in=foo-bar-1.2.4",
{"cf_fixed_in": "foo-bar-1.2.4"}
)
self.clicomm(
"--field cf_fixed_in=foo-bar-1.2.5 --field=cf_release_notes=blah",
{"cf_fixed_in": "foo-bar-1.2.5",
"cf_release_notes": "blah"}
)
def testDepends(self):
self.clicomm(
"--dependson 100,200",
{'depends_on': {'add': [100, 200]}}
)
self.clicomm(
"--dependson +100,200",
{'depends_on': {'add': [100, 200]}}
)
self.clicomm(
"--dependson=-100,200",
{'depends_on': {'remove': [100, 200]}}
)
self.clicomm(
"--dependson =100,200",
{'depends_on': {'set': [100, 200]}}
)
self.clicomm(
"--dependson 1 --dependson=-2 --dependson +3 --dependson =4",
{'depends_on': {'add': [1, 3], 'remove': [2], 'set': [4]}}
)
self.clicomm(
"--blocked 5 --blocked -6 --blocked +7 --blocked =8,9",
{'blocks': {'add': [5, 7], 'remove': [6], 'set': [8, 9]}}
)
self.clicomm(
"--keywords foo --keywords=-bar --keywords +baz --keywords =yay",
{'keywords': {'add': ["foo", "baz"],
'remove': ["bar"], 'set': ["yay"]}}
)
self.clicomm("--keywords =", {'keywords': {'set': []}})
def testCC(self):
self.clicomm(
"--cc foo@example.com --cc=-minus@example.com "
"--cc =foo@example.com --cc +foo@example.com",
{'cc': {'add': ['foo@example.com', "=foo@example.com",
"+foo@example.com"],
'remove': ["minus@example.com"]}},
)
def testSubComponents(self):
self.clicomm("--component foo --sub-component 'bar baz'",
{"component": "foo", "sub_components": {"foo": ["bar baz"]}})
def testSubComponentFail(self):
with pytest.raises(ValueError):
self.bz.build_update(sub_component="some sub component")