Skip to content

Commit b4602d5

Browse files
committed
tests: Add 'backends' fixture to run test with both REST and XMLRPC
Add one example for bugs.mozilla.org Signed-off-by: Cole Robinson <crobinso@redhat.com>
1 parent 1b0c95a commit b4602d5

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

tests/conftest.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,17 @@ def pytest_configure(config):
7474
os.environ["HOME"] = os.path.dirname(__file__) + "/data/homedir"
7575

7676

77+
def pytest_generate_tests(metafunc):
78+
"""
79+
If a test requests the 'backends' fixture, run that test with both
80+
force_rest=True and force_xmlrpc=True Bugzilla options
81+
"""
82+
if 'backends' in metafunc.fixturenames:
83+
values = [{"force_xmlrpc": True}, {"force_rest": True}]
84+
ids = ["XMLRPC", "REST"]
85+
metafunc.parametrize("backends", values, ids=ids, scope="session")
86+
87+
7788
@pytest.fixture
7889
def run_cli(capsys, monkeypatch):
7990
"""

tests/test_ro_functional.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@
2424
def _open_bz(url, **kwargs):
2525
if "use_creds" not in kwargs:
2626
kwargs["use_creds"] = False
27-
return bugzilla.Bugzilla(url, **kwargs)
27+
bz = bugzilla.Bugzilla(url, **kwargs)
28+
29+
if kwargs.get("force_rest", False):
30+
assert bz.is_rest() is True
31+
if kwargs.get("force_xmlrpc", False):
32+
assert bz.is_xmlrpc() is True
33+
return bz
2834

2935

3036
def _check(out, mincount, expectstr):
@@ -45,9 +51,9 @@ def _test_version(bz, bzversion):
4551
# mozilla testing #
4652
###################
4753

48-
def test_mozilla():
54+
def test_mozilla(backends):
4955
url = "bugzilla.mozilla.org"
50-
bz = _open_bz(url)
56+
bz = _open_bz(url, **backends)
5157

5258
# bugzilla.mozilla.org returns version values in YYYY-MM-DD
5359
# format, so just try to confirm that

0 commit comments

Comments
 (0)