def test_start_missing_callbacks(self): bot = toby.Bot("", "") with self.assertRaises(toby.CallbackError): bot.start() bot.set_on_message = on_message with self.assertRaises(toby.CallbackError): bot.start()
def test_not_connected_hooks_off(self): bot = toby.Bot("", "") bot.set_on_connect = on_connect bot.set_on_message = on_message with self.assertRaises(toby.ConnectionError): bot.hooks_off('ack')
def test_not_connected_remove_socket(self): bot = toby.Bot("", "") bot.set_on_connect = on_connect bot.set_on_message = on_message with self.assertRaises(toby.ConnectionError): bot.remove_socket('targetid', 'ack')
def test_not_connected_create_socket(self): bot = toby.Bot("", "") bot.set_on_connect = on_connect bot.set_on_message = on_message with self.assertRaises(toby.ConnectionError): bot.create_socket(False, 'ack')
def test_not_connected_unfollow(self): bot = toby.Bot("", "") bot.set_on_connect = on_connect bot.set_on_message = on_message with self.assertRaises(toby.ConnectionError): bot.unfollow([])
def test_not_connected_send(self): bot = toby.Bot("", "") bot.set_on_connect = on_connect bot.set_on_message = on_message with self.assertRaises(toby.ConnectionError): bot.send(toby.Message("asdf"))
import toby bot = toby.Bot("python", "python") def on_disconnect(): print "disconnected" def on_connect(): print "connected" bot.info("info") #bot.create_bot("", "", "create-bot") #bot.create_socket(False, "create-socket") #bot.send(toby.Message("", {"hello":"world"}, ["toby"], "python")) #bot.follow(["python"]) #bot.unfollow(["python"]) def on_message(message): #print "MESSAGE: " + message #toby.send("got your message #bot1") print message bot.set_on_connect(on_connect) bot.set_on_disconnect(on_disconnect) bot.set_on_message(on_message) bot.start()