Merge lp:~ara/mago/shotwell into lp:~mago-contributors/mago/mago-1.0

Proposed by Ara Pulido
Status: Merged
Merge reported by: Jean-Baptiste Lallement
Merged at revision: not available
Proposed branch: lp:~ara/mago/shotwell
Merge into: lp:~mago-contributors/mago/mago-1.0
Diff against target: 255 lines (+206/-2)
6 files modified
mago/application/shotwell.py (+114/-0)
mago/test_suite/main.py (+2/-2)
mago/test_suite/shotwell.py (+37/-0)
shotwell/README (+20/-0)
shotwell/shotwell_basics.py (+18/-0)
shotwell/shotwell_basics.xml (+15/-0)
To merge this branch: bzr merge lp:~ara/mago/shotwell
Reviewer Review Type Date Requested Status
Jean-Baptiste Lallement Approve
Nagappan Alagappan Approve
Review via email: mp+40065@code.launchpad.net

Description of the change

This change include the shotwell wrapper and a test to import one image.

To post a comment you must log in.
Revision history for this message
Nagappan Alagappan (nagappan) wrote :

Changes looks fine to me. Thanks

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

I've changed 'Wastebasket' (en_GB) to 'Trash' to match the C locale otherwise the test fails.
Note that this test fails in Natty because txtLocation vanished from the 'Open' dialog.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'mago/application/shotwell.py'
2--- mago/application/shotwell.py 1970-01-01 00:00:00 +0000
3+++ mago/application/shotwell.py 2010-11-04 10:33:55 +0000
4@@ -0,0 +1,114 @@
5+PACKAGE = "mago"
6+
7+# -*- coding : utf-8 -*-
8+
9+"""
10+This is the "shotwell" module.
11+
12+This module provides a wrapper for LDTP to make writing Shotwell tests easier.
13+"""
14+import ooldtp
15+import ldtp
16+import os
17+from .main import Application
18+from ..gconfwrapper import GConf
19+from ..cmd import globals
20+import time
21+import gettext
22+import re
23+
24+gettext.install (True)
25+gettext.bindtextdomain (PACKAGE, globals.LOCALE_SHARE)
26+gettext.textdomain (PACKAGE)
27+t = gettext.translation(PACKAGE, globals.LOCALE_SHARE, fallback = True)
28+_ = t.gettext
29+
30+
31+class Shotwell(Application):
32+ """
33+ Shotwell manages the Shotwell application.
34+ """
35+ WINDOW = _("frmShotwell")
36+ LAUNCHER = "shotwell"
37+ MNU_IMPORT_FROM_FOLDER = _("mnuImportFromFolder...")
38+ DLG_IMPORT = _("dlgImportFromFolder")
39+ TXT_LOCATION = _("txtLocation")
40+ BTN_CLOSE = _("btnClose")
41+ BTN_OK = _("btnOK")
42+ MNU_QUIT = _("mnuQuit")
43+ DLG_QUESTION = _("dlgQuestion")
44+ BTN_COPY = _("btnCopyintoLibrary")
45+ BTN_LINK = _("btnCreateLinks")
46+ DLG_INFORMATION = _("dlgInformation")
47+ DLG_WARNING = _("dlgWarning")
48+ LBL_SUCCESSFUL = _("*photosuccessfullyimported")
49+ MNU_SELECTALL = _("mnuSelectAll")
50+ MNU_DELETE = _("mnuMovetoWastebasket")
51+ MNU_EMPTYTRASH = _("mnuEmptyWastebasket")
52+ BTN_ONLYREMOVE = _("btnOnlyRemove")
53+
54+ def __init__(self):
55+ Application.__init__(self)
56+
57+
58+ def import_from_folder(self, path, copy=True):
59+ """
60+ It imports a folder
61+
62+ @type path: string
63+ @param path: The path to the folder to import
64+ @type copy: boolean
65+ @param copy: True, to copy the images. Falso, to just create links
66+
67+ @return int: Number of images successfully imported
68+ """
69+
70+ shotwell = ooldtp.context(self.name)
71+
72+ # Click on the import folder menu item
73+ shotwell.getchild(self.MNU_IMPORT_FROM_FOLDER).selectmenuitem()
74+
75+ # Wait for the dialog
76+ ldtp.waittillguiexist(self.DLG_IMPORT)
77+
78+ # Import the folder
79+ dlgImport = ooldtp.context(self.DLG_IMPORT)
80+ txtLocation = dlgImport.getchild(self.TXT_LOCATION)
81+ txtLocation.settextvalue(path)
82+
83+ # Workaround due to bug in shotwell
84+ ldtp.wait(2)
85+ ldtp.enterstring("<backspace>")
86+
87+ ldtp.wait(2)
88+ # Close the dialog
89+ dlgImport.getchild(self.BTN_OK).click()
90+
91+ ldtp.waittillguiexist(self.DLG_QUESTION)
92+
93+ # Copy the images or create links
94+ question = ooldtp.context(self.DLG_QUESTION)
95+
96+ if copy:
97+ question.getchild(self.BTN_COPY).click()
98+ else:
99+ question.getchild(self.BTN_LINK).click()
100+
101+ ldtp.waittillguiexist(self.DLG_INFORMATION)
102+
103+ dlgInfo = ooldtp.context(self.DLG_INFORMATION)
104+
105+ lblSuccess = dlgInfo.getchild(self.LBL_SUCCESSFUL)
106+ lblSuccess = lblSuccess.gettextvalue()
107+
108+ btn_ok = dlgInfo.getchild(self.BTN_OK)
109+ btn_ok.click()
110+
111+ # Find how many photos were successfully imported
112+ pattern = re.compile("(\d+)")
113+
114+ if (re.match(pattern, lblSuccess)):
115+ return re.match(pattern, lblSuccess).groups()[0]
116+ else:
117+ return 0
118+
119
120=== modified file 'mago/test_suite/main.py'
121--- mago/test_suite/main.py 2009-07-22 18:58:59 +0000
122+++ mago/test_suite/main.py 2010-11-04 10:33:55 +0000
123@@ -4,7 +4,7 @@
124 """
125 from ..application.main import Application
126 from inspect import getsourcefile
127-from os.path import dirname
128+from os.path import dirname, abspath
129
130 class TestSuite:
131 """
132@@ -21,7 +21,7 @@
133 pass
134
135 def get_test_dir(cls):
136- return dirname(getsourcefile(cls))
137+ return dirname(abspath(getsourcefile(cls)))
138 get_test_dir = classmethod(get_test_dir)
139
140
141
142=== added file 'mago/test_suite/shotwell.py'
143--- mago/test_suite/shotwell.py 1970-01-01 00:00:00 +0000
144+++ mago/test_suite/shotwell.py 2010-11-04 10:33:55 +0000
145@@ -0,0 +1,37 @@
146+"""
147+This module contains the definition of the test suite for Shotwell testing.
148+"""
149+import ldtp, ooldtp
150+from .main import SingleApplicationTestSuite
151+from ..application.shotwell import Application, Shotwell
152+
153+class ShotwellTestSuite(SingleApplicationTestSuite):
154+ """
155+ Default test suite for Shotwell
156+ """
157+ APPLICATION_FACTORY = Shotwell
158+ def setup(self):
159+ self.application.open()
160+
161+ def teardown(self):
162+ # Clean the library
163+ shotwell = ooldtp.context(self.application.name)
164+ selectall = shotwell.getchild(self.application.MNU_SELECTALL)
165+ selectall.selectmenuitem()
166+ delete = shotwell.getchild(self.application.MNU_DELETE)
167+ delete.selectmenuitem()
168+ emptytrash = shotwell.getchild(self.application.MNU_EMPTYTRASH)
169+ emptytrash.selectmenuitem()
170+
171+ ldtp.waittillguiexist(self.application.DLG_WARNING)
172+
173+ warning = ooldtp.context(self.application.DLG_WARNING)
174+
175+ onlyremove = warning.getchild(self.application.BTN_ONLYREMOVE)
176+ onlyremove.click()
177+
178+ ldtp.waittillguinotexist(self.application.DLG_WARNING)
179+ self.application.close()
180+
181+ def cleanup(self):
182+ pass
183\ No newline at end of file
184
185=== added directory 'shotwell'
186=== added file 'shotwell/README'
187--- shotwell/README 1970-01-01 00:00:00 +0000
188+++ shotwell/README 2010-11-04 10:33:55 +0000
189@@ -0,0 +1,20 @@
190+SHOTWELL TESTS
191+--------------
192+Tests that verify shotwell basic functionality.
193+
194+Safety
195+------
196+None of these tests touches any configuration or system files. They are safe to run.
197+
198+Configuration
199+-------------
200+An image call test_shotwell.png needs to be inside the data folder
201+
202+Available Tests
203+---------------
204+
205+* GEdit Chains
206+ - Unicode Tests
207+ Test Unicode text saving.
208+ - ASCII Tests
209+ Test ASCII text saving.
210
211=== added directory 'shotwell/data'
212=== added file 'shotwell/data/test_shotwell.png'
213Binary files shotwell/data/test_shotwell.png 1970-01-01 00:00:00 +0000 and shotwell/data/test_shotwell.png 2010-11-04 10:33:55 +0000 differ
214=== added file 'shotwell/shotwell_basics.py'
215--- shotwell/shotwell_basics.py 1970-01-01 00:00:00 +0000
216+++ shotwell/shotwell_basics.py 2010-11-04 10:33:55 +0000
217@@ -0,0 +1,18 @@
218+# -*- coding: utf-8 -*-
219+import os
220+from time import time, gmtime, strftime
221+
222+from mago.test_suite.shotwell import ShotwellTestSuite
223+from mago.check import FileComparison, FAIL
224+
225+class ShotwellBasics(ShotwellTestSuite):
226+ def import_folder(self, path, number):
227+ import_path = os.path.join(self.get_test_dir(), path)
228+ success = self.application.import_from_folder(import_path)
229+
230+ if int(success) != int(number):
231+ raise AssertionError, "The number of successful imported images expected: %s ; got %s" % (number, success)
232+
233+if __name__ == "__main__":
234+ shotwell_test = ShotwellBasics()
235+ shotwell_test.run()
236
237=== added file 'shotwell/shotwell_basics.xml'
238--- shotwell/shotwell_basics.xml 1970-01-01 00:00:00 +0000
239+++ shotwell/shotwell_basics.xml 2010-11-04 10:33:55 +0000
240@@ -0,0 +1,15 @@
241+<?xml version="1.0"?>
242+<suite name="Shotwell Basics">
243+ <class>shotwell_basics.ShotwellBasics</class>
244+ <description>
245+ Tests which verify shotwell basics file functionality.
246+ </description>
247+ <case name="Import Folder">
248+ <method>import_folder</method>
249+ <description>Import Folder.</description>
250+ <args>
251+ <path>data/</path>
252+ <number>1</number>
253+ </args>
254+ </case>
255+</suite>

Subscribers

People subscribed via source and target branches

to status/vote changes: