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

Proposed by Pedro Villavicencio
Status: Merged
Merged at revision: 141
Proposed branch: lp:~pedro/mago/baobab-tests
Merge into: lp:~mago-contributors/mago/mago-1.0
Diff against target: 241 lines (+216/-0)
5 files modified
baobab/README (+20/-0)
baobab/baobab_scans.py (+21/-0)
baobab/baobab_scans.xml (+19/-0)
mago/application/baobab.py (+135/-0)
mago/test_suite/baobab.py (+21/-0)
To merge this branch: bzr merge lp:~pedro/mago/baobab-tests
Reviewer Review Type Date Requested Status
Jean-Baptiste Lallement Approve
Review via email: mp+41073@code.launchpad.net

Description of the change

Baobab tests, so far it does:
  * Scan a given directory.
  * Scan the home folder.
  * Scan the filesystem.

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

looks good. thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'baobab'
2=== added file 'baobab/README'
3--- baobab/README 1970-01-01 00:00:00 +0000
4+++ baobab/README 2010-11-17 17:12:55 +0000
5@@ -0,0 +1,20 @@
6+BAOBAB TESTS
7+=============
8+
9+Safety
10+------
11+
12+None of these tests touches any configuration or system files. They are safe to run.
13+
14+Configuration
15+-------------
16+
17+The tests don't need any special configuration.
18+
19+Available Tests
20+---------------
21+
22+* Baobab Scans:
23+ - Scan a given directory.
24+ - Scan the home folder.
25+ - Scan the filesystem.
26
27=== added file 'baobab/baobab_scans.py'
28--- baobab/baobab_scans.py 1970-01-01 00:00:00 +0000
29+++ baobab/baobab_scans.py 2010-11-17 17:12:55 +0000
30@@ -0,0 +1,21 @@
31+# -*- coding: utf-8 -*-
32+import os
33+from time import time, gmtime, strftime
34+
35+from mago.test_suite.baobab import BaobabTestSuite
36+
37+class BaobabScans(BaobabTestSuite):
38+
39+ def baobab_scan_folder(self):
40+ dir_path = ('%s/' % (os.path.join(self.get_test_dir())))
41+ self.application.baobab_scan_folder(dir_path)
42+
43+ def baobab_scan_home_directory(self):
44+ self.application.baobab_scan_home()
45+
46+ def baobab_scan_filesystem(self):
47+ self.application.baobab_scan_filesystem()
48+
49+if __name__ == "__main__":
50+ baobab_test = BaobabScans()
51+ baobab_test.run()
52
53=== added file 'baobab/baobab_scans.xml'
54--- baobab/baobab_scans.xml 1970-01-01 00:00:00 +0000
55+++ baobab/baobab_scans.xml 2010-11-17 17:12:55 +0000
56@@ -0,0 +1,19 @@
57+<?xml version="1.0"?>
58+<suite name="Application Basics">
59+ <class>baobab_scans.BaobabScans</class>
60+ <description>
61+ Tests which verify Baobab basics file functionality.
62+ </description>
63+ <case name="Scan_Folder">
64+ <method>baobab_scan_folder</method>
65+ <description>Use Baobab to scan a Folder</description>
66+ </case>
67+ <case name="Scan_Home_Directory">
68+ <method>baobab_scan_home_directory</method>
69+ <description>Use Baobab to scan the home directory</description>
70+ </case>
71+ <case name="Scan_Filesystem">
72+ <method>baobab_scan_filesystem</method>
73+ <description>Use Baobab to scan the Filesystem</description>
74+ </case>
75+</suite>
76
77=== added file 'mago/application/baobab.py'
78--- mago/application/baobab.py 1970-01-01 00:00:00 +0000
79+++ mago/application/baobab.py 2010-11-17 17:12:55 +0000
80@@ -0,0 +1,135 @@
81+PACKAGE = "mago"
82+
83+#-*- coding:utf-8 -*-
84+"""
85+This is the "baobab" module.
86+
87+This module provides a wrapper for LDTP to make writing Baobab tests easier.
88+"""
89+import ooldtp
90+import ldtp
91+import os
92+from .main import Application
93+from ..gconfwrapper import GConf
94+from ..cmd import globals
95+import time
96+import gettext
97+
98+gettext.install (True)
99+gettext.bindtextdomain (PACKAGE, globals.LOCALE_SHARE)
100+gettext.textdomain (PACKAGE)
101+t = gettext.translation(PACKAGE, globals.LOCALE_SHARE, fallback = True)
102+_ = t.gettext
103+
104+
105+class Baobab(Application):
106+ """
107+ baobab manages the Baobab application.
108+ """
109+
110+ LAUNCHER = 'baobab'
111+ LAUNCHER_ARGS = []
112+ WINDOW = 'frmDiskUsageAnalyzer'
113+
114+ DLG_SELECTFOLDER = _('dlgSelectFolder')
115+ BTN_REFRESH = _('btnRefresh')
116+ BTN_SCANFILESYSTEM = _('btnScanFilesystem')
117+ BTN_SCANFOLDER = _('btnScanFolder')
118+ BTN_SCANHOME = _('btnScanHome')
119+ BTN_SCANREMOTEFOLDER = _('btnScanRemoteFolder')
120+ BTN_STOP = _('btnStop')
121+ BTN_TYPEAFILENAME = _('tbtnTypeafilename')
122+ MNU_ABOUT = _('mnuAbout')
123+ MNU_COLLAPSEALL = _('mnuCollapseAll')
124+ MNU_CONTENTS = _('mnuContents')
125+ MNU_EMPTY = _('mnuEmpty')
126+ MNU_EMPTY1 = _('mnuEmpty1')
127+ MNU_EMPTY2 = _('mnuEmpty2')
128+ MNU_EMPTY3 = _('mnuEmpty3')
129+ MNU_EXPANDALL = _('mnuExpandAll')
130+ MNU_PREFERENCES = _('mnuPreferences')
131+ MNU_QUIT = _('mnuQuit')
132+ MNU_REFRESH = _('mnuRefresh')
133+ MNU_SCANFILESYSTEM = _('mnuScanFilesystem')
134+ MNU_SCANFOLDER = _('mnuScanFolder')
135+ MNU_SCANHOMEFOLDER = _('mnuScanHomeFolder')
136+ MNU_SCANREMOTEFOLDER = _('mnuScanRemoteFolder')
137+ MNU_STOP = _('mnuStop')
138+ MNU_VIEWASRINGSCHART = _('mnuViewasRingsChart')
139+ MNU_VIEWASTREEMAPCHART = _('mnuViewasTreemapChart')
140+ TXT_LOCATION = _('txtLocation')
141+ CBO_VIEWAS = _('cboViewas*')
142+
143+
144+ def baobab_scan_home(self):
145+ baobab = ooldtp.context(self.name)
146+
147+ #Scan the home folder and wait till the end of the scan.
148+ baobab.getchild(self.MNU_SCANHOMEFOLDER).selectmenuitem()
149+ buttonStop = baobab.getchild(self.BTN_STOP)
150+
151+ while buttonStop.stateenabled():
152+ ldtp.wait()
153+
154+ self.baobab_change_views()
155+ #Scan the home again now this time using the button in the toolbar.
156+ baobab.getchild(self.BTN_SCANHOME).click()
157+
158+ while buttonStop.stateenabled():
159+ ldtp.wait()
160+
161+ self.baobab_change_views()
162+
163+ def baobab_scan_folder(self, path):
164+ baobab = ooldtp.context(self.name)
165+
166+ baobab.getchild(self.BTN_SCANFOLDER).click()
167+
168+ ldtp.waittillguiexist(self.DLG_SELECTFOLDER)
169+
170+ if (ldtp.guiexist(self.DLG_SELECTFOLDER)):
171+ selectFiles = ooldtp.context(self.DLG_SELECTFOLDER)
172+ if not (selectFiles.getchild(self.TXT_LOCATION)):
173+ ldtp.generatekeyevent('<ctrl>l')
174+ textLocation = selectFiles.getchild(self.TXT_LOCATION)
175+ textLocation.settextvalue(path)
176+ ldtp.generatekeyevent('<return>')
177+ ldtp.wait(2)
178+
179+ buttonStop = baobab.getchild(self.BTN_STOP)
180+
181+ while buttonStop.stateenabled():
182+ ldtp.wait()
183+
184+ self.baobab_change_views()
185+
186+ def baobab_scan_filesystem(self):
187+ baobab = ooldtp.context(self.name)
188+
189+ #Scan the filesystem
190+ baobab.getchild(self.MNU_SCANFILESYSTEM).selectmenuitem()
191+ buttonStop = baobab.getchild(self.BTN_STOP)
192+
193+ while buttonStop.stateenabled():
194+ ldtp.wait(2)
195+
196+ #Change the views again to see if that works and we don't get any crash.
197+ self.baobab_change_views()
198+
199+ def baobab_change_views(self):
200+ baobab = ooldtp.context(self.name)
201+
202+ #Change the graph view.
203+ comboView = baobab.getchild(self.CBO_VIEWAS)
204+
205+ for item in comboView.getallitem():
206+ ldtp.wait(2)
207+ comboView.selectitem(item)
208+
209+ #Collapse and expand the tree
210+ baobab.getchild(self.MNU_EXPANDALL).selectmenuitem()
211+ ldtp.wait(2)
212+ baobab.getchild(self.MNU_COLLAPSEALL).selectmenuitem()
213+
214+ def __init__(self):
215+ Application.__init__(self)
216
217=== added file 'mago/test_suite/baobab.py'
218--- mago/test_suite/baobab.py 1970-01-01 00:00:00 +0000
219+++ mago/test_suite/baobab.py 2010-11-17 17:12:55 +0000
220@@ -0,0 +1,21 @@
221+"""
222+This module contains the definition of the test suite for Baobab testing.
223+"""
224+import ldtp, ooldtp
225+from .main import SingleApplicationTestSuite
226+from ..application.baobab import Application, Baobab
227+
228+class BaobabTestSuite(SingleApplicationTestSuite):
229+ """
230+ Default test suite for Baobab
231+ """
232+ APPLICATION_FACTORY = Baobab
233+
234+ def setup(self):
235+ self.application.open()
236+
237+ def teardown(self):
238+ self.application.close()
239+
240+ def cleanup(self):
241+ pass

Subscribers

People subscribed via source and target branches

to status/vote changes: