~jtatum/mago/gcalctool

« back to all changes in this revision

Viewing changes to evolution/evolution_notify.py

  • Committer: Eitan Isaacson
  • Date: 2009-08-04 11:17:25 UTC
  • mfrom: (96.1.8 sprint)
  • Revision ID: eitan@ascender.com-20090804111725-mlz3hmeghktpjwvs
mergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from mago.test_suite.evolution import EvolutionTestSuite
 
2
from mago.application.evolution import Evolution, AccountInfo
 
3
from mago.check import ScreenshotCompare, FAIL
 
4
from mago.application.deskex import NotifyOSD
 
5
 
 
6
from ConfigParser import ConfigParser
 
7
import ldtp, ooldtp, ldtputils
 
8
from time import sleep, time
 
9
from shutil import copytree, move
 
10
from os.path import expanduser
 
11
 
 
12
class 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
 
 
22
class 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