Merge lp:~mago-contributors/mago/evolution into lp:~mago-contributors/mago/mago-1.0

Proposed by Ara Pulido
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
Reviewer Review Type Date Requested Status
Nagappan Alagappan Approve
Review via email: mp+9318@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Ara Pulido (ara) wrote :

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.

Revision history for this message
Nagappan Alagappan (nagappan) wrote :

Nice work :)

review: Approve
Revision history for this message
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("ldtp-(\d\.\d\.\d).*")
< m = pattern.match(version)

> pattern = re.compile("ldtp-(\d+\.\d+\.\d+)")
> m = pattern.search(version)

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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2009-04-01 14:08:43 +0000
+++ .bzrignore 2009-06-09 15:24:42 +0000
@@ -9,3 +9,4 @@
9debian/ubuntu-desktop-tests9debian/ubuntu-desktop-tests
10python-build-stamp-2.510python-build-stamp-2.5
11pidgin/data/credentials.ini11pidgin/data/credentials.ini
12evolution/data/credentials.ini
1213
=== added directory 'evolution'
=== added directory 'evolution/data'
=== added file 'evolution/data/credentials.ini.example'
--- evolution/data/credentials.ini.example 1970-01-01 00:00:00 +0000
+++ evolution/data/credentials.ini.example 2009-06-10 11:13:16 +0000
@@ -0,0 +1,11 @@
1# [TEST_POP]
2# popaccount = thisisatest
3# popserver = pop.testserver.com
4# smtpaccount = thisisatest
5# smtpserver = smtp.testserver.com
6# emailaddress = thisdoesnotexist@testserver.com
7# accountname = testing
8# name = Tester Ubuntu
9# protocol = POP
10# password = thisisnotarealpassword
11
012
=== added directory 'evolution/data/evolution'
=== added directory 'evolution/data/evolution/mail'
=== added file 'evolution/data/evolution/mail/%gconf.xml'
--- evolution/data/evolution/mail/%gconf.xml 1970-01-01 00:00:00 +0000
+++ evolution/data/evolution/mail/%gconf.xml 2009-06-09 15:24:42 +0000
@@ -0,0 +1,23 @@
1<?xml version="1.0"?>
2<gconf>
3 <entry name="send_recv_maximized" mtime="1242653573" type="bool" value="false"/>
4 <entry name="send_recv_height" mtime="1242653573" type="int" value="200"/>
5 <entry name="send_recv_width" mtime="1242653573" type="int" value="600"/>
6 <entry name="default_account" mtime="1242371807" type="string">
7 <stringvalue>1242371745.7630.0@sushirider</stringvalue>
8 </entry>
9 <entry name="signatures" mtime="1242310233" type="list" ltype="string">
10 <li type="string">
11 <stringvalue>&lt;?xml version=&quot;1.0&quot;?&gt;
12&lt;signature name=&quot;Autogenerated&quot; uid=&quot;1242310233.29141.18@sushirider&quot; auto=&quot;true&quot; format=&quot;text/html&quot;/&gt;
13</stringvalue>
14 </li>
15 </entry>
16 <entry name="accounts" mtime="1244203896" type="list" ltype="string">
17 <li type="string">
18 <stringvalue>&lt;?xml version=&quot;1.0&quot;?&gt;
19 &lt;account name=&quot;{accountname}&quot; uid=&quot;1242371745.7630.0@sushirider&quot; enabled=&quot;true&quot;&gt;&lt;identity&gt;&lt;name&gt;{name}&lt;/name&gt;&lt;addr-spec&gt;{emailaddress}&lt;/addr-spec&gt;&lt;signature uid=&quot;&quot;/&gt;&lt;/identity&gt;&lt;source save-passwd=&quot;true&quot; keep-on-server=&quot;false&quot; auto-check=&quot;false&quot; auto-check-timeout=&quot;10&quot;&gt;&lt;url&gt;pop://{popaccount}@{popserver}/;use_ssl=always&lt;/url&gt;&lt;/source&gt;&lt;transport save-passwd=&quot;true&quot;&gt;&lt;url&gt;smtp://{smtpaccount};auth=PLAIN@{smtpserver}/;use_ssl=when-possible&lt;/url&gt;&lt;/transport&gt;&lt;drafts-folder&gt;&lt;/drafts-folder&gt;&lt;sent-folder&gt;&lt;/sent-folder&gt;&lt;auto-cc always=&quot;false&quot;&gt;&lt;recipients&gt;&lt;/recipients&gt;&lt;/auto-cc&gt;&lt;auto-bcc always=&quot;false&quot;&gt;&lt;recipients&gt;&lt;/recipients&gt;&lt;/auto-bcc&gt;&lt;receipt-policy policy=&quot;never&quot;/&gt;&lt;pgp encrypt-to-self=&quot;false&quot; always-trust=&quot;false&quot; always-sign=&quot;false&quot; no-imip-sign=&quot;false&quot;/&gt;&lt;smime sign-default=&quot;false&quot; encrypt-default=&quot;false&quot; encrypt-to-self=&quot;false&quot;/&gt;&lt;/account&gt;
20 </stringvalue>
21 </li>
22 </entry>
23</gconf>
024
=== added file 'evolution/evolution_indicator.py'
--- evolution/evolution_indicator.py 1970-01-01 00:00:00 +0000
+++ evolution/evolution_indicator.py 2009-06-16 08:10:06 +0000
@@ -0,0 +1,59 @@
1from mago.test_suite.evolution import EvolutionTestSuite
2from mago.application.evolution import Evolution, AccountInfo
3from mago.check import ScreenshotCompare, FAIL
4from mago.application.deskex import IndicatorApplet
5
6from ConfigParser import ConfigParser
7import ldtp, ooldtp, ldtputils
8from time import sleep, time
9from shutil import copytree, move
10from os.path import expanduser
11
12class EvolutionUseApp(Evolution):
13 def open(self, profile_template='', credentials='',
14 me_account=''):
15 self.me_account = AccountInfo(me_account, credentials)
16
17 self.backup_config()
18 self.generate_profile(profile_template, self.me_account.template_args)
19
20 Evolution.open(self, False, credentials)
21
22class EvolutionIndicatorTest(EvolutionTestSuite):
23 APPLICATION_FACTORY = EvolutionUseApp
24 def cleanup(self):
25 return
26
27 def testIndicatorShowsUp(self):
28 indicator = IndicatorApplet()
29 if not indicator.is_indicator_shown("Evolution Mail"):
30 raise AssertionError("The indicator didn't show up", ldtputils.imagecapture())
31
32 def testIndicateMyself(self, subject, body, password=''):
33
34 indicator = IndicatorApplet()
35 no_message = indicator.capture_applet_icon()
36 email = self.application.me_account.template_args['emailaddress']
37 password = self.application.me_account.template_args['password']
38
39 self.application.compose_new_message(email, subject, body)
40 self.application.send_email(subject)
41
42 # Force sending the email
43 ldtp.wait(5)
44
45 # Get new messages
46 self.application.send_and_receive(password, True, True)
47
48 # Check that the applet icon changed
49 with_message = indicator.capture_applet_icon()
50
51 checker = ScreenshotCompare(no_message, with_message)
52
53 if checker.perform_test() != FAIL:
54 raise AssertionError('icon did not change.', ldtputils.imagecapture())
55
56
57
58
59
060
=== added file 'evolution/evolution_indicator.xml'
--- evolution/evolution_indicator.xml 1970-01-01 00:00:00 +0000
+++ evolution/evolution_indicator.xml 2009-06-16 08:10:06 +0000
@@ -0,0 +1,24 @@
1<?xml version="1.0"?>
2<suite name="evolution indicator">
3 <class>evolution_indicator.EvolutionIndicatorTest</class>
4 <description>
5 Basic Email messaging and m-i
6 </description>
7 <args>
8 <profile_template>./evolution/data/evolution/mail/</profile_template>
9 <credentials>./evolution/data/credentials.ini</credentials>
10 <me_account>TEST_POP</me_account>
11 </args>
12 <case name="IndicatorShowsTest">
13 <method>testIndicatorShowsUp</method>
14 <description>Basic checking for applet</description>
15 </case>
16 <case name="BasicSendAndIndicationTest">
17 <method>testIndicateMyself</method>
18 <description>Send a test to myself and check for indicator-applet to change</description>
19 <args>
20 <subject>Hello World!</subject>
21 <body>This is the first test of my life.</body>
22 </args>
23 </case>
24</suite>
025
=== added file 'evolution/evolution_messaging.py'
--- evolution/evolution_messaging.py 1970-01-01 00:00:00 +0000
+++ evolution/evolution_messaging.py 2009-06-15 10:58:35 +0000
@@ -0,0 +1,53 @@
1from mago.test_suite.evolution import EvolutionTestSuite
2from mago.application.evolution import Evolution, AccountInfo
3from ConfigParser import ConfigParser
4import ldtp, ooldtp, ldtputils
5from time import sleep, time
6from shutil import copytree, move
7from os.path import expanduser
8
9class EvolutionUseApp(Evolution):
10 def open(self, profile_template='', credentials='',
11 me_account=''):
12 self.me_account = AccountInfo(me_account, credentials)
13
14 self.backup_config()
15 self.generate_profile(profile_template, self.me_account.template_args)
16
17 Evolution.open(self, False, credentials)
18
19class EvolutionUseTest(EvolutionTestSuite):
20 APPLICATION_FACTORY = EvolutionUseApp
21 def cleanup(self):
22 return
23
24 def testSendMessageToMyself(self, subject, body, password=''):
25
26 email = self.application.me_account.template_args['emailaddress']
27 password = self.application.me_account.template_args['password']
28
29 self.application.compose_new_message(email, subject, body)
30 self.application.send_email(subject)
31 # Wait for the message to be sent
32 # TODO: Change to look for the Outbox(1) label.
33 ldtp.wait(10)
34
35 # Get new messages
36 self.application.send_and_receive(password)
37
38 # Get the list of messages and check if it was correctly received
39 messages_list = self.application.get_list_messages()
40
41 found = False
42 for msg in messages_list:
43 if str(msg['subject']) == str(subject):
44 found = True
45 break
46
47 if not found:
48 raise AssertionError("The message was not correctly received.",
49 ldtputils.imagecapture())
50
51
52
53
054
=== added file 'evolution/evolution_messaging.xml'
--- evolution/evolution_messaging.xml 1970-01-01 00:00:00 +0000
+++ evolution/evolution_messaging.xml 2009-06-09 15:24:42 +0000
@@ -0,0 +1,20 @@
1<?xml version="1.0"?>
2<suite name="pidgin messaging">
3 <class>evolution_messaging.EvolutionUseTest</class>
4 <description>
5 Basic Email messaging.
6 </description>
7 <args>
8 <profile_template>./evolution/data/evolution/mail/</profile_template>
9 <credentials>./evolution/data/credentials.ini</credentials>
10 <me_account>TEST_POP</me_account>
11 </args>
12 <case name="BasicSendTest">
13 <method>testSendMessageToMyself</method>
14 <description>Basic send test</description>
15 <args>
16 <subject>Hello World!</subject>
17 <body>This is the first test of my life.</body>
18 </args>
19 </case>
20</suite>
021
=== added file 'evolution/evolution_notify.py'
--- evolution/evolution_notify.py 1970-01-01 00:00:00 +0000
+++ evolution/evolution_notify.py 2009-06-15 10:58:35 +0000
@@ -0,0 +1,74 @@
1from mago.test_suite.evolution import EvolutionTestSuite
2from mago.application.evolution import Evolution, AccountInfo
3from mago.check import ScreenshotCompare, FAIL
4from mago.application.deskex import NotifyOSD
5
6from ConfigParser import ConfigParser
7import ldtp, ooldtp, ldtputils
8from time import sleep, time
9from shutil import copytree, move
10from os.path import expanduser
11
12class EvolutionUseApp(Evolution):
13 def open(self, profile_template='', credentials='',
14 me_account=''):
15 self.me_account = AccountInfo(me_account, credentials)
16
17 self.backup_config()
18 self.generate_profile(profile_template, self.me_account.template_args)
19
20 Evolution.open(self, False, credentials)
21
22class EvolutionNotifyTest(EvolutionTestSuite):
23 APPLICATION_FACTORY = EvolutionUseApp
24 def cleanup(self):
25 return
26
27 def testNotifyMyself(self, subject, body, oracle, password=''):
28
29 notify = NotifyOSD()
30 email = self.application.me_account.template_args['emailaddress']
31 password = self.application.me_account.template_args['password']
32
33 self.application.compose_new_message(email, subject, body)
34 self.application.send_email(subject)
35
36 # Force sending the email
37 ldtp.wait(5)
38
39 # Get new messages
40 self.application.send_and_receive(password, True, True)
41
42 # Wait for notification (TODO)
43 elapsed, screeny = notify.grab_image_and_wait("1 New Message", 40)
44
45 checker = ScreenshotCompare(oracle, screeny)
46
47 try:
48 passed = checker.perform_test()
49 except Exception, e:
50 checker.calibrate()
51 raise e
52
53 if passed == FAIL:
54 raise AssertionError('screenshots differ', screeny)
55
56
57 # Get the list of messages and check if it was correctly received
58 messages_list = self.application.get_list_messages()
59
60 found = False
61 for msg in messages_list:
62 if str(msg['subject']) == str(subject):
63 found = True
64 break
65
66 if not found:
67 raise AssertionError("The message was not correctly received.",
68 ldtputils.imagecapture())
69
70
71
72
73
74
075
=== added file 'evolution/evolution_notify.xml'
--- evolution/evolution_notify.xml 1970-01-01 00:00:00 +0000
+++ evolution/evolution_notify.xml 2009-06-12 11:56:53 +0000
@@ -0,0 +1,21 @@
1<?xml version="1.0"?>
2<suite name="pidgin messaging">
3 <class>evolution_notify.EvolutionNotifyTest</class>
4 <description>
5 Basic Email messaging and notifications.
6 </description>
7 <args>
8 <profile_template>./evolution/data/evolution/mail/</profile_template>
9 <credentials>./evolution/data/credentials.ini</credentials>
10 <me_account>TEST_POP</me_account>
11 </args>
12 <case name="BasicSendTest">
13 <method>testNotifyMyself</method>
14 <description>Basic send test and notification</description>
15 <args>
16 <oracle>./evolution/data/one_new_message.png</oracle>
17 <subject>Hello World!</subject>
18 <body>This is the first test of my life.</body>
19 </args>
20 </case>
21</suite>
022
=== modified file 'indicator-applet/indicator_applet.py'
--- indicator-applet/indicator_applet.py 2009-06-23 13:26:34 +0000
+++ indicator-applet/indicator_applet.py 2009-07-27 11:06:25 +0000
@@ -19,8 +19,7 @@
19 self.application.add_server(os.path.abspath(desktop_file))19 self.application.add_server(os.path.abspath(desktop_file))
20 self.application.show_indicator(sender)20 self.application.show_indicator(sender)
21 sleep(1)21 sleep(1)
22 if not ldtp.objectexist(self.application.TOP_PANEL, 22 if not self.application.is_indicator_shown(sender)
23 'mnu' + sender.replace(' ','')):
24 raise AssertionError('indicator did not appear in applet.')23 raise AssertionError('indicator did not appear in applet.')
2524
26 def iconChangeTest(self, desktop_file=None, sender=None):25 def iconChangeTest(self, desktop_file=None, sender=None):
2726
=== modified file 'mago/application/__init__.py'
--- mago/application/__init__.py 2009-05-26 16:20:12 +0000
+++ mago/application/__init__.py 2009-06-15 10:58:35 +0000
@@ -3,4 +3,4 @@
33
4Classes that wrap application functionality to ease their testing4Classes that wrap application functionality to ease their testing
5"""5"""
6__all__ = ['main', 'gnome', 'ubuntu', 'pidgin']6__all__ = ['main', 'gnome', 'ubuntu', 'pidgin', 'evolution']
77
=== modified file 'mago/application/deskex.py'
--- mago/application/deskex.py 2009-07-21 18:20:22 +0000
+++ mago/application/deskex.py 2009-07-27 11:06:25 +0000
@@ -1,11 +1,12 @@
1from .main import Application1from .main import Application
2from ..utils import show_desktop2from ..utils import show_desktop, get_ldtp_version
3from time import time, sleep3from time import time, sleep
4import tempfile4import tempfile
5import pynotify5import pynotify
6import ldtp, ldtputils6import ldtp, ldtputils
7import os7import os
8import gtk, glib8import gtk, glib
9from distutils import version
910
10try:11try:
11 import indicate12 import indicate
@@ -54,14 +55,29 @@
5455
55 def capture_applet_icon(self):56 def capture_applet_icon(self):
56 x, y, w, h = ldtp.getobjectsize(self.TOP_PANEL, self.IA_TOPLEVEL)57 x, y, w, h = ldtp.getobjectsize(self.TOP_PANEL, self.IA_TOPLEVEL)
57 screeny = ldtputils.imagecapture(58
58 outFile=tempfile.mktemp('.png', 'ia_'),59 ldtp_one_six = version.StrictVersion('1.6.0')
59 x=x, y=y, resolution1=w, resolution2=h) 60 ldtp_current = version.StrictVersion(get_ldtp_version())
61
62 if ldtp_current < ldtp_one_six:
63 screeny = ldtputils.imagecapture(
64 outFile=tempfile.mktemp('.png', 'ia_'),
65 x=x, y=y, resolution1=w, resolution2=h)
66 else:
67 screeny = ldtputils.imagecapture(
68 outFile=tempfile.mktemp('.png', 'ia_'),
69 x=x, y=y, width=w, height=h)
70
60 return screeny71 return screeny
6172
62 def select_indicator(self, sender):73 def select_indicator(self, sender):
63 ldtp.selectmenuitem(self.TOP_PANEL, 'mnu' + sender.replace(' ',''))74 ldtp.selectmenuitem(self.TOP_PANEL, 'mnu' + sender.replace(' ',''))
6475
76 def is_indicator_shown(self, sender):
77 return ldtp.objectexist(self.TOP_PANEL,
78 'mnu' + sender.replace(' ',''))
79
80
65 def wait_for_indicator_display(self, sender, timeout=5):81 def wait_for_indicator_display(self, sender, timeout=5):
66 handlers = []82 handlers = []
67 displayed = [False]83 displayed = [False]
@@ -157,16 +173,28 @@
157 n.set_hint("value", value)173 n.set_hint("value", value)
158 n.show ()174 n.show ()
159175
160 def grab_image_and_wait(self, summary):176 def grab_image_and_wait(self, summary, timeOut=30):
161 ldtp.waittillguiexist(summary)177 ldtp.waittillguiexist(summary, guiTimeOut=timeOut)
162 start_time = time()178 start_time = time()
163 sleep(1)179 sleep(1)
164 x, y, w, h = ldtp.getwindowsize(summary)180 x, y, w, h = ldtp.getwindowsize(summary)
165 screenshot = \181
166 ldtputils.imagecapture(outFile=tempfile.mktemp('.png', 'nosd_'),182 ldtp_one_six = version.StrictVersion('1.6.0')
183 ldtp_current = version.StrictVersion(get_ldtp_version())
184
185 if ldtp_current < ldtp_one_six:
186 screenshot = \
187 ldtputils.imagecapture(outFile=tempfile.mktemp('.png', 'nosd_'),
167 x=x+3, y=y+3, 188 x=x+3, y=y+3,
168 resolution1=w-6, 189 resolution1=w-6,
169 resolution2=h-6)190 resolution2=h-6)
191 else:
192 screenshot = \
193 ldtputils.imagecapture(outFile=tempfile.mktemp('.png', 'nosd_'),
194 x=x+3, y=y+3,
195 width=w-6,
196 height=h-6)
197
170 ldtp.waittillguinotexist(summary)198 ldtp.waittillguinotexist(summary)
171 end_time = time() - start_time199 end_time = time() - start_time
172 self.screenshots.append(screenshot)200 self.screenshots.append(screenshot)
173201
=== added file 'mago/application/evolution.py'
--- mago/application/evolution.py 1970-01-01 00:00:00 +0000
+++ mago/application/evolution.py 2009-07-27 11:46:59 +0000
@@ -0,0 +1,255 @@
1from main import Application
2from ..utils import show_desktop
3import ldtp, ldtputils, ooldtp
4import os
5import gtk, glib
6import tarfile
7from shutil import move, rmtree, copytree
8from ConfigParser import ConfigParser
9from string import Formatter
10
11class AccountInfo(object):
12
13 def __init__(self, name, credentials):
14 if not isinstance(credentials, ConfigParser):
15 creds_fn = credentials
16 credentials = ConfigParser()
17 credentials.read(creds_fn)
18 self.details = dict(credentials.items(name))
19 self.name = name
20
21 def __getattr__(self, name):
22 try:
23 return self.details[name]
24 except KeyError:
25 raise AttributeError
26
27 @property
28 def template_args(self):
29 args = {}
30 for arg in ('popaccount', 'popserver', 'smtpaccount', 'smtpserver',
31 'emailaddress', 'accountname', 'name', 'protocol', 'password'):
32 args[arg] = getattr(self, arg)
33 return args
34
35class Evolution(Application):
36 """
37 Evolution application helper class.
38 """
39 WINDOW = "*-Evolution"
40 LAUNCHER = "evolution"
41 BTN_OK = "OK"
42
43 # Main window elements
44 BTN_SENDRECEIVE = "btnSend/Receive"
45 DLG_SENDRECEIVE = "dlgSend&ReceiveMail"
46 DLG_ENTER_PASSWORD = "dlgEnterPasswordfor*"
47 TBL_MSG_FOLDERS = 'ttblMailFolderTree'
48
49 # Compose message constants
50 MNU_COMPOSENEW = "mnuComposeNewMessage"
51 FRM_COMPOSE = "frmComposeMessage"
52 TXT_TO = "txtTo"
53 TXT_SUBJECT = "txtSubject"
54 TXT_BODY = "txt6"
55 BTN_SEND = "btnSend"
56
57 # Messages treetable
58 MESSAGES = "ttblMessages"
59 STATUS_LBL = "Status"
60 STATUS_INDEX = 0
61 ATTACH_LBL = "Attachment"
62 ATTACH_INDEX = 1
63 FLAGGED_LBL = "Flagged"
64 FLAGGED_INDEX = 2
65 FROM_LBL = "From"
66 FROM_INDEX = 3
67 SUBJECT_LBL = "Subject"
68 SUBJECT_INDEX = 4
69 DATE_LBL = "Date"
70 DATE_INDEX = 5
71
72 def __init__(self):
73 Application.__init__(self)
74
75 def open(self, clean_profile=True, credentials=''):
76 """
77 It saves the old profile (if needed) and
78 set up a new one. After this initial process,
79 it opens the application
80
81 @type clean_profile: boolean
82 @param clean_profile: True, to back up the old profile and create a
83 new one (default)
84 @type credentials: string
85 @param credentials: Path to the config file with accounts information
86 """
87 clean_profile = clean_profile not in ('False', '0', False)
88 self.creds_fn = credentials
89 self.credentials = ConfigParser()
90 self.credentials.read(self.creds_fn)
91
92 if clean_profile:
93 self.backup_config()
94
95 Application.open(self)
96
97 def generate_profile(self, profile_template, template_args=None):
98 """
99 It uses the profile_template and the
100 credentials to build a new profile folder
101 """
102
103 conf_folder = '~/.gconf/apps/evolution/mail'
104 os.makedirs(os.path.expanduser(conf_folder))
105
106 formatter = Formatter()
107 for fn in os.listdir(profile_template):
108 if os.path.isdir(os.path.join(profile_template, fn)):
109 copytree(os.path.join(profile_template, fn),
110 os.path.join(os.path.expanduser(conf_folder), fn))
111 continue
112 buf = open(os.path.join(profile_template, fn)).read()
113 f = open(os.path.join(os.path.expanduser(conf_folder), fn), 'w')
114 try:
115 buf = formatter.format(buf, **template_args)
116 except KeyError, e:
117 raise Exception, e
118 f.write(buf)
119 f.close()
120
121 def compose_new_message(self, to, subject='', body='', account=''):
122
123 evolution = ooldtp.context(self.WINDOW)
124 mnuComposeNew = evolution.getchild(self.MNU_COMPOSENEW)
125 mnuComposeNew.click()
126 ldtp.waittillguiexist(self.FRM_COMPOSE)
127 compose_window = ooldtp.context(self.FRM_COMPOSE)
128 txtTo = compose_window.getchild(self.TXT_TO)
129 txtTo.settextvalue(to)
130 txtSubject = compose_window.getchild(self.TXT_SUBJECT)
131 txtSubject.settextvalue(subject)
132
133 # Remap is needed because the frame changes its name
134 self.remap()
135
136 compose_window = ooldtp.context(subject)
137
138 txtBody = compose_window.getchild(self.TXT_BODY)
139 txtBody.settextvalue(body)
140
141 def send_email(self, subject):
142
143 compose_window = ooldtp.context(subject)
144 btnSend = compose_window.getchild(self.BTN_SEND)
145 btnSend.click()
146
147 def send_and_receive(self, password='', minimize=False, dont_wait=False):
148 evolution = ooldtp.context(self.WINDOW)
149 btnsr = evolution.getchild(self.BTN_SENDRECEIVE)
150 btnsr.click()
151 ldtp.waittillguiexist(self.DLG_SENDRECEIVE)
152
153 if minimize:
154 show_desktop(True)
155
156 if ldtp.waittillguiexist(self.DLG_ENTER_PASSWORD, guiTimeOut=2) == 1:
157 enter_pass_dlg = ooldtp.context(self.DLG_ENTER_PASSWORD)
158 txt_pass = enter_pass_dlg.getchild(role='password_text')[0]
159 txt_pass.settextvalue(password)
160 btn_ok = enter_pass_dlg.getchild(self.BTN_OK)
161 btn_ok.click()
162 if minimize:
163 show_desktop(True)
164
165 if dont_wait:
166 return
167
168 ldtp.waittillguinotexist(self.DLG_SENDRECEIVE)
169
170
171 def get_list_messages(self, only_unread=False, folder="Inbox"):
172
173 messages_list = []
174
175 self.select_folder(folder)
176
177 evolution = ooldtp.context(self.WINDOW)
178 messages = evolution.getchild(self.MESSAGES)
179
180 for i in range(messages.getrowcount()):
181 status = messages.getcellvalue(i, self.STATUS_INDEX)
182 sender = messages.getcellvalue(i, self.FROM_INDEX)
183 subject = messages.getcellvalue(i, self.SUBJECT_INDEX)
184
185 if not only_unread or status == '0':
186 messages_list.append({'subject':subject,'sender':sender,'status':status})
187
188 return messages_list
189
190 def select_folder(self, folder):
191 evolution = ooldtp.context(self.WINDOW)
192 table_msg = evolution.getchild(self.TBL_MSG_FOLDERS)
193 table_msg.selectrowpartialmatch(folder)
194
195 def backup_config(self):
196 """
197 It saves the configuration of Evolution in a file
198 called ~/.evo.bak.tar.gz{.n}
199
200 It saves the evolution config & messages
201 """
202 p = os.path.expanduser('~/.evo.bak.tar.gz')
203 backup_path = p
204 i = 2
205 while os.path.exists(backup_path):
206 backup_path = '%s.%d' % (p, i)
207 i += 1
208
209 try:
210 tar = tarfile.open(backup_path, mode='w:gz')
211 evolution_conf = os.path.expanduser('~/.evolution')
212 evolution_gconf = os.path.expanduser('~/.gconf/apps/evolution')
213
214 if os.path.exists(evolution_conf):
215 tar.add(evolution_conf)
216 rmtree(evolution_conf)
217 if os.path.exists(evolution_gconf):
218 tar.add(evolution_gconf)
219 rmtree(evolution_gconf)
220 tar.close()
221 except IOError:
222 pass
223 else:
224 self.backup_path = backup_path
225
226 def restore_config(self):
227 """
228 It deletes the configuration folder and restore then
229 one backed up (at backup_path)
230 """
231 try:
232 rmtree(os.path.expanduser('~/.evolution'))
233 rmtree(os.path.expanduser('~/.gconf/apps/evolution'))
234 except OSError:
235 pass
236
237 try:
238 tar = tarfile.open(self.backup_path, mode='r:gz')
239 tar.extractall(os.path.expanduser('/.'))
240 except IOError:
241 traceback.print_exc()
242
243
244
245if __name__ == "__main__":
246 from time import sleep
247 test = Evolution()
248 #test.open()
249 #subject = "Greetings"
250 #test.compose_new_message("tester.ubuntu@gmail.com", subject, "hey hey")
251 #test.send_email(subject)
252 #test.send_and_receive('testingubuntu')
253 test.backup_config()
254 test.restore_config()
255 # test.close()
0256
=== modified file 'mago/test_suite/__init__.py'
--- mago/test_suite/__init__.py 2009-05-26 16:20:12 +0000
+++ mago/test_suite/__init__.py 2009-06-15 10:58:35 +0000
@@ -3,4 +3,4 @@
33
4Test suite classes that implement setup/teardown/cleanup methods4Test suite classes that implement setup/teardown/cleanup methods
5"""5"""
6__all__ = ['main', 'gnome', 'ubuntu', 'pidgin']6__all__ = ['main', 'gnome', 'ubuntu', 'pidgin', 'evolution']
77
=== added file 'mago/test_suite/evolution.py'
--- mago/test_suite/evolution.py 1970-01-01 00:00:00 +0000
+++ mago/test_suite/evolution.py 2009-06-09 15:24:42 +0000
@@ -0,0 +1,28 @@
1"""
2gnome module contains the definition of the test suites used for gnome
3applications
4"""
5import ldtp, ooldtp
6from .main import SingleApplicationTestSuite
7from ..application.gnome import Application
8from ..application.evolution import Evolution
9
10class EvolutionTestSuite(SingleApplicationTestSuite):
11 """
12 Default test suite for Evolution
13 """
14 APPLICATION_FACTORY = Evolution
15 def __init__(self, **kwargs):
16 self.app_args = kwargs
17 SingleApplicationTestSuite.__init__(self)
18
19 def setup(self):
20 self.application.open(**self.app_args)
21
22 def teardown(self):
23 self.application.close()
24
25 def cleanup(self):
26 self.application.close()
27 self.application.open(**self.app_args)
28
029
=== modified file 'mago/utils.py'
--- mago/utils.py 2009-06-29 18:46:40 +0000
+++ mago/utils.py 2009-07-27 11:06:25 +0000
@@ -1,5 +1,7 @@
1import os1import os
2import gtk, gobject, wnck2import gtk, gobject, wnck
3import subprocess
4import re
35
4def show_desktop(show):6def show_desktop(show):
5 def _start_showing():7 def _start_showing():
@@ -12,3 +14,13 @@
1214
13def get_system_language():15def get_system_language():
14 raise NotImplementedError, "not yet..."16 raise NotImplementedError, "not yet..."
17
18def get_ldtp_version():
19 script = subprocess.Popen(['ldtp', '--version'], stdout=subprocess.PIPE)
20 version = script.communicate()[0]
21 pattern = re.compile("ldtp-(\d\.\d\.\d).*")
22 m = pattern.match(version)
23 version = m.group(1)
24 return version
25
26

Subscribers

People subscribed via source and target branches

to status/vote changes: