3 from yumguicore
.gui
import doGtkEvents
4 from yum
.constants
import *
6 def testProgress(progress
):
8 test function for the Progress class
9 @param progress: instance of the Progress class to test
11 progress
.set_markup('<b>Testing the Progress class</b>')
13 frac
= float(x
)/1000.0
14 percent
= int(float(x
)/999.0*100)
15 progress
.set_pbar_text('%i %%' % percent
)
16 progress
.set_fraction(frac
)
20 def testTextViewConsole(console
):
22 Test function for the TextViewConsole class
23 @param console: instance of the TextViewConsole class
25 console
.write_line('Testing TextViewConsole class\n')
26 txt
= 'Line of text (default style)\n' * 5
27 console
.write_line(txt
)
28 txt
= 'Line of text (style_err)\n' * 5
29 console
.write_line(txt
,console
.style_err
)
33 def testRPMCallback(callback
):
34 ''' test the YumGuiRPMCallback class '''
36 ''' Simulate txmbr '''
38 self
.output_state
= TS_INSTALL
41 ''' Simulate tsInfo '''
45 def getMembers(self
,pkgtup
):
46 return [fakeTxMember()]
48 def fakeRPMHeader(tup
):
49 ''' Generate a dictinary to simulate an rpm header '''
51 hdr
['name'], hdr
['arch'], hdr
['epoch'], hdr
['version'], hdr
['release'] = tup
54 files
= [(('foo','i386','0','1.0','1.fc7'),100000),
55 (('foo1','noarch','1','1.1','4.fc7'),200000),
56 (('foo2','i386','0','2.0','5.fc7'),300000),
57 (('foo3','i386','0','3.0','7.fc7'),400000)]
59 callback
.tsInfo
= tsInfo
60 what
= rpm
.RPMCALLBACK_TRANS_START
61 callback
.callback(what
,6,len(files
),None,None)
62 for tup
,size
in files
:
64 hdr
= fakeRPMHeader(tup
)
65 rpmloc
= '%s-%s-%s.%s.rpm' % (hdr
['name'], hdr
['version'], hdr
['release'],hdr
['arch'])
67 what
= rpm
.RPMCALLBACK_INST_PROGRESS
70 callback
.callback(what
,cursize
,size
,h
,None)
71 what
= rpm
.RPMCALLBACK_TRANS_STOP
72 callback
.callback(what
,None,None,None,None)
73 callback
.progress
.reset()
76 if __name__
== "__main__":