Skip to content

Commit 48797ca

Browse files
committed
tests: fill out API side of cli command coverage
Signed-off-by: Cole Robinson <[email protected]>
1 parent d154649 commit 48797ca

11 files changed

Lines changed: 59 additions & 11 deletions

bugzilla/base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,6 @@ def query(self, query):
12641264
# Try to give a hint in the error message if url_to_query
12651265
# isn't supported by this bugzilla instance
12661266
if ("query_format" not in str(e) or
1267-
"RHBugzilla" in str(e.__class__) or
12681267
self._check_version(5, 0)):
12691268
raise
12701269
raise BugzillaError("%s\nYour bugzilla instance does not "
@@ -1719,14 +1718,15 @@ def _validate_createbug(self, *args, **kwargs):
17191718
# Previous API required users specifying keyword args that mapped
17201719
# to the XMLRPC arg names. Maintain that bad compat, but also allow
17211720
# receiving a single dictionary like query() does
1722-
if kwargs and args:
1721+
if kwargs and args: # pragma: no cover
17231722
raise BugzillaError("createbug: cannot specify positional "
17241723
"args=%s with kwargs=%s, must be one or the "
17251724
"other." % (args, kwargs))
17261725
if args:
17271726
if len(args) > 1 or not isinstance(args[0], dict):
1728-
raise BugzillaError("createbug: positional arguments only "
1729-
"accept a single dictionary.")
1727+
raise BugzillaError( # pragma: no cover
1728+
"createbug: positional arguments only "
1729+
"accept a single dictionary.")
17301730
data = args[0]
17311731
else:
17321732
data = kwargs
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#508645 NEW - Libvirt Maintainers - RFE: qemu: Support a managed autoconnect mode for host USB devices
2+
#668543 NEW - Cole Robinson - RFE: warn users at guest start if networks/storage pools are inactive

tests/data/mockargs/test_modify2.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{'blocks': {'set': [123456, 445566]},
2+
'comment': {'comment': 'some example comment', 'is_private': True},
23
'component': 'NEWCOMP',
34
'dupe_of': 555666,
45
'flags': [{'name': '-needinfo,+somethingels', 'status': 'e'}],

tests/data/mockargs/test_new1.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
{'component': 'FOOCOMP',
1+
{'blocks': ['12345', '6789'],
2+
3+
'comment_is_private': True,
4+
'component': 'FOOCOMP',
5+
'depends_on': ['dependme'],
26
'description': 'This is the first comment!\nWith newline & stuff.',
37
'groups': ['FOOGROUP', 'BARGROUP'],
48
'keywords': ['ADDKEY'],
Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
{'component': ['foo', 'bar'],
1+
{'cc': ['[email protected]'],
2+
'component': ['foo', 'bar'],
3+
'field0-0-0': 'keywords',
4+
'field1-0-0': 'cf_fixed_in',
5+
'field2-0-0': 'cf_qa_whiteboard',
26
'id': ['1234', '2480'],
37
'include_fields': ['assigned_to', 'id', 'status', 'summary'],
4-
'product': ['foo']}
8+
'longdesc': 'some comment string',
9+
'longdesc_type': 'allwordssubstr',
10+
'product': ['foo'],
11+
'qa_contact': '[email protected]',
12+
'query_format': 'advanced',
13+
'type0-0-0': 'substring',
14+
'type1-0-0': 'substring',
15+
'type2-0-0': 'substring',
16+
'value0-0-0': 'fribkeyword',
17+
'value1-0-0': 'amifixed',
18+
'value2-0-0': 'some-example-whiteboard'}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{'email1': ['[email protected]'],
2+
'emailcc1': True,
3+
'emailtype1': 'BAR',
4+
'include_fields': ['assigned_to', 'id', 'status', 'summary'],
5+
'query_format': 'advanced'}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{'flags': {'name': 'needinfo', 'status': '?'}, 'ids': [12345, 6789]}

tests/test_api_misc.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,17 @@ def test_rhbz_pre_translation():
102102
assert output_query == input_query
103103

104104

105-
def testSubComponentFail():
105+
def testUpdateFailures():
106+
# sub_component without component also passed
106107
bz = tests.mockbackend.make_bz(version="4.4.0", rhbz=True)
107108
with pytest.raises(ValueError):
108109
bz.build_update(sub_component="some sub component")
109110

111+
# Trying to update value that only rhbz supports
112+
bz = tests.mockbackend.make_bz()
113+
with pytest.raises(ValueError):
114+
bz.build_update(fixed_in="some fixedin value")
115+
110116

111117
def testCreatebugFieldConversion():
112118
bz4 = tests.mockbackend.make_bz(version="4.0.0")

tests/test_cli_modify.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def test_modify(run_cli):
3232
cmd += "--flag=-needinfo,+somethingelse "
3333
cmd += "--whiteboard =foo --whiteboard =thisone "
3434
cmd += "--dupeid 555666 "
35+
cmd += "--comment 'some example comment' --private "
3536
fakebz = tests.mockbackend.make_bz(
3637
bug_update_args="data/mockargs/test_modify2.txt",
3738
bug_update_return={})

tests/test_cli_new.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ def test_new(run_cli):
1515
cmd = "bugzilla new --product FOOPROD --component FOOCOMP "
1616
cmd += "--summary 'Hey this is the title!' "
1717
cmd += "--comment 'This is the first comment!\nWith newline & stuff.' "
18-
cmd += "--keywords ADDKEY --groups FOOGROUP,BARGROUP"
18+
cmd += "--keywords ADDKEY --groups FOOGROUP,BARGROUP "
19+
cmd += "--blocked 12345,6789 --cc [email protected] --cc [email protected] "
20+
cmd += "--dependson dependme --private "
1921

2022
fakebz = tests.mockbackend.make_bz(
2123
bug_create_args="data/mockargs/test_new1.txt",

0 commit comments

Comments
 (0)