File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2424def _open_bz (url , ** kwargs ):
2525 if "use_creds" not in kwargs :
2626 kwargs ["use_creds" ] = False
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
27+ return tests .utils .open_functional_bz (bugzilla .Bugzilla , url , kwargs )
3428
3529
3630def _check (out , mincount , expectstr ):
Original file line number Diff line number Diff line change @@ -33,7 +33,11 @@ def _split_int(s):
3333 return [int (i ) for i in s .split ("," )]
3434
3535
36- if not bugzilla .RHBugzilla (url = RHURL ).logged_in :
36+ def _open_bz (** kwargs ):
37+ return tests .utils .open_functional_bz (bugzilla .RHBugzilla , RHURL , kwargs )
38+
39+
40+ if not _open_bz ().logged_in :
3741 print ("\n R/W tests require cached login credentials for url=%s\n " % RHURL )
3842 sys .exit (1 )
3943
@@ -50,10 +54,6 @@ def _check_have_admin(bz):
5054 return ret
5155
5256
53- def _open_bz (** kwargs ):
54- return bugzilla .RHBugzilla (url = RHURL , ** kwargs )
55-
56-
5757def test0LoggedInNoCreds ():
5858 bz = _open_bz (use_creds = False )
5959 assert not bz .logged_in
Original file line number Diff line number Diff line change @@ -43,6 +43,27 @@ def monkeypatch_getpass(monkeypatch):
4343 raw_input ) # pylint: disable=undefined-variable
4444
4545
46+ def open_functional_bz (bzclass , url , kwargs ):
47+ bz = bzclass (url , ** kwargs )
48+
49+ if kwargs .get ("force_rest" , False ):
50+ assert bz .is_rest () is True
51+ if kwargs .get ("force_xmlrpc" , False ):
52+ assert bz .is_xmlrpc () is True
53+
54+ # Set a session timeout of 30 seconds
55+ session = bz .get_requests_session ()
56+ origrequest = session .request
57+
58+ def fake_request (* args , ** kwargs ):
59+ if "timeout" not in kwargs :
60+ kwargs ["timeout" ] = 60
61+ return origrequest (* args , ** kwargs )
62+
63+ session .request = fake_request
64+ return bz
65+
66+
4667def diff_compare (inputdata , filename ):
4768 """Compare passed string output to contents of filename"""
4869 filename = tests_path (filename )
You can’t perform that action at this time.
0 commit comments