1
from mago.test_suite.pidgin import PidginTestSuite
2
from mago.application.pidgin import Pidgin, AccountInfo
3
from ConfigParser import ConfigParser
4
import ldtp, ooldtp, ldtputils
5
from time import sleep, time
6
from shutil import copytree, move
7
from os.path import expanduser
9
class PidginUseApp(Pidgin):
10
def open(self, profile_template='', credentials='',
11
me_account='', buddy_account=''):
12
self.me_account = AccountInfo(me_account, credentials)
13
self.buddy_account = AccountInfo(buddy_account, credentials)
16
self.generate_profile(profile_template, self.me_account.template_args)
18
Pidgin.open(self, False, credentials)
20
print 'wait_for_account_connect?'
21
self.wait_for_account_connect(self.me_account)
22
print 'account connect'
23
self.buddy_login(self.buddy_account)
24
self.wait_for_buddy(self.buddy_account.alias)
27
self.buddy.disconnect()
30
class PidginUseTest(PidginTestSuite):
31
APPLICATION_FACTORY = PidginUseApp
35
def testSendMessage(self, msg=''):
36
buddy_alias = self.application.buddy_account.alias
38
self.application.send_message(
39
self.application.buddy_account.alias, msg)
40
self.application.buddy.wait_for_message(body=msg, timeout=5)
42
def testRecieveMessage(self, msg='', timeout=5):
43
buddy_alias = self.application.buddy_account.alias
45
prev_log = self.application.get_conversation_log(buddy_alias)
47
self.application.buddy.send_message(
48
self.application.me_account.username, msg)
50
for i in xrange(timeout):
51
log = self.application.get_conversation_log(
53
recent_ims = log[len(prev_log):].split('\n')
56
buddy_alias+': ')[-1] == msg:
60
raise AssertionError("Did not recieve matching message",
61
ldtputils.imagecapture())