]> code.delx.au - pymsnt/blobdiff - src/tlib/msn/test_msnw.py
P2P file transfers should be more reliable.
[pymsnt] / src / tlib / msn / test_msnw.py
index feb78203ea0c656172cac8778923ac4756637663..97579db908d546f966bae9923d7c5cabec21f9b2 100644 (file)
@@ -1,10 +1,23 @@
-# 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
@@ -19,16 +32,6 @@ import msnw
 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)
 
@@ -167,18 +170,18 @@ class BasicTests(unittest.TestCase, TestsUtil):
 
        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()
@@ -187,7 +190,7 @@ class BasicTests(unittest.TestCase, TestsUtil):
                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":
@@ -212,7 +215,12 @@ class BasicTests(unittest.TestCase, TestsUtil):
                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":
@@ -241,5 +249,8 @@ class BasicTests(unittest.TestCase, TestsUtil):
                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