From bf0151340d2e1f7a2a3a6543f52ad100762fa492 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Feb 2026 17:53:30 +0000 Subject: [PATCH] fix: resolve DeepSource issues in test files - Use lazy % formatting in logging (PYL-W1203) in test_external_integrations.py - Add @staticmethod to 3 methods not using self (PYL-R0201) - Remove unused mock_media and mock_smtp variables (PYL-W0612) - Remove redundant local reimports of upload_to_webdav (PYL-W0404) Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> --- tests/test_external_integrations.py | 15 +++++++++------ tests/test_upload_tasks.py | 4 ++-- tests/test_upload_webdav_comprehensive.py | 4 ---- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/tests/test_external_integrations.py b/tests/test_external_integrations.py index 25781195..669fd9aa 100644 --- a/tests/test_external_integrations.py +++ b/tests/test_external_integrations.py @@ -323,7 +323,7 @@ class TestS3Integration: try: s3_client.delete_object(Bucket=bucket, Key=s3_key) except Exception as exc: - logger.warning(f"Failed to clean up S3 test object {s3_key}: {exc}") + logger.warning("Failed to clean up S3 test object %s: %s", s3_key, exc) # --------------------------------------------------------------------------- @@ -383,7 +383,7 @@ class TestDropboxIntegration: try: dbx.files_delete_v2(remote_path) except Exception as exc: - logger.warning(f"Failed to clean up Dropbox test file {remote_path}: {exc}") + logger.warning("Failed to clean up Dropbox test file %s: %s", remote_path, exc) # --------------------------------------------------------------------------- @@ -474,7 +474,7 @@ class TestOneDriveIntegration: timeout=30, ) except Exception as exc: - logger.warning(f"Failed to clean up OneDrive test file {filename}: {exc}") + logger.warning("Failed to clean up OneDrive test file %s: %s", filename, exc) # --------------------------------------------------------------------------- @@ -488,7 +488,8 @@ class TestOneDriveIntegration: class TestAuthentikIntegration: """Verify Authentik / OpenID Connect discovery endpoint is reachable.""" - def test_oidc_discovery_endpoint(self, original_env: dict) -> None: + @staticmethod + def test_oidc_discovery_endpoint(original_env: dict) -> None: """Validate that the OIDC discovery URL returns a valid JSON document.""" import requests @@ -502,7 +503,8 @@ class TestAuthentikIntegration: assert "authorization_endpoint" in data, "OIDC response missing 'authorization_endpoint'" assert "token_endpoint" in data, "OIDC response missing 'token_endpoint'" - def test_authentik_client_credentials_present(self, original_env: dict) -> None: + @staticmethod + def test_authentik_client_credentials_present(original_env: dict) -> None: """Validate that Authentik client credentials are configured alongside the config URL.""" client_id = original_env.get("AUTHENTIK_CLIENT_ID") client_secret = original_env.get("AUTHENTIK_CLIENT_SECRET") @@ -529,7 +531,8 @@ class TestFullOCRMetadataPipeline: Celery or Redis, by calling the service APIs directly. """ - def test_ocr_then_metadata_extraction(self, original_env: dict) -> None: + @staticmethod + def test_ocr_then_metadata_extraction(original_env: dict) -> None: """Generate a PDF, OCR it with Azure, then extract metadata with OpenAI.""" import re diff --git a/tests/test_upload_tasks.py b/tests/test_upload_tasks.py index 2de25a9b..e9175585 100644 --- a/tests/test_upload_tasks.py +++ b/tests/test_upload_tasks.py @@ -327,7 +327,7 @@ def test_upload_to_google_drive_accepts_file_id(sample_text_file): """Test that upload_to_google_drive accepts file_id parameter.""" with ( patch("app.tasks.upload_to_google_drive.get_google_drive_service") as mock_service, - patch("app.tasks.upload_to_google_drive.MediaFileUpload") as mock_media, + patch("app.tasks.upload_to_google_drive.MediaFileUpload"), patch("app.tasks.upload_to_google_drive.extract_metadata_from_file") as mock_metadata, patch("app.tasks.upload_to_google_drive.settings") as mock_settings, patch("app.tasks.upload_to_google_drive.log_task_progress"), @@ -364,7 +364,7 @@ def test_upload_to_email_accepts_file_id(sample_text_file): """Test that upload_to_email accepts file_id parameter.""" with ( patch("app.tasks.upload_to_email.settings") as mock_settings, - patch("app.tasks.upload_to_email.smtplib.SMTP") as mock_smtp, + patch("app.tasks.upload_to_email.smtplib.SMTP"), patch("app.tasks.upload_to_email.get_email_template") as mock_template, patch("app.tasks.upload_to_email.extract_metadata_from_file") as mock_metadata, patch("app.tasks.upload_to_email.log_task_progress"), diff --git a/tests/test_upload_webdav_comprehensive.py b/tests/test_upload_webdav_comprehensive.py index 2a78d1e7..131ec5cd 100644 --- a/tests/test_upload_webdav_comprehensive.py +++ b/tests/test_upload_webdav_comprehensive.py @@ -532,14 +532,10 @@ class TestUploadToWebDAV: def test_module_importable(self): """Test that upload_to_webdav module is importable.""" - from app.tasks.upload_to_webdav import upload_to_webdav - assert callable(upload_to_webdav) def test_task_has_retry_configuration(self): """Test that the task has retry configuration from BaseTaskWithRetry.""" - from app.tasks.upload_to_webdav import upload_to_webdav - # BaseTaskWithRetry should provide retry configuration assert hasattr(upload_to_webdav, "max_retries") # BaseTaskWithRetry configures 3 retries