def test_email_client_reset(self): # Email message content # Email subject subject = 'Testing Reset Method' # Email body body = 'Email body has not been reset. Please check its functionality.' # Email signature signature = '\n\nKind regards,\[email protected]' # initialising Email email_client = EmailClient(self.__server, self.__port_number, self.__username, self.__password) email_client.set_subject(subject) email_client.set_body(body) email_client.set_signature(signature) email_client.add_attachment('test.txt') # resetting email content email_client.reset_email() # adding Email body new_body = 'Email body has been reset.' email_client.set_body(new_body) # testing sent = True self.assertEqual(email_client.send(self.__recipient), sent)
def test_reset_functionality(self): """ This functions tests that mail contents are reset after calling reset() """ # initialize the email client email_client = EmailClient(self.server, self.server_port, self.mail_id, self.password) # set email contents to test strings and files email_client.set_subject(self.test_subject) email_client.set_body(self.test_body) email_client.set_signature(self.test_signature) email_client.add_attachment(self.test_attachment) # before reset will be true as email will be sent before_reset = email_client.send(self.recipient) # reset the email contents email_client.reset_email() # after reset will be false as email won't be sent as the contents removed after_reset = email_client.send(self.recipient) # compare that both are not equal self.assertNotEqual(before_reset, after_reset)