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
7
class PidginNewAccountTest(PidginTestSuite):
8
def __init__(self, credentials):
9
PidginTestSuite.__init__(
10
self, clean_profile=True, credentials=credentials)
12
def testNewAccount(self, account_name=None):
14
if not self.application.credentials.has_section(account_name):
16
'no %s account configured in %s' % (account_name,
17
self.application.creds_fn))
19
account_info = AccountInfo(account_name, self.application.credentials)
21
ldtp.waittillguiexist(self.application.DLG_ACCOUNTS,
22
self.application.BTN_ADD)
24
dlg_accounts = ooldtp.context(self.application.DLG_ACCOUNTS)
26
btn_add = dlg_accounts.getchild(self.application.BTN_ADD)
30
ldtp.waittillguiexist(self.application.DLG_ADD_ACCOUNT)
32
dlg_add_account = ooldtp.context(self.application.DLG_ADD_ACCOUNT)
34
cbo_protocol = dlg_add_account.getchild(self.application.CBO_PROTOCOL)
36
cbo_protocol.comboselect(account_info.protocol)
40
ldtp.remap(self.application.DLG_ADD_ACCOUNT)
42
details = account_info.details
44
for name, value in details.items():
45
if name not in ('username', 'domain', 'resource', 'password'):
47
dlg_add_account.settextvalue('txt%s' % name.capitalize(), value)
49
btn_add = dlg_add_account.getchild(self.application.BTN_ADD)
55
last_row = dlg_accounts.getrowcount(self.application.TBL_ACCOUNTS) - 1
57
print 'last_row', last_row
60
raise AssertionError("no new accounts in view.",
61
ldtputils.imagecapture())
63
username = account_info.username_and_domain
66
dlg_accounts.getcellvalue(self.application.TBL_ACCOUNTS, 0, 1)
68
# Don't know why but first getcellvalue() always fails..
73
cellval = dlg_accounts.getcellvalue(self.application.TBL_ACCOUNTS, 0, 1)
74
if cellval != username:
76
'wrong username in accounts view (expected %s, got %s)' % \
79
cellval = dlg_accounts.getcellvalue(self.application.TBL_ACCOUNTS, 0, 2)
80
if cellval != account_info.protocol:
82
'wrong protocol in accounts view (expected %s, got %s)' % \
83
(account_info.protocol, cellval))
86
raise AssertionError(','.join(fails)+'.', ldtputils.imagecapture())
88
# TODO: Should we test successful connection too?