import pytest import services.auth_service as auth_svc from services.auth_service import get_or_create_google_user def test_google_user_creation(monkeypatch): # Enable database for testing monkeypatch.setattr(auth_svc, "USE_DATABASE", True) monkeypatch.setattr(auth_svc, "DATABASE_AVAILABLE", True) email = "google_test_user@example.com" name = "Google User" avatar_url = "https://example.com/avatar.png" # Create the user user = get_or_create_google_user(email=email, name=name, avatar_url=avatar_url) assert user is not None assert user.email == email assert user.name == name assert user.avatar_url == avatar_url # Retrieve again user_again = get_or_create_google_user(email=email, name=name, avatar_url="https://new-avatar.com") assert user_again.id == user.id