def test_mail_throws_exception(self, mock_mail, mock_Message): mock_mail.send.side_effect = Exception response = send_email("subject", ["recipients"], "html_body") self.assertFalse(response)
def test_function_return_true(self, mock_mail, mock_Message): response = send_email("subject", ["recipients"], "html_body") self.assertTrue(response)
def test_mail_called_with_object_Message(self, mock_mail, mock_Message): send_email("subject", ["recipients"], "html_body") msg = mock_Message("subject", recipients=["recipients"]) mock_mail.send.assert_called_with(msg)
def test_mail_called_once(self, mock_mail, mock_Message): send_email("subject", ["recipients"], "html_body") mock_mail.send.assert_called_once()
def test_Message_called_with(self, mock_Message): send_email("subject", ["recipients"], "html_body") mock_Message.assert_called_with("subject", recipients=["recipients"])
def test_incorrect_email_format(self): with app.test_request_context(): response = send_email("topic", "*****@*****.**", "Kasia") self.assertFalse(response)
def test_correct_data(self): with app.test_request_context(): response = send_email("topic", ["*****@*****.**"], "Kasia") self.assertTrue(response)