def test_modified_message(self): """Test if the modified message gets archived correctly""" from fuglu.shared import Suspect import shutil import tempfile tempfilename = tempfile.mktemp( suffix='archive', prefix='fuglu-unittest', dir='/tmp') shutil.copy(TESTDATADIR + '/helloworld.eml', tempfilename) self.tempfiles.append(tempfilename) self.config.set('ArchivePlugin', 'storeoriginal', '0') candidate = ArchivePlugin(self.config) suspect = Suspect( '*****@*****.**', '*****@*****.**', tempfilename) origmessage = suspect.get_source() # modify the mesg msgrep = suspect.get_message_rep() msgrep['X-Changed-Something'] = 'Yes' suspect.setMessageRep(msgrep) filename = candidate.archive(suspect) self.assertTrue(filename != None and filename) self.tempfiles.append(filename) archivedmessage = open(filename, 'r').read() self.assertNotEqual(origmessage.strip(), archivedmessage.strip( )), 'Archived message should have stored modified message'
def test_modified_message(self): """Test if the modified message gets archived correctly""" from fuglu.shared import Suspect import shutil import tempfile tempfilename = tempfile.mktemp(suffix='archive', prefix='fuglu-unittest', dir='/tmp') shutil.copy(TESTDATADIR + '/helloworld.eml', tempfilename) self.tempfiles.append(tempfilename) self.config.set('ArchivePlugin', 'storeoriginal', '0') candidate = ArchivePlugin(self.config) suspect = Suspect('*****@*****.**', '*****@*****.**', tempfilename) origmessage = suspect.get_source() # modify the mesg msgrep = suspect.get_message_rep() msgrep['X-Changed-Something'] = 'Yes' suspect.setMessageRep(msgrep) filename = candidate.archive(suspect) self.assertTrue(filename != None and filename) self.tempfiles.append(filename) archivedmessage = open(filename, 'r').read() self.assertNotEqual(origmessage.strip(), archivedmessage.strip( )), 'Archived message should have stored modified message'