From 40eb4e43cd05bed1d95c3be789b0c07391c7a0f7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 14 Feb 2026 00:17:16 +0000 Subject: [PATCH] style: apply ruff auto-fix - Auto-formatted code with ruff format - Applied ruff linting fixes with --fix Co-authored-by: github-actions[bot] --- tests/test_api_google_drive_coverage.py | 39 +++++++++---------------- tests/test_settings_service_coverage.py | 5 ++-- 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/tests/test_api_google_drive_coverage.py b/tests/test_api_google_drive_coverage.py index b2569db5..75e092dd 100644 --- a/tests/test_api_google_drive_coverage.py +++ b/tests/test_api_google_drive_coverage.py @@ -6,11 +6,10 @@ Focuses on: - Token retrieval error paths """ -from datetime import datetime, timedelta -from unittest.mock import MagicMock, Mock, patch +from datetime import timedelta +from unittest.mock import MagicMock, patch import pytest -from fastapi import HTTPException from fastapi.testclient import TestClient @@ -209,7 +208,7 @@ class TestSaveGoogleDriveSettings: "client_id": "new_id", "client_secret": "new_secret", "folder_id": "folder123", - } + }, ) assert response.status_code == 200 @@ -223,10 +222,7 @@ class TestSaveGoogleDriveSettings: """Test saving with only refresh_token (minimal required field).""" mock_exists.return_value = False - response = client.post( - "/api/google-drive/save-settings", - data={"refresh_token": "new_token"} - ) + response = client.post("/api/google-drive/save-settings", data={"refresh_token": "new_token"}) assert response.status_code == 200 data = response.json() @@ -239,10 +235,7 @@ class TestSaveGoogleDriveSettings: """Test saving when .env file write fails but continues with in-memory update.""" mock_exists.return_value = True - response = client.post( - "/api/google-drive/save-settings", - data={"refresh_token": "new_token"} - ) + response = client.post("/api/google-drive/save-settings", data={"refresh_token": "new_token"}) # Should succeed (in-memory update) even if file write fails assert response.status_code == 200 @@ -250,47 +243,43 @@ class TestSaveGoogleDriveSettings: assert data["status"] == "success" -@pytest.mark.unit +@pytest.mark.unit class TestHelperFunctions: """Test helper functions in google_drive module.""" - + def test_format_time_remaining_expired(self): """Test format_time_remaining with negative timedelta.""" from app.api.google_drive import format_time_remaining - from datetime import timedelta - + # Expired time delta = timedelta(seconds=-1) result = format_time_remaining(delta) assert result == "Expired" - + def test_format_time_remaining_days(self): """Test format_time_remaining with days.""" from app.api.google_drive import format_time_remaining - from datetime import timedelta - + # 2 days, 3 hours delta = timedelta(days=2, hours=3) result = format_time_remaining(delta) assert "2 days" in result assert "3 hours" in result - + def test_format_time_remaining_hours_only(self): """Test format_time_remaining with hours but no days.""" from app.api.google_drive import format_time_remaining - from datetime import timedelta - + # 5 hours, 30 minutes delta = timedelta(hours=5, minutes=30) result = format_time_remaining(delta) assert "5 hours" in result assert "30 minutes" in result - + def test_format_time_remaining_singular_units(self): """Test format_time_remaining with singular units.""" from app.api.google_drive import format_time_remaining - from datetime import timedelta - + # 1 day, 1 hour delta = timedelta(days=1, hours=1) result = format_time_remaining(delta) diff --git a/tests/test_settings_service_coverage.py b/tests/test_settings_service_coverage.py index b502872a..7730f7ce 100644 --- a/tests/test_settings_service_coverage.py +++ b/tests/test_settings_service_coverage.py @@ -8,10 +8,11 @@ Focuses on: - Mixed encryption states """ +from unittest.mock import patch + import pytest from sqlalchemy.exc import SQLAlchemyError from sqlalchemy.orm import Session -from unittest.mock import Mock, patch, MagicMock from app.models import ApplicationSettings from app.utils.settings_service import ( @@ -321,7 +322,7 @@ class TestSettingsValidationEdgeCases: # However, session_secret is marked required in metadata, so empty string should fail # Let's check if session_secret is actually required from app.utils.settings_service import get_setting_metadata - + metadata = get_setting_metadata("session_secret") if metadata.get("required", False): # If required, empty string should fail