From 3b6ffdcd542062bed4729b57da1a59580962fbd9 Mon Sep 17 00:00:00 2001 From: MEHRSHAD MIRSHEKARY Date: Thu, 29 Aug 2024 11:25:25 +0330 Subject: [PATCH 1/2] :zap: Update(tests) email_notifier_fixture type annotation Updated type annotation for mock_email_notifier return rype --- django_logging/middleware/request_middleware.py | 2 +- tests/fixtures/email_notifier_fixture.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/django_logging/middleware/request_middleware.py b/django_logging/middleware/request_middleware.py index ba3168a..cd5e8ed 100644 --- a/django_logging/middleware/request_middleware.py +++ b/django_logging/middleware/request_middleware.py @@ -56,7 +56,7 @@ def __call__(self, request: HttpRequest) -> HttpResponse: request.browser_type = user_agent logger.info( - "Request Info: (request_path: %s, user: %s," "\nIP: %s, user_agent: %s)", + "Request Info: (request_path: %s, user: %s,\n IP: %s, user_agent: %s)", request.path, user, ip_address, diff --git a/tests/fixtures/email_notifier_fixture.py b/tests/fixtures/email_notifier_fixture.py index 4f3570c..642cc96 100644 --- a/tests/fixtures/email_notifier_fixture.py +++ b/tests/fixtures/email_notifier_fixture.py @@ -1,4 +1,4 @@ -from typing import Generator +from typing import Generator, Tuple from unittest.mock import MagicMock, patch import pytest @@ -46,7 +46,7 @@ def email_mock_settings() -> Generator[MagicMock, None, None]: @pytest.fixture -def notifier_mock_logger() -> Generator[tuple[MagicMock, MagicMock], None, None]: +def notifier_mock_logger() -> Generator[Tuple[MagicMock, MagicMock], None, None]: """ Fixture to mock the logger used for logging messages. From c164e337598477a945425c691f6c38a3de5e366f Mon Sep 17 00:00:00 2001 From: MEHRSHAD MIRSHEKARY Date: Thu, 29 Aug 2024 11:27:18 +0330 Subject: [PATCH 2/2] :zap: Update(tests) test_email_notifier type annotation Updated return type (tuple) --- tests/utils/test_email_notifier.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/utils/test_email_notifier.py b/tests/utils/test_email_notifier.py index 1cabca8..1efd5ee 100644 --- a/tests/utils/test_email_notifier.py +++ b/tests/utils/test_email_notifier.py @@ -1,6 +1,7 @@ import sys import threading from smtplib import SMTPException +from typing import Tuple from unittest.mock import ANY, MagicMock import pytest @@ -21,7 +22,7 @@ def test_send_email_async_success( self, mock_smtp: MagicMock, email_mock_settings: MagicMock, - notifier_mock_logger: tuple[MagicMock, MagicMock], + notifier_mock_logger: Tuple[MagicMock, MagicMock], ) -> None: """ Test that the send_email_async function successfully sends an email. @@ -91,7 +92,7 @@ def test_send_email_async_failure( self, mock_smtp: MagicMock, email_mock_settings: MagicMock, - notifier_mock_logger: tuple[MagicMock, MagicMock], + notifier_mock_logger: Tuple[MagicMock, MagicMock], ) -> None: """ Test that the send_email_async function handles SMTP failures.