@@ -19,7 +19,9 @@ def __init__(self, headers, status_code):
1919
2020
2121@mock .patch ("routes.v1.email.email.send_email" )
22- def test_email_send (mock_send_email , client , db ):
22+ @mock .patch ("logger.log.append_log" )
23+ def test_email_send (mock_save_log , mock_send_email , client , db ):
24+ mock_save_log .return_value = "Ok"
2325 sendgrid_response_mock = SendGridResponseMock (
2426 headers = {"x-message-id" : "xvis10203sn" }, status_code = 202
2527 )
@@ -34,25 +36,31 @@ def test_email_send(mock_send_email, client, db):
3436
3537
3638@mock .patch ("routes.v1.email.email.send_email" )
37- def test_email_send_with_sendgrid_unauthorizedexception (mock_send_email , client ):
39+ @mock .patch ("logger.log.append_log" )
40+ def test_email_send_with_sendgrid_unauthorizedexception (mock_save_log , mock_send_email , client ):
41+ mock_save_log .return_value = "Ok"
3842 mock_send_email .side_effect = UnauthorizedException ("Not allowed to access the API" )
3943 response = client .post ("/api/v1/email/send/" , json = read_json ("email_data.json" ))
4044 assert response .status_code == 200
4145 assert response .json () == {"detail" : "Not allowed to access the API" }
4246
4347
4448@mock .patch ("routes.v1.email.email.send_email" )
45- def test_email_send_with_sendgrid_bad_request_exception (mock_send_email , client ):
49+ @mock .patch ("logger.log.append_log" )
50+ def test_email_send_with_sendgrid_bad_request_exception (mock_save_log , mock_send_email , client ):
51+ mock_save_log .return_value = "Ok"
4652 mock_send_email .side_effect = BadRequestException ("Bad request" )
4753 response = client .post ("/api/v1/email/send/" , json = read_json ("email_data.json" ))
4854 assert response .status_code == 200
4955 assert response .json () == {"detail" : "Bad request" }
5056
5157
5258@mock .patch ("routes.v1.email.email.send_email" )
59+ @mock .patch ("logger.log.append_log" )
5360def test_email_send_with_db_duplicate_message_id (
54- mock_send_email , client , message
61+ mock_save_log , mock_send_email , client , message
5562):
63+ mock_save_log .return_value = "Ok"
5664 sendgrid_response_mock = SendGridResponseMock (
5765 headers = {"x-message-id" : "123657ab" }, status_code = 202
5866 )
@@ -61,6 +69,6 @@ def test_email_send_with_db_duplicate_message_id(
6169 assert response .status_code == 200
6270 assert response .json () == {
6371 "detail" : "duplicate key value violates unique constraint "
64- '"ix_message_message_id"\n DETAIL: Key (message_id)=('
65- "123657ab) already exists.\n "
72+ '"ix_message_message_id"\n DETAIL: Key (message_id)=('
73+ "123657ab) already exists.\n "
6674 }
0 commit comments