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)
Пример #2
0
    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)
Пример #3
0
    def test_invalid_attachment_path_mails(self):
        """
        This functions tests that mail is not sent when attachment path is invalid
        """
        # 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('xyz.txt')

        # verify that the email is sent
        self.assertFalse(email_client.send(self.recipient))
Пример #4
0
    def test_valid_mails(self):
        """
        This function tests that the mail is not sent when email contents are empty
        """
        # 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)

        # verify that the email is sent
        self.assertTrue(email_client.send(self.recipient))
Пример #5
0
    def test_empty_mails(self):
        """
        This function tests that the mail is sent successfully when all the mail contents are proper
        """
        # initialize the email client
        email_client = EmailClient(self.server, self.server_port, self.mail_id,
                                   self.password)

        # set email contents to empty string
        email_client.set_subject('')
        email_client.set_body('')
        email_client.set_signature('')
        email_client.add_attachment('')

        # verify that the email is not sent
        self.assertFalse(email_client.send(self.recipient))
Пример #6
0
    def test_empty_subject_mails(self):
        """
        This function tests that mail is not sent when attachment is present but no subject is added
        """
        # initialize the email client
        email_client = EmailClient(self.server, self.server_port, self.mail_id,
                                   self.password)

        # set subject of email to empty string
        email_client.set_subject('')

        # set email contents to test strings and files
        email_client.set_body(self.test_body)
        email_client.set_signature(self.test_signature)
        email_client.add_attachment(self.test_attachment)

        # verify that the email is sent
        self.assertFalse(email_client.send(self.recipient))
    def test_empty_email(self):
        # Empty Email message content
        # Email subject
        subject = ''
        # Email body
        body = ''
        # Email signature
        signature = ''

        # sending 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)

        # testing
        sent = False
        self.assertEqual(email_client.send(self.__recipient), sent)
    def test_email_client_send(self):
        # Email message content
        # Email subject
        subject = 'Testing'
        # Email body
        body = 'Hi,\n\nI am Kevin. How are you?'
        # Email signature
        signature = '\n\nKind regards,\n{}'.format(self.__username)

        # sending 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')

        # testing
        sent = True
        self.assertEqual(email_client.send(self.__recipient), sent)