2727import pytest
2828
2929import bugzilla
30- from bugzilla import Bugzilla
3130import tests
3231
3332
@@ -39,17 +38,11 @@ def _split_int(s):
3938
4039
4140if not bugzilla .RHBugzilla (url = RHURL ).logged_in :
42- print ("R /W tests require cached login credentials for url=%s" % RHURL )
41+ print ("\n R /W tests require cached login credentials for url=%s\n " % RHURL )
4342 sys .exit (1 )
4443
4544
4645class RHPartnerTest (unittest .TestCase ):
47- # Despite its name, this instance is simply for bugzilla testing,
48- # doesn't send out emails and is blown away occasionally. The front
49- # page has some info.
50- url = RHURL
51- bzclass = bugzilla .RHBugzilla
52-
5346 def _check_have_admin (self , bz , funcname ):
5447 # groupnames is empty for any user if our logged in user does not
5548 # have admin privs.
@@ -59,13 +52,16 @@ def _check_have_admin(self, bz, funcname):
5952 print ("\n No admin privs, reduced testing of %s" % funcname )
6053 return ret
6154
55+ def _open_bz (self , ** kwargs ):
56+ return bugzilla .RHBugzilla (url = RHURL , ** kwargs )
57+
6258 def test0LoggedInNoCreds (self ):
63- bz = self .bzclass ( url = self . url , use_creds = False )
59+ bz = self ._open_bz ( use_creds = False )
6460 assert not bz .logged_in
6561
6662 def test2 (self ):
67- bz = Bugzilla (url = self . url , use_creds = False )
68- assert bz .__class__ is self . bzclass
63+ bz = bugzilla . Bugzilla (RHURL , use_creds = False )
64+ assert bz .__class__ is bugzilla . RHBugzilla
6965
7066 def _makebug (self , bz ):
7167 component = "python-bugzilla"
@@ -94,7 +90,7 @@ def test03NewBugBasic(self):
9490 """
9591 Create a bug with minimal amount of fields, then close it
9692 """
97- bz = self .bzclass ( url = self . url )
93+ bz = self ._open_bz ( )
9894 bug = self ._makebug (bz )
9995
10096 # Verify hasattr works
@@ -112,7 +108,7 @@ def test04NewBugAllFields(self):
112108 """
113109 Create a bug using all 'new' fields, check some values, close it
114110 """
115- bz = self .bzclass ( url = self . url )
111+ bz = self ._open_bz ( )
116112
117113 summary = ("python-bugzilla test manyfields bug %s" %
118114 datetime .datetime .today ())
@@ -176,7 +172,7 @@ def test05ModifyStatus(self):
176172 """
177173 Modify status and comment fields for an existing bug
178174 """
179- bz = self .bzclass ( url = self . url )
175+ bz = self ._open_bz ( )
180176 bugid = "663674"
181177 cmd = "bugzilla modify %s " % bugid
182178
@@ -263,7 +259,7 @@ def test06ModifyEmails(self):
263259 """
264260 Modify cc, assignee, qa_contact for existing bug
265261 """
266- bz = self .bzclass ( url = self . url )
262+ bz = self ._open_bz ( )
267263 bugid = "663674"
268264 cmd = "bugzilla modify %s " % bugid
269265
@@ -311,7 +307,7 @@ def test07ModifyMultiFlags(self):
311307 """
312308 Modify flags and fixed_in for 2 bugs
313309 """
314- bz = self .bzclass ( url = self . url )
310+ bz = self ._open_bz ( )
315311 bugid1 = "461686"
316312 bugid2 = "461687"
317313 cmd = "bugzilla modify %s %s " % (bugid1 , bugid2 )
@@ -399,7 +395,7 @@ def cleardict_new(b):
399395 def test07ModifyMisc (self ):
400396 bugid = "461686"
401397 cmd = "bugzilla modify %s " % bugid
402- bz = self .bzclass ( url = self . url )
398+ bz = self ._open_bz ( )
403399 bug = bz .getbug (bugid )
404400
405401 # modify --dependson
@@ -501,7 +497,7 @@ def _test8Attachments(self):
501497 """
502498 Get and set attachments for a bug
503499 """
504- bz = self .bzclass ( url = self . url )
500+ bz = self ._open_bz ( )
505501 cmd = "bugzilla attach "
506502 testfile = "../tests/data/bz-attach-get1.txt"
507503
@@ -552,7 +548,7 @@ def _test8Attachments(self):
552548 assert setbug .attachments [- 1 ]["flags" ] == []
553549
554550 # Set attachment obsolete
555- bz ._proxy . Bug . update_attachment ({ # pylint: disable=protected-access
551+ bz ._backend . bug_attachment_update ({ # pylint: disable=protected-access
556552 "ids" : [setbug .attachments [- 1 ]["id" ]],
557553 "is_obsolete" : 1 })
558554 setbug .refresh ()
@@ -599,7 +595,7 @@ def _test8Attachments(self):
599595
600596
601597 def test09Whiteboards (self ):
602- bz = self .bzclass ( url = self . url )
598+ bz = self ._open_bz ( )
603599 bug_id = "663674"
604600 cmd = "bugzilla modify %s " % bug_id
605601 bug = bz .getbug (bug_id )
@@ -668,7 +664,7 @@ def fakegetpass(prompt):
668664 getpass .getpass = fakegetpass
669665
670666 try :
671- cmd = "bugzilla --no-cache-credentials --bugzilla %s" % self . url
667+ cmd = "bugzilla --no-cache-credentials --bugzilla %s" % RHURL
672668 # Implied login with --username and --password
673669 ret = tests .
clicomm (
"%s --user [email protected] " 674670 "--password foobar query -b 123456" % cmd ,
@@ -700,7 +696,7 @@ def fakegetpass(prompt):
700696
701697 def test11UserUpdate (self ):
702698 # This won't work if run by the same user we are using
703- bz = self .bzclass ( url = self . url )
699+ bz = self ._open_bz ( )
704700705701 group = "fedora_contrib"
706702
@@ -758,7 +754,7 @@ def test11UserUpdate(self):
758754
759755
760756 def test11ComponentEditing (self ):
761- bz = self .bzclass ( url = self . url )
757+ bz = self ._open_bz ( )
762758 component = ("python-bugzilla-testcomponent-%s" %
763759 str (random .randint (1 , 1024 * 1024 * 1024 )))
764760 basedata = {
@@ -831,8 +827,7 @@ def compare(data, newid):
831827 ("You are not allowed" in str (e )))
832828
833829 def test12SetCookie (self ):
834- bz = self .bzclass (self .url ,
835- cookiefile = - 1 , tokenfile = None , configpaths = [])
830+ bz = self ._open_bz (cookiefile = - 1 , tokenfile = None , configpaths = [])
836831
837832 try :
838833 bz .cookiefile = None
@@ -847,7 +842,7 @@ def test12SetCookie(self):
847842 assert not bz .logged_in
848843
849844 def test13SubComponents (self ):
850- bz = self .bzclass ( url = self . url )
845+ bz = self ._open_bz ( )
851846 # Long closed RHEL5 lvm2 bug. This component has sub_components
852847 bug = bz .getbug ("185526" )
853848 bug .autorefresh = True
@@ -865,18 +860,18 @@ def test13SubComponents(self):
865860 "Default / Unclassified (RHEL5)" ]}
866861
867862 def test13ExternalTrackerQuery (self ):
868- bz = self .bzclass ( url = self . url )
863+ bz = self ._open_bz ( )
869864 with pytest .raises (RuntimeError ):
870865 bz .build_external_tracker_boolean_query ()
871866
872867 def _deleteAllExistingExternalTrackers (self , bugid ):
873- bz = self .bzclass ( url = self . url )
868+ bz = self ._open_bz ( )
874869 ids = [bug ['id' ] for bug in bz .getbug (bugid ).external_bugs ]
875870 if ids != []:
876871 bz .remove_external_tracker (ids = ids )
877872
878873 def test14ExternalTrackersAddUpdateRemoveQuery (self ):
879- bz = self .bzclass ( url = self . url )
874+ bz = self ._open_bz ( )
880875 bugid = 461686
881876 ext_bug_id = 380489
882877
@@ -922,14 +917,14 @@ def test14ExternalTrackersAddUpdateRemoveQuery(self):
922917 assert len (ids ) == 0
923918
924919 def test15EnsureLoggedIn (self ):
925- bz = self .bzclass ( url = self . url )
920+ bz = self ._open_bz ( )
926921 comm = "bugzilla --ensure-logged-in query --bug_id 979546"
927922 tests .clicomm (comm , bz )
928923
929924 def test16ModifyTags (self ):
930925 bugid = "461686"
931926 cmd = "bugzilla modify %s " % bugid
932- bz = self .bzclass ( url = self . url )
927+ bz = self ._open_bz ( )
933928 bug = bz .getbug (bugid )
934929
935930 if bug .tags :
@@ -951,7 +946,7 @@ def test16ModifyTags(self):
951946
952947 def test17LoginAPIKey (self ):
953948 api_key = "somefakeapikey1234"
954- bz = self .bzclass ( url = self . url , use_creds = False , api_key = api_key )
949+ bz = self ._open_bz ( use_creds = False , api_key = api_key )
955950 if bz .bz_ver_major < 5 :
956951 self .skipTest ("can only test apikey on bugzilla 5+" )
957952
0 commit comments