~ubuntu-branches/ubuntu/vivid/mago/vivid

« back to all changes in this revision

Viewing changes to pidgin/pidgin_new_account.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2011-02-08 13:32:13 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110208133213-m1og7ey0m990chg6
Tags: 0.3+bzr20-0ubuntu1
* debian/rules:
  - updated to debhelper 7
  - use dh_python2 instead of python-central
* debian/pycompat:
  - removed, no longer needed
* debian/control:
  - dropped cdbs and python-central dependencies
* bzr snapshot of the current trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from mago.test_suite.pidgin import PidginTestSuite
2
 
from mago.application.pidgin import AccountInfo
3
 
from ConfigParser import ConfigParser
4
 
import ldtp, ooldtp, ldtputils
5
 
from time import sleep
6
 
 
7
 
class PidginNewAccountTest(PidginTestSuite):
8
 
    def __init__(self, credentials):
9
 
        PidginTestSuite.__init__(
10
 
            self, clean_profile=True, credentials=credentials)
11
 
 
12
 
    def testNewAccount(self, account_name=None):
13
 
 
14
 
        if not self.application.credentials.has_section(account_name):
15
 
            raise Exception(
16
 
                'no %s account configured in %s' % (account_name, 
17
 
                                                    self.application.creds_fn))
18
 
 
19
 
        account_info = AccountInfo(account_name, self.application.credentials)
20
 
 
21
 
        ldtp.waittillguiexist(self.application.DLG_ACCOUNTS, 
22
 
                              self.application.BTN_ADD)
23
 
 
24
 
        dlg_accounts = ooldtp.context(self.application.DLG_ACCOUNTS)
25
 
 
26
 
        btn_add = dlg_accounts.getchild(self.application.BTN_ADD)
27
 
 
28
 
        btn_add.click()
29
 
 
30
 
        ldtp.waittillguiexist(self.application.DLG_ADD_ACCOUNT)
31
 
 
32
 
        dlg_add_account = ooldtp.context(self.application.DLG_ADD_ACCOUNT)
33
 
 
34
 
        cbo_protocol = dlg_add_account.getchild(self.application.CBO_PROTOCOL)
35
 
 
36
 
        cbo_protocol.comboselect(account_info.protocol)
37
 
 
38
 
        sleep(1)
39
 
 
40
 
        ldtp.remap(self.application.DLG_ADD_ACCOUNT)
41
 
 
42
 
        details = account_info.details
43
 
 
44
 
        for name, value in details.items():
45
 
            if name not in ('username', 'domain', 'resource', 'password'):
46
 
                continue
47
 
            dlg_add_account.settextvalue('txt%s' % name.capitalize(), value)
48
 
 
49
 
        btn_add = dlg_add_account.getchild(self.application.BTN_ADD)
50
 
 
51
 
        btn_add.click()
52
 
 
53
 
        sleep(1)
54
 
 
55
 
        last_row = dlg_accounts.getrowcount(self.application.TBL_ACCOUNTS) - 1
56
 
 
57
 
        print 'last_row', last_row
58
 
 
59
 
        if last_row < 0:
60
 
            raise AssertionError("no new accounts in view.", 
61
 
                                 ldtputils.imagecapture())
62
 
 
63
 
        username = account_info.username_and_domain
64
 
 
65
 
        try:
66
 
            dlg_accounts.getcellvalue(self.application.TBL_ACCOUNTS, 0, 1)
67
 
        except:
68
 
            # Don't know why but first getcellvalue() always fails..
69
 
            pass
70
 
        
71
 
        fails = []
72
 
 
73
 
        cellval = dlg_accounts.getcellvalue(self.application.TBL_ACCOUNTS, 0, 1)
74
 
        if cellval != username:
75
 
            fails.append(
76
 
                'wrong username in accounts view (expected %s, got %s)' % \
77
 
                    (username, cellval))
78
 
 
79
 
        cellval = dlg_accounts.getcellvalue(self.application.TBL_ACCOUNTS, 0, 2)
80
 
        if  cellval != account_info.protocol:
81
 
            fails.append(
82
 
                'wrong protocol in accounts view (expected %s, got %s)' % \
83
 
                    (account_info.protocol, cellval))
84
 
 
85
 
        if fails:
86
 
            raise AssertionError(','.join(fails)+'.', ldtputils.imagecapture())
87
 
 
88
 
        # TODO: Should we test successful connection too?