def click_send_later(self): message = EmailMessage(self.sender.login, self.mailToEdit.text(), self.subjectEdit.text(), self.bodyEdit.toPlainText(), self.attachments) datetime_object = datetime.strptime(self.sendDate.text(), '%d.%m %H:%M') if datetime_object is None: self.sendStatus.setText("Bad date format. Enter %d.%m %H:%M") MailSender.save_message(message, datetime_object) self.sendStatus.setText("Saved as {0}".format(filename))
def test_daemon_sending(self): message = EmailMessage(self.login, self.recipient, *self.msg_content) filename = MailSender.save_message(message, datetime.now()) self.assertTrue(os.path.isfile("./" + messages_dir + "/" + filename)) format_str = "python DaemonSender.py {0} {1} {2} {3}" start_string = format_str.format(self.credentials[0], self.credentials[1], self.login, self.password) subprocess.Popen(start_string, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP) self.assertFalse(os.path.isfile(filename))
def test_save_message(self): message = EmailMessage(self.login, self.recipient, *self.msg_content) datetime_object = datetime.now() filename = MailSender.save_message(message, datetime_object) self.assertTrue(os.path.isfile("./" + messages_dir + "/" + filename))