Merge lp:~pedro/mago/brasero-tests into lp:~mago-contributors/mago/mago-1.0

Proposed by Pedro Villavicencio
Status: Merged
Merged at revision: 141
Proposed branch: lp:~pedro/mago/brasero-tests
Merge into: lp:~mago-contributors/mago/mago-1.0
Diff against target: 256 lines (+228/-0)
5 files modified
brasero/README (+16/-0)
brasero/brasero_basics.py (+20/-0)
brasero/brasero_basics.xml (+15/-0)
mago/application/brasero.py (+145/-0)
mago/test_suite/brasero.py (+32/-0)
To merge this branch: bzr merge lp:~pedro/mago/brasero-tests
Reviewer Review Type Date Requested Status
Jean-Baptiste Lallement Approve
Review via email: mp+41051@code.launchpad.net

This proposal supersedes a proposal from 2010-11-15.

Description of the change

Added a Brasero basic test, that burns a directory into an ISO file.

To post a comment you must log in.
Revision history for this message
Jean-Baptiste Lallement (jibel) wrote : Posted in a previous version of this proposal

Thanks for your work. I've a few comments though.

* in mago/test_suite/brasero.py
 - The cleanup code is superfluous. If you really want to close the app during cleanup a call to self.application.close() should be enough.
 - The cleanup method could also remove the brasero.iso that the test just created
* mago/application/brasero.py
 - If /tmp/brasero.iso already exist then the test fails because a dialog is displayed asking to overwrite that file. Either check the existence of this dialog or remove /tmp/brasero.iso as a precondition of the test.
* General comment about style:
I'm not a style maniac, far from it, but there are some improvements here.
 - Don't mix tabs and spaces for indentation (brasero/brasero_basics.py)
 - I know that spaces are cheap but don't use them between the function name and the args e.g
NO: brasero = ooldtp.context (self.name)
YES: brasero = ooldtp.context(self.name)

NO: brasero.getchild (self.BTN_BURN).click ()
YES: brasero.getchild(self.BTN_BURN).click()

More infos at http://www.python.org/dev/peps/pep-0008/

I'll be happy to review it again after the changes.

review: Needs Fixing
Revision history for this message
Pedro Villavicencio (pedro) wrote : Posted in a previous version of this proposal

Thanks for the comments!, I've followed those and include the recommendations into the branch, may you please check and tell me if it's ok this time? Thanks in advance!.

Revision history for this message
Jean-Baptiste Lallement (jibel) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'brasero'
2=== added file 'brasero/README'
3--- brasero/README 1970-01-01 00:00:00 +0000
4+++ brasero/README 2010-11-17 14:23:27 +0000
5@@ -0,0 +1,16 @@
6+BRASERO TESTS
7+=============
8+
9+Safety
10+------
11+None of these tests touches any configuration or system files. They are safe to run.
12+
13+Configuration
14+-------------
15+A file needs to be on the data/ folder in order to burn it, an example image (brasero-test.png) is included with the test.
16+
17+Available Tests
18+---------------
19+
20+* Brasero Basics:
21+ - Burn Data into an ISO file.
22
23=== added file 'brasero/brasero_basics.py'
24--- brasero/brasero_basics.py 1970-01-01 00:00:00 +0000
25+++ brasero/brasero_basics.py 2010-11-17 14:23:27 +0000
26@@ -0,0 +1,20 @@
27+# -*- coding: utf-8 -*-
28+import os
29+from time import time, gmtime, strftime
30+
31+from mago.test_suite.brasero import BraseroTestSuite
32+
33+class BraseroBasics(BraseroTestSuite):
34+ def burn_path_to_iso(self, path_to_burn=None, iso_tmp_path=None):
35+ #Make sure the iso file is not there and if it's remove it.
36+ self.check_iso_and_remove(iso_tmp_path)
37+
38+ dir_path = os.path.join(self.get_test_dir(), path_to_burn)
39+ self.application.burn_path_to_iso(dir_path, iso_tmp_path)
40+ #small check to see if the iso was created on the specified directory.
41+ if not(os.path.exists(iso_tmp_path)):
42+ raise AssertionError, "ISO file was not created."
43+
44+if __name__ == "__main__":
45+ brasero_test = BraseroBasics()
46+ brasero_test.run()
47
48=== added file 'brasero/brasero_basics.xml'
49--- brasero/brasero_basics.xml 1970-01-01 00:00:00 +0000
50+++ brasero/brasero_basics.xml 2010-11-17 14:23:27 +0000
51@@ -0,0 +1,15 @@
52+<?xml version="1.0"?>
53+<suite name="Application Basics">
54+ <class>brasero_basics.BraseroBasics</class>
55+ <description>
56+ Tests which verify Brasero basics file functionality.
57+ </description>
58+ <case name="Burn Data ISO">
59+ <method>burn_path_to_iso</method>
60+ <description>Test for burning a directory to an ISO file on the disk</description>
61+ <args>
62+ <path_to_burn>data/</path_to_burn>
63+ <iso_tmp_path>/tmp/brasero.iso</iso_tmp_path>
64+ </args>
65+ </case>
66+</suite>
67
68=== added directory 'brasero/data'
69=== added file 'brasero/data/brasero-test.png'
70Binary files brasero/data/brasero-test.png 1970-01-01 00:00:00 +0000 and brasero/data/brasero-test.png 2010-11-17 14:23:27 +0000 differ
71=== added file 'mago/application/brasero.py'
72--- mago/application/brasero.py 1970-01-01 00:00:00 +0000
73+++ mago/application/brasero.py 2010-11-17 14:23:27 +0000
74@@ -0,0 +1,145 @@
75+PACKAGE = "mago"
76+
77+#-*- coding:utf-8 -*-
78+"""
79+This is the "brasero" module.
80+
81+This module provides a wrapper for LDTP to make writing Brasero tests easier.
82+"""
83+import ooldtp
84+import ldtp
85+import os
86+from .main import Application
87+from ..gconfwrapper import GConf
88+from ..cmd import globals
89+import time
90+import gettext
91+
92+gettext.install (True)
93+gettext.bindtextdomain (PACKAGE, globals.LOCALE_SHARE)
94+gettext.textdomain (PACKAGE)
95+t = gettext.translation(PACKAGE, globals.LOCALE_SHARE, fallback = True)
96+_ = t.gettext
97+
98+
99+class Brasero(Application):
100+ """
101+ brasero manages the Brasero application.
102+ """
103+
104+ LAUNCHER = 'brasero'
105+ LAUNCHER_ARGS = []
106+ WINDOW = 'frmBrasero*'
107+
108+ DLG_SELECT_FILES = _('dlgSelectFiles')
109+ DLG_LOCATION_FOR = _('dlgLocationforImageFile')
110+ DLG_CREATINGIMAGE = _('dlgCreatingImage')
111+ BTN_0 = _('btn0')
112+ BTN_1 = _('btn1')
113+ BTN_2 = _('btn2')
114+ BTN_3 = _('btn3')
115+ BTN_4 = _('btn4')
116+ BTN_ADD = _('btnAdd')
117+ BTN_ADD1 = _('btnAdd1')
118+ BTN_ADD2 = _('btnAdd2')
119+ BTN_BURN = _('btnBurn*')
120+ BTN_CLOSE = _('btnClose')
121+ BTN_CREATEFOLDER = _('btnCreateFolder')
122+ BTN_CREATEIMAGE = _('btnCreateImage')
123+ BTN_DOWNPATH = _('btnDownPath')
124+ BTN_EMPTYPROJECT = _('btnEmptyProject')
125+ BTN_REMOVE = _('btnRemove')
126+ BTN_REMOVE1 = _('btnRemove1')
127+ BTN_REMOVE2 = _('btnRemove2')
128+ BTN_UPPATH = _('btnUpPath')
129+ BTN_ZOOMIN = _('btnZoomIn')
130+ BTN_ZOOMOUT = _('btnZoomOut')
131+ BTN_TYPE_A_FILENAME = _('btnTypeafilename')
132+ MNU_ABOUT = _('mnuAbout')
133+ MNU_ADDFILES = _('mnuAddFiles')
134+ MNU_ALLFILES = _('mnuAllfiles')
135+ MNU_AUDIOFILES = _('mnuAudiofiles')
136+ MNU_BLANK___ = _('mnuBlank...')
137+ MNU_BROWSETHEFILESYSTEM = _('mnuBrowsethefilesystem')
138+ MNU_BURNIMAGE___ = _('mnuBurnImage...')
139+ MNU_BURN___ = _('mnuBurn...')
140+ MNU_CHECKINTEGRITY___ = _('mnuCheckIntegrity...')
141+ MNU_CONTENTS = _('mnuContents')
142+ MNU_COPYDISC___ = _('mnuCopyDisc...')
143+ MNU_COVEREDITOR = _('mnuCoverEditor')
144+ MNU_DISPLAYPLAYLISTSANDTHEIRCONTENTS = _('mnuDisplayplaylistsandtheircontents')
145+ MNU_EJECT = _('mnuEject')
146+ MNU_EMPTY = _('mnuEmpty')
147+ MNU_EMPTY1 = _('mnuEmpty1')
148+ MNU_EMPTY2 = _('mnuEmpty2')
149+ MNU_EMPTY3 = _('mnuEmpty3')
150+ MNU_EMPTY4 = _('mnuEmpty4')
151+ MNU_EMPTY5 = _('mnuEmpty5')
152+ MNU_EMPTYPROJECT = _('mnuEmptyProject')
153+ MNU_GETHELPONLINE = _('mnuGetHelpOnline')
154+ MNU_IMAGEFILE = _('mnuImageFile')
155+ MNU_IMAGEFILES = _('mnuImagefiles')
156+ MNU_MOVIES = _('mnuMovies')
157+ MNU_NEWAUDIOPROJECT = _('mnuNewAudioProject')
158+ MNU_NEWDATAPROJECT = _('mnuNewDataProject')
159+ MNU_NEWVIDEOPROJECT = _('mnuNewVideoProject')
160+ MNU_NOITEMSFOUND = _('mnuNoitemsfound')
161+ MNU_OPEN___ = _('mnuOpen...')
162+ MNU_PLUGINS = _('mnuPlugins')
163+ MNU_QUIT = _('mnuQuit')
164+ MNU_REMOVEFILES = _('mnuRemoveFiles')
165+ MNU_REPORTAPROBLEM = _('mnuReportaProblem')
166+ MNU_SAVE = _('mnuSave')
167+ MNU_SAVEAS___ = _('mnuSaveAs...')
168+ MNU_TRANSLATETHISAPPLICATION = _('mnuTranslateThisApplication')
169+ TXT_0 = _('txt0')
170+ TXT_1 = _('txt1')
171+ TXT_LOCATION = _('txtLocation')
172+ TXT_NAME = _('txtName')
173+
174+ def burn_path_to_iso(self, path_to_burn, iso_tmp_path):
175+ brasero = ooldtp.context(self.name)
176+
177+ # Click on the new data project menu item
178+ brasero.getchild(self.MNU_NEWDATAPROJECT).selectmenuitem()
179+ ldtp.wait(2)
180+ # Click on the Add Files button
181+ brasero.getchild(self.BTN_ADD).click()
182+ ldtp.wait(2)
183+ #Select the files with the path previously assigned on the xml file. (data/)
184+ if (ldtp.guiexist(self.DLG_SELECT_FILES)):
185+ selectFiles = ooldtp.context(self.DLG_SELECT_FILES)
186+ if not (selectFiles.getchild(self.TXT_LOCATION)):
187+ ldtp.generatekeyevent('<ctrl>l')
188+ textLocation = selectFiles.getchild(self.TXT_LOCATION)
189+ textLocation.settextvalue(path_to_burn)
190+ ldtp.generatekeyevent('<return>')
191+ ldtp.wait(2)
192+ # Go back to Brasero window and click on Burn.
193+ ldtp.waittillguiexist(self.WINDOW)
194+ brasero.getchild(self.BTN_BURN).click()
195+
196+ # wait for the dialog and enter the tmp path for the ISO previously assigned on the xml file.
197+ ldtp.waittillguiexist(self.DLG_LOCATION_FOR)
198+
199+ if (ldtp.guiexist(self.DLG_LOCATION_FOR)):
200+ location = ooldtp.context(self.DLG_LOCATION_FOR)
201+ textISO = location.getchild(self.TXT_NAME)
202+ textISO.settextvalue(iso_tmp_path)
203+ if (location.getchild(self.BTN_CREATEIMAGE)):
204+ location.getchild(self.BTN_CREATEIMAGE).click()
205+ else:
206+ ldtp.generatekeyevent('<return>')
207+ else:
208+ ldtp.generatekeyevent('<return>')
209+
210+ #Create the image and wait for the last dialog.
211+ ldtp.waittillguiexist(self.DLG_CREATINGIMAGE)
212+ creatingImage = ooldtp.context(self.DLG_CREATINGIMAGE)
213+ #Wait till the Close button is available, during the burn process only a Cancel button is shown to the user.
214+ ldtp.waittillguiexist(self.DLG_CREATINGIMAGE, self.BTN_CLOSE)
215+ creatingImage.getchild(self.BTN_CLOSE).click()
216+ ldtp.waittillguiexist(self.WINDOW)
217+
218+ def __init__(self):
219+ Application.__init__(self)
220
221=== added file 'mago/test_suite/brasero.py'
222--- mago/test_suite/brasero.py 1970-01-01 00:00:00 +0000
223+++ mago/test_suite/brasero.py 2010-11-17 14:23:27 +0000
224@@ -0,0 +1,32 @@
225+"""
226+This module contains the definition of the test suite for Brasero testing.
227+"""
228+import ldtp, ooldtp
229+import os
230+from .main import SingleApplicationTestSuite
231+from ..application.brasero import Application, Brasero
232+
233+class BraseroTestSuite(SingleApplicationTestSuite):
234+ """
235+ Default test suite for Brasero
236+ """
237+ APPLICATION_FACTORY = Brasero
238+
239+ def check_iso_and_remove (self, path=None):
240+ if (os.path.exists(path)):
241+ try:
242+ os.remove(path)
243+ except OSError, error:
244+ raise AssertionError, ("could not remove %s, %s" % (path, error))
245+
246+ def setup(self):
247+ self.application.open()
248+
249+ def teardown(self):
250+ self.application.close()
251+
252+ def cleanup(self):
253+ #delete the iso if it's present in the tmp dir.
254+ ##TODO: grab the variable from the brasero_basics.xml
255+ iso_file = '/tmp/brasero.iso'
256+ self.check_iso_and_remove(iso_file)

Subscribers

People subscribed via source and target branches

to status/vote changes: