forked from python-bugzilla/python-bugzilla
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreatebug.py
More file actions
91 lines (75 loc) · 2.81 KB
/
createbug.py
File metadata and controls
91 lines (75 loc) · 2.81 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
#
# 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 createbug dictionaries with bin/bugzilla
'''
import unittest
import tests
bz4 = tests.make_bz("4.0.0")
class CreatebugTest(unittest.TestCase):
maxDiff = None
bz = bz4
def assertDictEqual(self, *args, **kwargs):
# pylint: disable=arguments-differ
# EPEL5 back compat
if hasattr(unittest.TestCase, "assertDictEqual"):
return unittest.TestCase.assertDictEqual(self, *args, **kwargs)
return self.assertEqual(*args, **kwargs)
def clicomm(self, argstr, out):
comm = "bugzilla new --test-return-result " + argstr
if out is None:
self.assertRaises(RuntimeError, tests.clicomm, comm, self.bz)
else:
q = tests.clicomm(comm, self.bz, returnmain=True)
self.assertDictEqual(out, q)
def testBasic(self):
self.clicomm(
"--product foo --component bar --summary baz --version 12",
{'component': 'bar', 'product': 'foo',
'summary': 'baz', 'version': '12'}
)
def testOpSys(self):
self.clicomm(
"--os windowsNT --arch ia64 --comment 'youze a foo' --cc me",
{'description': 'youze a foo', 'op_sys': 'windowsNT',
'platform': 'ia64', 'cc': ["me"]}
)
def testSeverity(self):
self.clicomm(
"--severity HIGH --priority Low --url http://example.com",
{'url': 'http://example.com', 'priority': 'Low',
'severity': 'HIGH'}
)
def testMisc(self):
self.clicomm(
"--alias some-alias",
{"alias": "some-alias"}
)
def testMultiOpts(self):
# Test all opts that can take lists
out = {'blocks': ['3', '4'], 'cc': ['1', '2'],
'depends_on': ['5', 'foo', 'wib'], 'groups': ['bar', '8'],
'keywords': ['TestOnly', 'ZStream']}
self.clicomm(
"--cc 1,2 --blocked 3,4 --dependson 5,foo,wib --groups bar,8 "
"--keywords TestOnly,ZStream",
out
)
self.clicomm(
"--cc 1 --cc 2 --blocked 3 --blocked 4 "
"--dependson 5,foo --dependson wib --groups bar --groups 8 "
"--keywords TestOnly --keywords ZStream",
out
)
def testFieldConversion(self):
vc = self.bz._validate_createbug # pylint: disable=protected-access
out = vc(product="foo", component="bar",
version="12", description="foo", short_desc="bar",
check_args=False)
self.assertDictEqual(out,
{'component': 'bar', 'description': 'foo', 'product': 'foo',
'summary': 'bar', 'version': '12'})