def handle(self, *args, **kwargs): # Get the binary buffer behind the text one try: self.input_file = self.input_file.detach() except io.UnsupportedOperation: pass msg = message_from_bytes(self.input_file.read()) handler = MailProcessor(msg) handler.process()
def test_move_to_subfolder(self): old_path = self.entry.path new_path = os.path.join(self.queue._get_maildir("subfolder"), self.identifier) self.mkdir(self.queue._get_maildir()) self.create_mail(old_path, subject="move_to_subfolder") self.assertTrue(os.path.exists(old_path)) self.assertFalse(os.path.exists(new_path)) self.entry.move_to_subfolder("subfolder") self.assertFalse(os.path.exists(old_path)) self.assertTrue(os.path.exists(new_path)) with open(new_path, "rb") as f: msg = message_from_bytes(f.read()) self.assertEqual(msg["Subject"], "move_to_subfolder")