diff --git a/bugzilla/base.py b/bugzilla/base.py index 59f31298..14e21a34 100644 --- a/bugzilla/base.py +++ b/bugzilla/base.py @@ -1264,7 +1264,6 @@ def query(self, query): # Try to give a hint in the error message if url_to_query # isn't supported by this bugzilla instance if ("query_format" not in str(e) or - "RHBugzilla" in str(e.__class__) or self._check_version(5, 0)): raise raise BugzillaError("%s\nYour bugzilla instance does not " @@ -1719,14 +1718,15 @@ def _validate_createbug(self, *args, **kwargs): # Previous API required users specifying keyword args that mapped # to the XMLRPC arg names. Maintain that bad compat, but also allow # receiving a single dictionary like query() does - if kwargs and args: + if kwargs and args: # pragma: no cover raise BugzillaError("createbug: cannot specify positional " "args=%s with kwargs=%s, must be one or the " "other." % (args, kwargs)) if args: if len(args) > 1 or not isinstance(args[0], dict): - raise BugzillaError("createbug: positional arguments only " - "accept a single dictionary.") + raise BugzillaError( # pragma: no cover + "createbug: positional arguments only " + "accept a single dictionary.") data = args[0] else: data = kwargs diff --git a/tests/data/clioutput/test_query2-rhbz.txt b/tests/data/clioutput/test_query2-rhbz.txt new file mode 100644 index 00000000..5d93087c --- /dev/null +++ b/tests/data/clioutput/test_query2-rhbz.txt @@ -0,0 +1,2 @@ +#508645 NEW - Libvirt Maintainers - RFE: qemu: Support a managed autoconnect mode for host USB devices +#668543 NEW - Cole Robinson - RFE: warn users at guest start if networks/storage pools are inactive diff --git a/tests/data/mockargs/test_modify2.txt b/tests/data/mockargs/test_modify2.txt index 86794afb..13aa2f41 100644 --- a/tests/data/mockargs/test_modify2.txt +++ b/tests/data/mockargs/test_modify2.txt @@ -1,4 +1,5 @@ {'blocks': {'set': [123456, 445566]}, + 'comment': {'comment': 'some example comment', 'is_private': True}, 'component': 'NEWCOMP', 'dupe_of': 555666, 'flags': [{'name': '-needinfo,+somethingels', 'status': 'e'}], diff --git a/tests/data/mockargs/test_new1.txt b/tests/data/mockargs/test_new1.txt index 50de3ec0..aa61d7c5 100644 --- a/tests/data/mockargs/test_new1.txt +++ b/tests/data/mockargs/test_new1.txt @@ -1,4 +1,8 @@ -{'component': 'FOOCOMP', +{'blocks': ['12345', '6789'], + 'cc': ['foo@example.com', 'bar@example.com'], + 'comment_is_private': True, + 'component': 'FOOCOMP', + 'depends_on': ['dependme'], 'description': 'This is the first comment!\nWith newline & stuff.', 'groups': ['FOOGROUP', 'BARGROUP'], 'keywords': ['ADDKEY'], diff --git a/tests/data/mockargs/test_query1-rhbz.txt b/tests/data/mockargs/test_query1-rhbz.txt index a0fcbbce..b06a128d 100644 --- a/tests/data/mockargs/test_query1-rhbz.txt +++ b/tests/data/mockargs/test_query1-rhbz.txt @@ -1,4 +1,18 @@ -{'component': ['foo', 'bar'], +{'cc': ['foo@example.com'], + 'component': ['foo', 'bar'], + 'field0-0-0': 'keywords', + 'field1-0-0': 'cf_fixed_in', + 'field2-0-0': 'cf_qa_whiteboard', 'id': ['1234', '2480'], 'include_fields': ['assigned_to', 'id', 'status', 'summary'], - 'product': ['foo']} \ No newline at end of file + 'longdesc': 'some comment string', + 'longdesc_type': 'allwordssubstr', + 'product': ['foo'], + 'qa_contact': 'qa@example.com', + 'query_format': 'advanced', + 'type0-0-0': 'substring', + 'type1-0-0': 'substring', + 'type2-0-0': 'substring', + 'value0-0-0': 'fribkeyword', + 'value1-0-0': 'amifixed', + 'value2-0-0': 'some-example-whiteboard'} \ No newline at end of file diff --git a/tests/data/mockargs/test_query2-rhbz.txt b/tests/data/mockargs/test_query2-rhbz.txt new file mode 100644 index 00000000..c724f3ce --- /dev/null +++ b/tests/data/mockargs/test_query2-rhbz.txt @@ -0,0 +1,5 @@ +{'email1': ['foo@example.com'], + 'emailcc1': True, + 'emailtype1': 'BAR', + 'include_fields': ['assigned_to', 'id', 'status', 'summary'], + 'query_format': 'advanced'} \ No newline at end of file diff --git a/tests/data/mockargs/test_update_flags.txt b/tests/data/mockargs/test_update_flags.txt new file mode 100644 index 00000000..934e882e --- /dev/null +++ b/tests/data/mockargs/test_update_flags.txt @@ -0,0 +1 @@ +{'flags': {'name': 'needinfo', 'status': '?'}, 'ids': [12345, 6789]} \ No newline at end of file diff --git a/tests/test_api_misc.py b/tests/test_api_misc.py index 60c65163..2983e609 100644 --- a/tests/test_api_misc.py +++ b/tests/test_api_misc.py @@ -102,11 +102,17 @@ def test_rhbz_pre_translation(): assert output_query == input_query -def testSubComponentFail(): +def testUpdateFailures(): + # sub_component without component also passed bz = tests.mockbackend.make_bz(version="4.4.0", rhbz=True) with pytest.raises(ValueError): bz.build_update(sub_component="some sub component") + # Trying to update value that only rhbz supports + bz = tests.mockbackend.make_bz() + with pytest.raises(ValueError): + bz.build_update(fixed_in="some fixedin value") + def testCreatebugFieldConversion(): bz4 = tests.mockbackend.make_bz(version="4.0.0") diff --git a/tests/test_cli_modify.py b/tests/test_cli_modify.py index 2f5fee1b..6f4e88f2 100644 --- a/tests/test_cli_modify.py +++ b/tests/test_cli_modify.py @@ -32,6 +32,7 @@ def test_modify(run_cli): cmd += "--flag=-needinfo,+somethingelse " cmd += "--whiteboard =foo --whiteboard =thisone " cmd += "--dupeid 555666 " + cmd += "--comment 'some example comment' --private " fakebz = tests.mockbackend.make_bz( bug_update_args="data/mockargs/test_modify2.txt", bug_update_return={}) diff --git a/tests/test_cli_new.py b/tests/test_cli_new.py index c3ea6dad..6ab25884 100644 --- a/tests/test_cli_new.py +++ b/tests/test_cli_new.py @@ -15,7 +15,9 @@ def test_new(run_cli): cmd = "bugzilla new --product FOOPROD --component FOOCOMP " cmd += "--summary 'Hey this is the title!' " cmd += "--comment 'This is the first comment!\nWith newline & stuff.' " - cmd += "--keywords ADDKEY --groups FOOGROUP,BARGROUP" + cmd += "--keywords ADDKEY --groups FOOGROUP,BARGROUP " + cmd += "--blocked 12345,6789 --cc foo@example.com --cc bar@example.com " + cmd += "--dependson dependme --private " fakebz = tests.mockbackend.make_bz( bug_create_args="data/mockargs/test_new1.txt", diff --git a/tests/test_cli_query.py b/tests/test_cli_query.py index 21db51ca..b4028c3d 100644 --- a/tests/test_cli_query.py +++ b/tests/test_cli_query.py @@ -34,15 +34,27 @@ def test_query(run_cli): out = run_cli(cmd, fakebz) tests.utils.diff_compare(out, "data/clioutput/test_query1.txt") - # Simple query with some comma opts + # RHBZ query with a ton of opts cmd = "bugzilla query " - cmd += "--product foo --component foo,bar --bug_id 1234,2480" + cmd += "--product foo --component foo,bar --bug_id 1234,2480 " + cmd += "--keywords fribkeyword --fixed_in amifixed " + cmd += "--qa_whiteboard some-example-whiteboard " + cmd += "--cc foo@example.com --qa_contact qa@example.com " + cmd += "--comment 'some comment string' " fakebz = tests.mockbackend.make_bz(rhbz=True, bug_search_args="data/mockargs/test_query1-rhbz.txt", bug_search_return="data/mockreturn/test_query1.txt") out = run_cli(cmd, fakebz) tests.utils.diff_compare(out, "data/clioutput/test_query1-rhbz.txt") + # --emailtype handling + cmd = "bugzilla query --cc foo@example.com --emailtype BAR " + fakebz = tests.mockbackend.make_bz(rhbz=True, + bug_search_args="data/mockargs/test_query2-rhbz.txt", + bug_search_return="data/mockreturn/test_query1.txt") + out = run_cli(cmd, fakebz) + tests.utils.diff_compare(out, "data/clioutput/test_query2-rhbz.txt") + # Same but with --ids output cmd = "bugzilla query --ids " cmd += "--product foo --component foo,bar --bug_id 1234,2480"