-# Copyright 2005 James Bunton <james@delx.cjb.net>
+# Copyright 2005-2006 James Bunton <james@delx.cjb.net>
# Licensed for distribution under the GPL version 2, check COPYING for details
"""
Test cases for msnw (MSN Wrapper)
"""
+# Settings
+TIMEOUT = 30.0 # Connection timeout in seconds
+LOGGING = True
+TWOFILES = False
+FTSENDTEST = False
+FTRECEIVETEST = False
+USER1 = "messengertest1@hotmail.com"
+PASS1 = "hellohello"
+USER2 = "messengertest2@hotmail.com"
+PASS2 = "hellohello"
+
+
+
# Twisted imports
from twisted.internet.defer import Deferred
from twisted.internet import reactor, error
import msn
-# Settings
-TIMEOUT = 30.0 # Connection timeout in seconds
-LOGGING = True
-USER1 = "messengertest1@hotmail.com"
-PASS1 = "hellohello"
-USER2 = "messengertest2@hotmail.com"
-PASS2 = "hellohello"
-
-
-
if LOGGING:
log.startLogging(sys.stdout)
def testConnect(self):
self.doLogins(both=False)
-# testConnect.skip = "True"
+ testConnect.skip = FTRECEIVETEST or FTSENDTEST
def testPurgeContacts(self):
self.doLogins()
self.doPurgeContacts()
-# testPurgeContacts.skip = "True"
+ testPurgeContacts.skip = FTRECEIVETEST or FTSENDTEST
def testAddContacts(self):
self.doLogins()
self.doPurgeContacts()
self.doAddContacts()
-# testAddContacts.skip = "True"
+ testAddContacts.skip = FTRECEIVETEST or FTSENDTEST
def testMessageExchange(self):
self.doLogins()
self.user1.sendMessage(USER2, "Hi user2")
self.loop("Timeout exchanging message.", cond="GOTMESSAGE")
self.failUnless((self.user2.message == (USER1, "Hi user2")), "Failed to transfer message.")
-# testMessageExchange.skip = "True"
+ testMessageExchange.skip = FTRECEIVETEST or FTSENDTEST
def testFileSend(self):
if raw_input("\n\nALERT!!!\n\nPlease connect to account %s and accept the file transfer from %s. When you have received the complete file, send a message back to the client to signal success.\nType ok when you are ready: " % (USER2, USER1)).lower() != "ok":
d = self.user1.sendFile(USER2, "myfile.txt", len(data))
d.addCallback(gotFileSend)
self.loop("Sending file.", cond="GOTMESSAGE", timeout=60*60)
- testFileSend.skip = "True"
+ global TWOFILES
+ if TWOFILES:
+ d = self.user1.sendFile(USER2, "myfile2.txt", len(data))
+ d.addCallback(gotFileSend)
+ self.loop("Sending file.", cond="GOTMESSAGE", timeout=60*60)
+ testFileSend.skip = not FTSENDTEST
def testFileReceive(self):
if raw_input("\n\nALERT!!!\n\nPlease connect to account %s and send a file transfer to %s.\nType ok when you are ready: " % (USER2, USER1)).lower() != "ok":
self.doPurgeContacts(both=False)
self.doAddContacts(both=False)
self.loop("Receiving file.", cond="GOTFILE", timeout=60*60)
- testFileReceive.skip = "True"
+ global TWOFILES
+ if TWOFILES:
+ self.loop("Receiving file.", cond="GOTFILE", timeout=60*60)
+ testFileReceive.skip = not FTRECEIVETEST