Changeset - 5f92bf989968
[Not reviewed]
0 2 0
Jan Kaluza - 10 years ago 2016-01-04 10:33:41
jkaluza@redhat.com
Fix twitter tests
2 files changed with 19 insertions and 4 deletions:
0 comments (0 inline, 0 general)
tests/twitter/twitter_test.cfg
Show inline comments
 
[service]
 
jid = localhostxmpp
 
jid = localhost
 
password = secret
 
server = 0.0.0.0
 
port = 5223
tests/twitter/twitter_test.py
Show inline comments
 
@@ -5,6 +5,8 @@ import subprocess
 
import os
 

	
 
import sleekxmpp
 
from sleekxmpp.xmlstream.matcher import StanzaPath, MatchXPath
 
from sleekxmpp.xmlstream.handler import Callback
 

	
 

	
 
class Responder(sleekxmpp.ClientXMPP):
 
@@ -25,6 +27,7 @@ class Client(sleekxmpp.ClientXMPP):
 
		self.nick = nick
 
		self.add_event_handler("session_start", self.start)
 
		self.add_event_handler("message", self.message)
 
		self.add_event_handler('roster_update', self.roster_update)
 
		self.finished = False
 

	
 
		self.tests = {}
 
@@ -36,7 +39,8 @@ class Client(sleekxmpp.ClientXMPP):
 
		self.tests["friends"] = ["#friends command", False]
 
		self.tests["unfollow"] = ["#unfollow command", False]
 
		self.tests["friends2"] = ["#friends after unfollow command", False]
 
		self.tests["mode1"] = ["#mode 1", False]
 
		self.tests["mode1"] = ["#mode 1 response", False]
 
		self.tests["mode1buddy"] = ["#mode 1 buddy added", False]
 

	
 
		self.status = "timeline"
 
		self.timestamp = int(time.time())
 
@@ -61,17 +65,28 @@ class Client(sleekxmpp.ClientXMPP):
 
			self.tests["follow"][1] = True
 
			self.send_message(mto=msg['from'], mbody="#friends")
 
		elif self.status == "friends" and msg['body'].find("USER LIST") != -1 and msg['body'].find("colinpwheeler") != -1:
 
			self.status = "unfollow"
 
			self.status = "mode1"
 
			self.tests["friends"][1] = True
 
			self.send_message(mto=msg['from'], mbody="#unfollow colinpwheeler")
 
			self.send_message(mto=msg['from'], mbody="#mode 1")
 
		elif self.status == "mode1" and msg['body'] == "Changed mode to 1":
 
			self.tests["mode1"][1] = True
 
		elif self.status == "unfollow" and msg['body'] == "You are not following colinpwheeler anymore":
 
			self.status = "friends2"
 
			self.tests["unfollow"][1] = True
 
			self.send_message(mto=msg['from'], mbody="#friends")
 
		elif self.status == "friends2" and msg['body'].find("USER LIST") != -1 and msg['body'].find("colinpwheeler") == -1:
 
			self.status = "mode1"
 
			self.tests["friends2"][1] = True
 
			self.finished = True
 

	
 
	def roster_update(self, iq):
 
		roster = iq['roster']['items']
 

	
 
		if self.status == "mode1" and roster.has_key("colinpwheeler@localhost"):
 
			self.status = "unfollow"
 
			self.tests["mode1buddy"][1] = True
 
			self.send_message(mto="twitter.com@localhost", mbody="#unfollow colinpwheeler")
 

	
 
	def start(self, event):
 
		self.getRoster()
 
		self.sendPresence()
0 comments (0 inline, 0 general)