+ 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":
+ raise unittest.SkipTest("User didn't type 'ok'")
+
+ def fileFinished(data):
+ #filename = "/tmp/msn" + str(random.randint(1000, 9999)) + ".dat"
+ filename = "/tmp/MSNFILE_" + self.fileReceive.filename
+ f = open(filename, "w")
+ f.write(data)
+ f.close()
+ print "Got file!", filename
+ # Terminate the loop in a little, let them send the BYE before
+ # we drop the connection
+ def wait():
+ self.done = "GOTFILE"
+ reactor.callLater(5, wait)
+
+ def gotFileReceive(fileReceive):
+ buffer = msn.StringBuffer(fileFinished)
+ self.fileReceive = fileReceive
+ self.fileReceive.accept(buffer)
+
+ self.doLogins(both=False)
+ self.user1.gotFileReceive = gotFileReceive
+ self.doPurgeContacts(both=False)
+ self.doAddContacts(both=False)
+ self.loop("Receiving file.", cond="GOTFILE", timeout=60*60)
+ global TWOFILES
+ if TWOFILES:
+ self.loop("Receiving file.", cond="GOTFILE", timeout=60*60)
+ testFileReceive.skip = not FTRECEIVETEST