fix: Add missing commas in function calls and improve code formatting
Some checks failed
Backend CI / lint (push) Failing after 4m51s
Backend CI / test (push) Successful in 4m19s

This commit is contained in:
JSC
2025-08-12 23:37:38 +02:00
parent d3d7edb287
commit f094fbf140
18 changed files with 135 additions and 133 deletions

View File

@@ -1,5 +1,6 @@
"""Tests for authentication endpoints."""
from datetime import UTC
from typing import Any
from unittest.mock import patch
@@ -495,7 +496,7 @@ class TestAuthEndpoints:
response = await test_client.post(
"/api/v1/auth/refresh",
cookies={"refresh_token": "valid_refresh_token"}
cookies={"refresh_token": "valid_refresh_token"},
)
assert response.status_code == 200
@@ -520,7 +521,7 @@ class TestAuthEndpoints:
response = await test_client.post(
"/api/v1/auth/refresh",
cookies={"refresh_token": "valid_refresh_token"}
cookies={"refresh_token": "valid_refresh_token"},
)
assert response.status_code == 500
@@ -536,7 +537,7 @@ class TestAuthEndpoints:
"""Test OAuth token exchange with invalid code."""
response = await test_client.post(
"/api/v1/auth/exchange-oauth-token",
json={"code": "invalid_code"}
json={"code": "invalid_code"},
)
assert response.status_code == 400
@@ -565,7 +566,7 @@ class TestAuthEndpoints:
is_active=test_user.is_active,
)
mock_update.return_value = updated_user
# Mock the user_to_response to return UserResponse format
from app.schemas.auth import UserResponse
mock_user_to_response.return_value = UserResponse(
@@ -589,7 +590,7 @@ class TestAuthEndpoints:
response = await test_client.patch(
"/api/v1/auth/me",
json={"name": "Updated Name"},
cookies=auth_cookies
cookies=auth_cookies,
)
assert response.status_code == 200
@@ -601,7 +602,7 @@ class TestAuthEndpoints:
"""Test update profile without authentication."""
response = await test_client.patch(
"/api/v1/auth/me",
json={"name": "Updated Name"}
json={"name": "Updated Name"},
)
assert response.status_code == 401
@@ -621,9 +622,9 @@ class TestAuthEndpoints:
"/api/v1/auth/change-password",
json={
"current_password": "old_password",
"new_password": "new_password"
"new_password": "new_password",
},
cookies=auth_cookies
cookies=auth_cookies,
)
assert response.status_code == 200
@@ -637,8 +638,8 @@ class TestAuthEndpoints:
"/api/v1/auth/change-password",
json={
"current_password": "old_password",
"new_password": "new_password"
}
"new_password": "new_password",
},
)
assert response.status_code == 401
@@ -652,9 +653,10 @@ class TestAuthEndpoints:
) -> None:
"""Test get user OAuth providers success."""
with patch("app.services.auth.AuthService.get_user_oauth_providers") as mock_providers:
from datetime import datetime
from app.models.user_oauth import UserOauth
from datetime import datetime, timezone
mock_oauth_google = UserOauth(
id=1,
user_id=test_user.id,
@@ -662,34 +664,34 @@ class TestAuthEndpoints:
provider_user_id="google123",
email="test@example.com",
name="Test User",
created_at=datetime.now(timezone.utc),
updated_at=datetime.now(timezone.utc),
created_at=datetime.now(UTC),
updated_at=datetime.now(UTC),
)
mock_oauth_github = UserOauth(
id=2,
user_id=test_user.id,
provider="github",
provider="github",
provider_user_id="github456",
email="test@example.com",
name="Test User",
created_at=datetime.now(timezone.utc),
updated_at=datetime.now(timezone.utc),
created_at=datetime.now(UTC),
updated_at=datetime.now(UTC),
)
mock_providers.return_value = [mock_oauth_google, mock_oauth_github]
response = await test_client.get(
"/api/v1/auth/user-providers",
cookies=auth_cookies
cookies=auth_cookies,
)
assert response.status_code == 200
data = response.json()
assert len(data) == 3 # password + 2 OAuth providers
# Check password provider (first)
assert data[0]["provider"] == "password"
assert data[0]["display_name"] == "Password"
# Check OAuth providers
assert data[1]["provider"] == "google"
assert data[1]["display_name"] == "Google"