Merge lp:~mago-contributors/mago/evolution into lp:~mago-contributors/mago/mago-1.0
- evolution
- Merge into mago-1.0
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~mago-contributors/mago/evolution |
Merge into: | lp:~mago-contributors/mago/mago-1.0 |
Diff against target: | None lines |
To merge this branch: | bzr merge lp:~mago-contributors/mago/evolution |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Nagappan Alagappan | Approve | ||
Review via email:
|
Commit message
Description of the change
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Ara Pulido (ara) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Nagappan Alagappan (nagappan) wrote : | # |
Nice work :)
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Javier Collado (javier.collado) wrote : | # |
Hello,
Thanks for the changes. It's really nice to have new applications such as
evolution included in the mago distribution.
There's one little thing that I would change to make the regular expression that
takes care of extracting the LDTP version more robust, just in case there are
multiple digits in the version string in the future (i.e. ldtp-99.99.99):
< pattern = re.compile(
< m = pattern.
> pattern = re.compile(
> m = pattern.
Best regards,
Javier
Ara Pulido wrote:
> Ara Pulido has proposed merging lp:~mago-contributors/mago/evolution into lp:mago.
>
> Requested reviews:
> Mago Contributors (mago-contributors)
>
> Two major things:
>
> 1) Added basic tests for evolution (and notify-osd / message-indicator cross tests)
> 2) LDTP broke the API in version 1.6, and the imagacapture signature is different. Added a method to keep backwards compatibility.
>
Preview Diff
1 | === modified file '.bzrignore' |
2 | --- .bzrignore 2009-04-01 14:08:43 +0000 |
3 | +++ .bzrignore 2009-06-09 15:24:42 +0000 |
4 | @@ -9,3 +9,4 @@ |
5 | debian/ubuntu-desktop-tests |
6 | python-build-stamp-2.5 |
7 | pidgin/data/credentials.ini |
8 | +evolution/data/credentials.ini |
9 | |
10 | === added directory 'evolution' |
11 | === added directory 'evolution/data' |
12 | === added file 'evolution/data/credentials.ini.example' |
13 | --- evolution/data/credentials.ini.example 1970-01-01 00:00:00 +0000 |
14 | +++ evolution/data/credentials.ini.example 2009-06-10 11:13:16 +0000 |
15 | @@ -0,0 +1,11 @@ |
16 | +# [TEST_POP] |
17 | +# popaccount = thisisatest |
18 | +# popserver = pop.testserver.com |
19 | +# smtpaccount = thisisatest |
20 | +# smtpserver = smtp.testserver.com |
21 | +# emailaddress = thisdoesnotexist@testserver.com |
22 | +# accountname = testing |
23 | +# name = Tester Ubuntu |
24 | +# protocol = POP |
25 | +# password = thisisnotarealpassword |
26 | + |
27 | |
28 | === added directory 'evolution/data/evolution' |
29 | === added directory 'evolution/data/evolution/mail' |
30 | === added file 'evolution/data/evolution/mail/%gconf.xml' |
31 | --- evolution/data/evolution/mail/%gconf.xml 1970-01-01 00:00:00 +0000 |
32 | +++ evolution/data/evolution/mail/%gconf.xml 2009-06-09 15:24:42 +0000 |
33 | @@ -0,0 +1,23 @@ |
34 | +<?xml version="1.0"?> |
35 | +<gconf> |
36 | + <entry name="send_recv_maximized" mtime="1242653573" type="bool" value="false"/> |
37 | + <entry name="send_recv_height" mtime="1242653573" type="int" value="200"/> |
38 | + <entry name="send_recv_width" mtime="1242653573" type="int" value="600"/> |
39 | + <entry name="default_account" mtime="1242371807" type="string"> |
40 | + <stringvalue>1242371745.7630.0@sushirider</stringvalue> |
41 | + </entry> |
42 | + <entry name="signatures" mtime="1242310233" type="list" ltype="string"> |
43 | + <li type="string"> |
44 | + <stringvalue><?xml version="1.0"?> |
45 | +<signature name="Autogenerated" uid="1242310233.29141.18@sushirider" auto="true" format="text/html"/> |
46 | +</stringvalue> |
47 | + </li> |
48 | + </entry> |
49 | + <entry name="accounts" mtime="1244203896" type="list" ltype="string"> |
50 | + <li type="string"> |
51 | + <stringvalue><?xml version="1.0"?> |
52 | + <account name="{accountname}" uid="1242371745.7630.0@sushirider" enabled="true"><identity><name>{name}</name><addr-spec>{emailaddress}</addr-spec><signature uid=""/></identity><source save-passwd="true" keep-on-server="false" auto-check="false" auto-check-timeout="10"><url>pop://{popaccount}@{popserver}/;use_ssl=always</url></source><transport save-passwd="true"><url>smtp://{smtpaccount};auth=PLAIN@{smtpserver}/;use_ssl=when-possible</url></transport><drafts-folder></drafts-folder><sent-folder></sent-folder><auto-cc always="false"><recipients></recipients></auto-cc><auto-bcc always="false"><recipients></recipients></auto-bcc><receipt-policy policy="never"/><pgp encrypt-to-self="false" always-trust="false" always-sign="false" no-imip-sign="false"/><smime sign-default="false" encrypt-default="false" encrypt-to-self="false"/></account> |
53 | + </stringvalue> |
54 | + </li> |
55 | + </entry> |
56 | +</gconf> |
57 | |
58 | === added file 'evolution/evolution_indicator.py' |
59 | --- evolution/evolution_indicator.py 1970-01-01 00:00:00 +0000 |
60 | +++ evolution/evolution_indicator.py 2009-06-16 08:10:06 +0000 |
61 | @@ -0,0 +1,59 @@ |
62 | +from mago.test_suite.evolution import EvolutionTestSuite |
63 | +from mago.application.evolution import Evolution, AccountInfo |
64 | +from mago.check import ScreenshotCompare, FAIL |
65 | +from mago.application.deskex import IndicatorApplet |
66 | + |
67 | +from ConfigParser import ConfigParser |
68 | +import ldtp, ooldtp, ldtputils |
69 | +from time import sleep, time |
70 | +from shutil import copytree, move |
71 | +from os.path import expanduser |
72 | + |
73 | +class EvolutionUseApp(Evolution): |
74 | + def open(self, profile_template='', credentials='', |
75 | + me_account=''): |
76 | + self.me_account = AccountInfo(me_account, credentials) |
77 | + |
78 | + self.backup_config() |
79 | + self.generate_profile(profile_template, self.me_account.template_args) |
80 | + |
81 | + Evolution.open(self, False, credentials) |
82 | + |
83 | +class EvolutionIndicatorTest(EvolutionTestSuite): |
84 | + APPLICATION_FACTORY = EvolutionUseApp |
85 | + def cleanup(self): |
86 | + return |
87 | + |
88 | + def testIndicatorShowsUp(self): |
89 | + indicator = IndicatorApplet() |
90 | + if not indicator.is_indicator_shown("Evolution Mail"): |
91 | + raise AssertionError("The indicator didn't show up", ldtputils.imagecapture()) |
92 | + |
93 | + def testIndicateMyself(self, subject, body, password=''): |
94 | + |
95 | + indicator = IndicatorApplet() |
96 | + no_message = indicator.capture_applet_icon() |
97 | + email = self.application.me_account.template_args['emailaddress'] |
98 | + password = self.application.me_account.template_args['password'] |
99 | + |
100 | + self.application.compose_new_message(email, subject, body) |
101 | + self.application.send_email(subject) |
102 | + |
103 | + # Force sending the email |
104 | + ldtp.wait(5) |
105 | + |
106 | + # Get new messages |
107 | + self.application.send_and_receive(password, True, True) |
108 | + |
109 | + # Check that the applet icon changed |
110 | + with_message = indicator.capture_applet_icon() |
111 | + |
112 | + checker = ScreenshotCompare(no_message, with_message) |
113 | + |
114 | + if checker.perform_test() != FAIL: |
115 | + raise AssertionError('icon did not change.', ldtputils.imagecapture()) |
116 | + |
117 | + |
118 | + |
119 | + |
120 | + |
121 | |
122 | === added file 'evolution/evolution_indicator.xml' |
123 | --- evolution/evolution_indicator.xml 1970-01-01 00:00:00 +0000 |
124 | +++ evolution/evolution_indicator.xml 2009-06-16 08:10:06 +0000 |
125 | @@ -0,0 +1,24 @@ |
126 | +<?xml version="1.0"?> |
127 | +<suite name="evolution indicator"> |
128 | + <class>evolution_indicator.EvolutionIndicatorTest</class> |
129 | + <description> |
130 | + Basic Email messaging and m-i |
131 | + </description> |
132 | + <args> |
133 | + <profile_template>./evolution/data/evolution/mail/</profile_template> |
134 | + <credentials>./evolution/data/credentials.ini</credentials> |
135 | + <me_account>TEST_POP</me_account> |
136 | + </args> |
137 | + <case name="IndicatorShowsTest"> |
138 | + <method>testIndicatorShowsUp</method> |
139 | + <description>Basic checking for applet</description> |
140 | + </case> |
141 | + <case name="BasicSendAndIndicationTest"> |
142 | + <method>testIndicateMyself</method> |
143 | + <description>Send a test to myself and check for indicator-applet to change</description> |
144 | + <args> |
145 | + <subject>Hello World!</subject> |
146 | + <body>This is the first test of my life.</body> |
147 | + </args> |
148 | + </case> |
149 | +</suite> |
150 | |
151 | === added file 'evolution/evolution_messaging.py' |
152 | --- evolution/evolution_messaging.py 1970-01-01 00:00:00 +0000 |
153 | +++ evolution/evolution_messaging.py 2009-06-15 10:58:35 +0000 |
154 | @@ -0,0 +1,53 @@ |
155 | +from mago.test_suite.evolution import EvolutionTestSuite |
156 | +from mago.application.evolution import Evolution, AccountInfo |
157 | +from ConfigParser import ConfigParser |
158 | +import ldtp, ooldtp, ldtputils |
159 | +from time import sleep, time |
160 | +from shutil import copytree, move |
161 | +from os.path import expanduser |
162 | + |
163 | +class EvolutionUseApp(Evolution): |
164 | + def open(self, profile_template='', credentials='', |
165 | + me_account=''): |
166 | + self.me_account = AccountInfo(me_account, credentials) |
167 | + |
168 | + self.backup_config() |
169 | + self.generate_profile(profile_template, self.me_account.template_args) |
170 | + |
171 | + Evolution.open(self, False, credentials) |
172 | + |
173 | +class EvolutionUseTest(EvolutionTestSuite): |
174 | + APPLICATION_FACTORY = EvolutionUseApp |
175 | + def cleanup(self): |
176 | + return |
177 | + |
178 | + def testSendMessageToMyself(self, subject, body, password=''): |
179 | + |
180 | + email = self.application.me_account.template_args['emailaddress'] |
181 | + password = self.application.me_account.template_args['password'] |
182 | + |
183 | + self.application.compose_new_message(email, subject, body) |
184 | + self.application.send_email(subject) |
185 | + # Wait for the message to be sent |
186 | + # TODO: Change to look for the Outbox(1) label. |
187 | + ldtp.wait(10) |
188 | + |
189 | + # Get new messages |
190 | + self.application.send_and_receive(password) |
191 | + |
192 | + # Get the list of messages and check if it was correctly received |
193 | + messages_list = self.application.get_list_messages() |
194 | + |
195 | + found = False |
196 | + for msg in messages_list: |
197 | + if str(msg['subject']) == str(subject): |
198 | + found = True |
199 | + break |
200 | + |
201 | + if not found: |
202 | + raise AssertionError("The message was not correctly received.", |
203 | + ldtputils.imagecapture()) |
204 | + |
205 | + |
206 | + |
207 | + |
208 | |
209 | === added file 'evolution/evolution_messaging.xml' |
210 | --- evolution/evolution_messaging.xml 1970-01-01 00:00:00 +0000 |
211 | +++ evolution/evolution_messaging.xml 2009-06-09 15:24:42 +0000 |
212 | @@ -0,0 +1,20 @@ |
213 | +<?xml version="1.0"?> |
214 | +<suite name="pidgin messaging"> |
215 | + <class>evolution_messaging.EvolutionUseTest</class> |
216 | + <description> |
217 | + Basic Email messaging. |
218 | + </description> |
219 | + <args> |
220 | + <profile_template>./evolution/data/evolution/mail/</profile_template> |
221 | + <credentials>./evolution/data/credentials.ini</credentials> |
222 | + <me_account>TEST_POP</me_account> |
223 | + </args> |
224 | + <case name="BasicSendTest"> |
225 | + <method>testSendMessageToMyself</method> |
226 | + <description>Basic send test</description> |
227 | + <args> |
228 | + <subject>Hello World!</subject> |
229 | + <body>This is the first test of my life.</body> |
230 | + </args> |
231 | + </case> |
232 | +</suite> |
233 | |
234 | === added file 'evolution/evolution_notify.py' |
235 | --- evolution/evolution_notify.py 1970-01-01 00:00:00 +0000 |
236 | +++ evolution/evolution_notify.py 2009-06-15 10:58:35 +0000 |
237 | @@ -0,0 +1,74 @@ |
238 | +from mago.test_suite.evolution import EvolutionTestSuite |
239 | +from mago.application.evolution import Evolution, AccountInfo |
240 | +from mago.check import ScreenshotCompare, FAIL |
241 | +from mago.application.deskex import NotifyOSD |
242 | + |
243 | +from ConfigParser import ConfigParser |
244 | +import ldtp, ooldtp, ldtputils |
245 | +from time import sleep, time |
246 | +from shutil import copytree, move |
247 | +from os.path import expanduser |
248 | + |
249 | +class EvolutionUseApp(Evolution): |
250 | + def open(self, profile_template='', credentials='', |
251 | + me_account=''): |
252 | + self.me_account = AccountInfo(me_account, credentials) |
253 | + |
254 | + self.backup_config() |
255 | + self.generate_profile(profile_template, self.me_account.template_args) |
256 | + |
257 | + Evolution.open(self, False, credentials) |
258 | + |
259 | +class EvolutionNotifyTest(EvolutionTestSuite): |
260 | + APPLICATION_FACTORY = EvolutionUseApp |
261 | + def cleanup(self): |
262 | + return |
263 | + |
264 | + def testNotifyMyself(self, subject, body, oracle, password=''): |
265 | + |
266 | + notify = NotifyOSD() |
267 | + email = self.application.me_account.template_args['emailaddress'] |
268 | + password = self.application.me_account.template_args['password'] |
269 | + |
270 | + self.application.compose_new_message(email, subject, body) |
271 | + self.application.send_email(subject) |
272 | + |
273 | + # Force sending the email |
274 | + ldtp.wait(5) |
275 | + |
276 | + # Get new messages |
277 | + self.application.send_and_receive(password, True, True) |
278 | + |
279 | + # Wait for notification (TODO) |
280 | + elapsed, screeny = notify.grab_image_and_wait("1 New Message", 40) |
281 | + |
282 | + checker = ScreenshotCompare(oracle, screeny) |
283 | + |
284 | + try: |
285 | + passed = checker.perform_test() |
286 | + except Exception, e: |
287 | + checker.calibrate() |
288 | + raise e |
289 | + |
290 | + if passed == FAIL: |
291 | + raise AssertionError('screenshots differ', screeny) |
292 | + |
293 | + |
294 | + # Get the list of messages and check if it was correctly received |
295 | + messages_list = self.application.get_list_messages() |
296 | + |
297 | + found = False |
298 | + for msg in messages_list: |
299 | + if str(msg['subject']) == str(subject): |
300 | + found = True |
301 | + break |
302 | + |
303 | + if not found: |
304 | + raise AssertionError("The message was not correctly received.", |
305 | + ldtputils.imagecapture()) |
306 | + |
307 | + |
308 | + |
309 | + |
310 | + |
311 | + |
312 | |
313 | === added file 'evolution/evolution_notify.xml' |
314 | --- evolution/evolution_notify.xml 1970-01-01 00:00:00 +0000 |
315 | +++ evolution/evolution_notify.xml 2009-06-12 11:56:53 +0000 |
316 | @@ -0,0 +1,21 @@ |
317 | +<?xml version="1.0"?> |
318 | +<suite name="pidgin messaging"> |
319 | + <class>evolution_notify.EvolutionNotifyTest</class> |
320 | + <description> |
321 | + Basic Email messaging and notifications. |
322 | + </description> |
323 | + <args> |
324 | + <profile_template>./evolution/data/evolution/mail/</profile_template> |
325 | + <credentials>./evolution/data/credentials.ini</credentials> |
326 | + <me_account>TEST_POP</me_account> |
327 | + </args> |
328 | + <case name="BasicSendTest"> |
329 | + <method>testNotifyMyself</method> |
330 | + <description>Basic send test and notification</description> |
331 | + <args> |
332 | + <oracle>./evolution/data/one_new_message.png</oracle> |
333 | + <subject>Hello World!</subject> |
334 | + <body>This is the first test of my life.</body> |
335 | + </args> |
336 | + </case> |
337 | +</suite> |
338 | |
339 | === modified file 'indicator-applet/indicator_applet.py' |
340 | --- indicator-applet/indicator_applet.py 2009-06-23 13:26:34 +0000 |
341 | +++ indicator-applet/indicator_applet.py 2009-07-27 11:06:25 +0000 |
342 | @@ -19,8 +19,7 @@ |
343 | self.application.add_server(os.path.abspath(desktop_file)) |
344 | self.application.show_indicator(sender) |
345 | sleep(1) |
346 | - if not ldtp.objectexist(self.application.TOP_PANEL, |
347 | - 'mnu' + sender.replace(' ','')): |
348 | + if not self.application.is_indicator_shown(sender) |
349 | raise AssertionError('indicator did not appear in applet.') |
350 | |
351 | def iconChangeTest(self, desktop_file=None, sender=None): |
352 | |
353 | === modified file 'mago/application/__init__.py' |
354 | --- mago/application/__init__.py 2009-05-26 16:20:12 +0000 |
355 | +++ mago/application/__init__.py 2009-06-15 10:58:35 +0000 |
356 | @@ -3,4 +3,4 @@ |
357 | |
358 | Classes that wrap application functionality to ease their testing |
359 | """ |
360 | -__all__ = ['main', 'gnome', 'ubuntu', 'pidgin'] |
361 | +__all__ = ['main', 'gnome', 'ubuntu', 'pidgin', 'evolution'] |
362 | |
363 | === modified file 'mago/application/deskex.py' |
364 | --- mago/application/deskex.py 2009-07-21 18:20:22 +0000 |
365 | +++ mago/application/deskex.py 2009-07-27 11:06:25 +0000 |
366 | @@ -1,11 +1,12 @@ |
367 | from .main import Application |
368 | -from ..utils import show_desktop |
369 | +from ..utils import show_desktop, get_ldtp_version |
370 | from time import time, sleep |
371 | import tempfile |
372 | import pynotify |
373 | import ldtp, ldtputils |
374 | import os |
375 | import gtk, glib |
376 | +from distutils import version |
377 | |
378 | try: |
379 | import indicate |
380 | @@ -54,14 +55,29 @@ |
381 | |
382 | def capture_applet_icon(self): |
383 | x, y, w, h = ldtp.getobjectsize(self.TOP_PANEL, self.IA_TOPLEVEL) |
384 | - screeny = ldtputils.imagecapture( |
385 | - outFile=tempfile.mktemp('.png', 'ia_'), |
386 | - x=x, y=y, resolution1=w, resolution2=h) |
387 | + |
388 | + ldtp_one_six = version.StrictVersion('1.6.0') |
389 | + ldtp_current = version.StrictVersion(get_ldtp_version()) |
390 | + |
391 | + if ldtp_current < ldtp_one_six: |
392 | + screeny = ldtputils.imagecapture( |
393 | + outFile=tempfile.mktemp('.png', 'ia_'), |
394 | + x=x, y=y, resolution1=w, resolution2=h) |
395 | + else: |
396 | + screeny = ldtputils.imagecapture( |
397 | + outFile=tempfile.mktemp('.png', 'ia_'), |
398 | + x=x, y=y, width=w, height=h) |
399 | + |
400 | return screeny |
401 | |
402 | def select_indicator(self, sender): |
403 | ldtp.selectmenuitem(self.TOP_PANEL, 'mnu' + sender.replace(' ','')) |
404 | |
405 | + def is_indicator_shown(self, sender): |
406 | + return ldtp.objectexist(self.TOP_PANEL, |
407 | + 'mnu' + sender.replace(' ','')) |
408 | + |
409 | + |
410 | def wait_for_indicator_display(self, sender, timeout=5): |
411 | handlers = [] |
412 | displayed = [False] |
413 | @@ -157,16 +173,28 @@ |
414 | n.set_hint("value", value) |
415 | n.show () |
416 | |
417 | - def grab_image_and_wait(self, summary): |
418 | - ldtp.waittillguiexist(summary) |
419 | + def grab_image_and_wait(self, summary, timeOut=30): |
420 | + ldtp.waittillguiexist(summary, guiTimeOut=timeOut) |
421 | start_time = time() |
422 | sleep(1) |
423 | x, y, w, h = ldtp.getwindowsize(summary) |
424 | - screenshot = \ |
425 | - ldtputils.imagecapture(outFile=tempfile.mktemp('.png', 'nosd_'), |
426 | + |
427 | + ldtp_one_six = version.StrictVersion('1.6.0') |
428 | + ldtp_current = version.StrictVersion(get_ldtp_version()) |
429 | + |
430 | + if ldtp_current < ldtp_one_six: |
431 | + screenshot = \ |
432 | + ldtputils.imagecapture(outFile=tempfile.mktemp('.png', 'nosd_'), |
433 | x=x+3, y=y+3, |
434 | resolution1=w-6, |
435 | resolution2=h-6) |
436 | + else: |
437 | + screenshot = \ |
438 | + ldtputils.imagecapture(outFile=tempfile.mktemp('.png', 'nosd_'), |
439 | + x=x+3, y=y+3, |
440 | + width=w-6, |
441 | + height=h-6) |
442 | + |
443 | ldtp.waittillguinotexist(summary) |
444 | end_time = time() - start_time |
445 | self.screenshots.append(screenshot) |
446 | |
447 | === added file 'mago/application/evolution.py' |
448 | --- mago/application/evolution.py 1970-01-01 00:00:00 +0000 |
449 | +++ mago/application/evolution.py 2009-07-27 11:46:59 +0000 |
450 | @@ -0,0 +1,255 @@ |
451 | +from main import Application |
452 | +from ..utils import show_desktop |
453 | +import ldtp, ldtputils, ooldtp |
454 | +import os |
455 | +import gtk, glib |
456 | +import tarfile |
457 | +from shutil import move, rmtree, copytree |
458 | +from ConfigParser import ConfigParser |
459 | +from string import Formatter |
460 | + |
461 | +class AccountInfo(object): |
462 | + |
463 | + def __init__(self, name, credentials): |
464 | + if not isinstance(credentials, ConfigParser): |
465 | + creds_fn = credentials |
466 | + credentials = ConfigParser() |
467 | + credentials.read(creds_fn) |
468 | + self.details = dict(credentials.items(name)) |
469 | + self.name = name |
470 | + |
471 | + def __getattr__(self, name): |
472 | + try: |
473 | + return self.details[name] |
474 | + except KeyError: |
475 | + raise AttributeError |
476 | + |
477 | + @property |
478 | + def template_args(self): |
479 | + args = {} |
480 | + for arg in ('popaccount', 'popserver', 'smtpaccount', 'smtpserver', |
481 | + 'emailaddress', 'accountname', 'name', 'protocol', 'password'): |
482 | + args[arg] = getattr(self, arg) |
483 | + return args |
484 | + |
485 | +class Evolution(Application): |
486 | + """ |
487 | + Evolution application helper class. |
488 | + """ |
489 | + WINDOW = "*-Evolution" |
490 | + LAUNCHER = "evolution" |
491 | + BTN_OK = "OK" |
492 | + |
493 | + # Main window elements |
494 | + BTN_SENDRECEIVE = "btnSend/Receive" |
495 | + DLG_SENDRECEIVE = "dlgSend&ReceiveMail" |
496 | + DLG_ENTER_PASSWORD = "dlgEnterPasswordfor*" |
497 | + TBL_MSG_FOLDERS = 'ttblMailFolderTree' |
498 | + |
499 | + # Compose message constants |
500 | + MNU_COMPOSENEW = "mnuComposeNewMessage" |
501 | + FRM_COMPOSE = "frmComposeMessage" |
502 | + TXT_TO = "txtTo" |
503 | + TXT_SUBJECT = "txtSubject" |
504 | + TXT_BODY = "txt6" |
505 | + BTN_SEND = "btnSend" |
506 | + |
507 | + # Messages treetable |
508 | + MESSAGES = "ttblMessages" |
509 | + STATUS_LBL = "Status" |
510 | + STATUS_INDEX = 0 |
511 | + ATTACH_LBL = "Attachment" |
512 | + ATTACH_INDEX = 1 |
513 | + FLAGGED_LBL = "Flagged" |
514 | + FLAGGED_INDEX = 2 |
515 | + FROM_LBL = "From" |
516 | + FROM_INDEX = 3 |
517 | + SUBJECT_LBL = "Subject" |
518 | + SUBJECT_INDEX = 4 |
519 | + DATE_LBL = "Date" |
520 | + DATE_INDEX = 5 |
521 | + |
522 | + def __init__(self): |
523 | + Application.__init__(self) |
524 | + |
525 | + def open(self, clean_profile=True, credentials=''): |
526 | + """ |
527 | + It saves the old profile (if needed) and |
528 | + set up a new one. After this initial process, |
529 | + it opens the application |
530 | + |
531 | + @type clean_profile: boolean |
532 | + @param clean_profile: True, to back up the old profile and create a |
533 | + new one (default) |
534 | + @type credentials: string |
535 | + @param credentials: Path to the config file with accounts information |
536 | + """ |
537 | + clean_profile = clean_profile not in ('False', '0', False) |
538 | + self.creds_fn = credentials |
539 | + self.credentials = ConfigParser() |
540 | + self.credentials.read(self.creds_fn) |
541 | + |
542 | + if clean_profile: |
543 | + self.backup_config() |
544 | + |
545 | + Application.open(self) |
546 | + |
547 | + def generate_profile(self, profile_template, template_args=None): |
548 | + """ |
549 | + It uses the profile_template and the |
550 | + credentials to build a new profile folder |
551 | + """ |
552 | + |
553 | + conf_folder = '~/.gconf/apps/evolution/mail' |
554 | + os.makedirs(os.path.expanduser(conf_folder)) |
555 | + |
556 | + formatter = Formatter() |
557 | + for fn in os.listdir(profile_template): |
558 | + if os.path.isdir(os.path.join(profile_template, fn)): |
559 | + copytree(os.path.join(profile_template, fn), |
560 | + os.path.join(os.path.expanduser(conf_folder), fn)) |
561 | + continue |
562 | + buf = open(os.path.join(profile_template, fn)).read() |
563 | + f = open(os.path.join(os.path.expanduser(conf_folder), fn), 'w') |
564 | + try: |
565 | + buf = formatter.format(buf, **template_args) |
566 | + except KeyError, e: |
567 | + raise Exception, e |
568 | + f.write(buf) |
569 | + f.close() |
570 | + |
571 | + def compose_new_message(self, to, subject='', body='', account=''): |
572 | + |
573 | + evolution = ooldtp.context(self.WINDOW) |
574 | + mnuComposeNew = evolution.getchild(self.MNU_COMPOSENEW) |
575 | + mnuComposeNew.click() |
576 | + ldtp.waittillguiexist(self.FRM_COMPOSE) |
577 | + compose_window = ooldtp.context(self.FRM_COMPOSE) |
578 | + txtTo = compose_window.getchild(self.TXT_TO) |
579 | + txtTo.settextvalue(to) |
580 | + txtSubject = compose_window.getchild(self.TXT_SUBJECT) |
581 | + txtSubject.settextvalue(subject) |
582 | + |
583 | + # Remap is needed because the frame changes its name |
584 | + self.remap() |
585 | + |
586 | + compose_window = ooldtp.context(subject) |
587 | + |
588 | + txtBody = compose_window.getchild(self.TXT_BODY) |
589 | + txtBody.settextvalue(body) |
590 | + |
591 | + def send_email(self, subject): |
592 | + |
593 | + compose_window = ooldtp.context(subject) |
594 | + btnSend = compose_window.getchild(self.BTN_SEND) |
595 | + btnSend.click() |
596 | + |
597 | + def send_and_receive(self, password='', minimize=False, dont_wait=False): |
598 | + evolution = ooldtp.context(self.WINDOW) |
599 | + btnsr = evolution.getchild(self.BTN_SENDRECEIVE) |
600 | + btnsr.click() |
601 | + ldtp.waittillguiexist(self.DLG_SENDRECEIVE) |
602 | + |
603 | + if minimize: |
604 | + show_desktop(True) |
605 | + |
606 | + if ldtp.waittillguiexist(self.DLG_ENTER_PASSWORD, guiTimeOut=2) == 1: |
607 | + enter_pass_dlg = ooldtp.context(self.DLG_ENTER_PASSWORD) |
608 | + txt_pass = enter_pass_dlg.getchild(role='password_text')[0] |
609 | + txt_pass.settextvalue(password) |
610 | + btn_ok = enter_pass_dlg.getchild(self.BTN_OK) |
611 | + btn_ok.click() |
612 | + if minimize: |
613 | + show_desktop(True) |
614 | + |
615 | + if dont_wait: |
616 | + return |
617 | + |
618 | + ldtp.waittillguinotexist(self.DLG_SENDRECEIVE) |
619 | + |
620 | + |
621 | + def get_list_messages(self, only_unread=False, folder="Inbox"): |
622 | + |
623 | + messages_list = [] |
624 | + |
625 | + self.select_folder(folder) |
626 | + |
627 | + evolution = ooldtp.context(self.WINDOW) |
628 | + messages = evolution.getchild(self.MESSAGES) |
629 | + |
630 | + for i in range(messages.getrowcount()): |
631 | + status = messages.getcellvalue(i, self.STATUS_INDEX) |
632 | + sender = messages.getcellvalue(i, self.FROM_INDEX) |
633 | + subject = messages.getcellvalue(i, self.SUBJECT_INDEX) |
634 | + |
635 | + if not only_unread or status == '0': |
636 | + messages_list.append({'subject':subject,'sender':sender,'status':status}) |
637 | + |
638 | + return messages_list |
639 | + |
640 | + def select_folder(self, folder): |
641 | + evolution = ooldtp.context(self.WINDOW) |
642 | + table_msg = evolution.getchild(self.TBL_MSG_FOLDERS) |
643 | + table_msg.selectrowpartialmatch(folder) |
644 | + |
645 | + def backup_config(self): |
646 | + """ |
647 | + It saves the configuration of Evolution in a file |
648 | + called ~/.evo.bak.tar.gz{.n} |
649 | + |
650 | + It saves the evolution config & messages |
651 | + """ |
652 | + p = os.path.expanduser('~/.evo.bak.tar.gz') |
653 | + backup_path = p |
654 | + i = 2 |
655 | + while os.path.exists(backup_path): |
656 | + backup_path = '%s.%d' % (p, i) |
657 | + i += 1 |
658 | + |
659 | + try: |
660 | + tar = tarfile.open(backup_path, mode='w:gz') |
661 | + evolution_conf = os.path.expanduser('~/.evolution') |
662 | + evolution_gconf = os.path.expanduser('~/.gconf/apps/evolution') |
663 | + |
664 | + if os.path.exists(evolution_conf): |
665 | + tar.add(evolution_conf) |
666 | + rmtree(evolution_conf) |
667 | + if os.path.exists(evolution_gconf): |
668 | + tar.add(evolution_gconf) |
669 | + rmtree(evolution_gconf) |
670 | + tar.close() |
671 | + except IOError: |
672 | + pass |
673 | + else: |
674 | + self.backup_path = backup_path |
675 | + |
676 | + def restore_config(self): |
677 | + """ |
678 | + It deletes the configuration folder and restore then |
679 | + one backed up (at backup_path) |
680 | + """ |
681 | + try: |
682 | + rmtree(os.path.expanduser('~/.evolution')) |
683 | + rmtree(os.path.expanduser('~/.gconf/apps/evolution')) |
684 | + except OSError: |
685 | + pass |
686 | + |
687 | + try: |
688 | + tar = tarfile.open(self.backup_path, mode='r:gz') |
689 | + tar.extractall(os.path.expanduser('/.')) |
690 | + except IOError: |
691 | + traceback.print_exc() |
692 | + |
693 | + |
694 | + |
695 | +if __name__ == "__main__": |
696 | + from time import sleep |
697 | + test = Evolution() |
698 | + #test.open() |
699 | + #subject = "Greetings" |
700 | + #test.compose_new_message("tester.ubuntu@gmail.com", subject, "hey hey") |
701 | + #test.send_email(subject) |
702 | + #test.send_and_receive('testingubuntu') |
703 | + test.backup_config() |
704 | + test.restore_config() |
705 | + # test.close() |
706 | |
707 | === modified file 'mago/test_suite/__init__.py' |
708 | --- mago/test_suite/__init__.py 2009-05-26 16:20:12 +0000 |
709 | +++ mago/test_suite/__init__.py 2009-06-15 10:58:35 +0000 |
710 | @@ -3,4 +3,4 @@ |
711 | |
712 | Test suite classes that implement setup/teardown/cleanup methods |
713 | """ |
714 | -__all__ = ['main', 'gnome', 'ubuntu', 'pidgin'] |
715 | +__all__ = ['main', 'gnome', 'ubuntu', 'pidgin', 'evolution'] |
716 | |
717 | === added file 'mago/test_suite/evolution.py' |
718 | --- mago/test_suite/evolution.py 1970-01-01 00:00:00 +0000 |
719 | +++ mago/test_suite/evolution.py 2009-06-09 15:24:42 +0000 |
720 | @@ -0,0 +1,28 @@ |
721 | +""" |
722 | +gnome module contains the definition of the test suites used for gnome |
723 | +applications |
724 | +""" |
725 | +import ldtp, ooldtp |
726 | +from .main import SingleApplicationTestSuite |
727 | +from ..application.gnome import Application |
728 | +from ..application.evolution import Evolution |
729 | + |
730 | +class EvolutionTestSuite(SingleApplicationTestSuite): |
731 | + """ |
732 | + Default test suite for Evolution |
733 | + """ |
734 | + APPLICATION_FACTORY = Evolution |
735 | + def __init__(self, **kwargs): |
736 | + self.app_args = kwargs |
737 | + SingleApplicationTestSuite.__init__(self) |
738 | + |
739 | + def setup(self): |
740 | + self.application.open(**self.app_args) |
741 | + |
742 | + def teardown(self): |
743 | + self.application.close() |
744 | + |
745 | + def cleanup(self): |
746 | + self.application.close() |
747 | + self.application.open(**self.app_args) |
748 | + |
749 | |
750 | === modified file 'mago/utils.py' |
751 | --- mago/utils.py 2009-06-29 18:46:40 +0000 |
752 | +++ mago/utils.py 2009-07-27 11:06:25 +0000 |
753 | @@ -1,5 +1,7 @@ |
754 | import os |
755 | import gtk, gobject, wnck |
756 | +import subprocess |
757 | +import re |
758 | |
759 | def show_desktop(show): |
760 | def _start_showing(): |
761 | @@ -12,3 +14,13 @@ |
762 | |
763 | def get_system_language(): |
764 | raise NotImplementedError, "not yet..." |
765 | + |
766 | +def get_ldtp_version(): |
767 | + script = subprocess.Popen(['ldtp', '--version'], stdout=subprocess.PIPE) |
768 | + version = script.communicate()[0] |
769 | + pattern = re.compile("ldtp-(\d\.\d\.\d).*") |
770 | + m = pattern.match(version) |
771 | + version = m.group(1) |
772 | + return version |
773 | + |
774 | + |
Two major things:
1) Added basic tests for evolution (and notify-osd / message-indicator cross tests)
2) LDTP broke the API in version 1.6, and the imagacapture signature is different. Added a method to keep backwards compatibility.