From: Kevin C. <ke...@us...> - 2006-02-09 12:40:17
|
Update of /cvsroot/mailmanager/MailManager/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20405/tests Modified Files: testSending.py Log Message: Attachments were lacking sqv_ prefix for sql methods Now have the test suite from 2.0 Test suite code has been modified for 2.1 Now tests attachments Index: testSending.py =================================================================== RCS file: /cvsroot/mailmanager/MailManager/tests/testSending.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- testSending.py 6 Feb 2006 18:22:34 -0000 1.2 +++ testSending.py 9 Feb 2006 12:40:08 -0000 1.3 @@ -92,6 +92,7 @@ self.sendAndHoldTest() self.sendAndCloseTest() self.addNoteTest() + self.attachmentTest() def sendTest(self): @@ -326,7 +327,7 @@ # Check the ticket is now in state hold ticket = self.mmobj.ticket(id=2)[0] - self.failUnless(ticket.status == 'hold') + self.failUnless(ticket.state == 'Hold') def sendAndCloseTest(self): @@ -424,7 +425,7 @@ # Check the ticket is now in state closed ticket = self.mmobj.ticket(id=3)[0] - self.failUnless(ticket.status == 'closed') + self.failUnless(ticket.state == 'Closed') def addNoteTest(self): @@ -477,7 +478,59 @@ + def attachmentTest(self): + """ Checks to see that adding attachments via the web interface works + + At present, this is a bit of a hack. We just add attachments to + our session, call send, and see that they have been added to the + message which was added to the ticket. + + Any error response from the mail server should result in the + user being informed. + """ + # Get the last modified date of the ticket + ticket = self.mmobj.ticket(id=5)[0] + last_modified = self.mmobj.sql.getTicketLastModified( + sqv_ticket_id = ticket.id + )[0].last_modified.strftime('%s') + + attachments = {} + attachments['testfile'] = { + 'filename' : 'testfile', + 'content-type' : 'application/octet-stream', + 'data' : 'blah' + } + + self.request.SESSION.set('attachments', attachments) + + msg_count = self.getMsgCount(ticket.id) + + result = ticket.http_sendReply( + mail_to = 'kev@logicalware.example', + subject = 'Test', + body = 'Test', + body_is_html = 0, + last_modified = last_modified, + REQUEST = self.request, + RESPONSE = self.request.response) + + new_msg_count = self.getMsgCount(ticket.id) + self.failUnless(new_msg_count == msg_count + 1) + + # Successful send, check that a message is added to the database + # and that mail is sent out ok. + msg_count = self.getMsgCount(ticket.id) + + msginfo = self.mmobj.MailHost.messages[-1:][0] + self.failUnless(msginfo['from'] == 'sales@acmewidgets.example') + self.failUnless(msginfo['to'][0] == 'kev@logicalware.example') + self.failUnless('Test' in msginfo['text']) + + self.failUnless('Content-Type: application/octet-stream;' in msginfo['text']) + self.failUnless('name="testfile"' in msginfo['text']) + self.failUnless('content-disposition: attachment;' in msginfo['text']) + self.failUnless('filename="testfile"' in msginfo['text']) def getMsgCount(self, ticket_id): |