""" E2E Tests for Credits Endpoints Tests credit balance and history with real server. Note: Since we can't mock Google OAuth in a running server, we test that endpoints properly require authentication. """ import pytest class TestCreditsE2E: """Test credits endpoints with real server.""" def test_credits_balance_requires_auth(self, api_client): """Credits balance requires authentication.""" response = api_client.get("/credits/balance") assert response.status_code == 401 def test_credits_history_requires_auth(self, api_client): """Credits history requires authentication.""" response = api_client.get("/credits/history") assert response.status_code == 401 class TestProtectedEndpointsE2E: """Test that protected endpoints require authentication.""" @pytest.mark.parametrize("endpoint,method", [ ("/gemini/generate-text", "post"), ("/gemini/generate-video", "post"), ("/gemini/edit-image", "post"), ("/gemini/generate-animation-prompt", "post"), ("/gemini/analyze-image", "post"), ("/payments/create-order", "post"), ("/payments/history", "get"), ("/contact", "post"), ]) def test_protected_endpoint_requires_auth(self, api_client, endpoint, method): """Protected endpoints return 401 without auth.""" if method == "post": response = api_client.post(endpoint, json={}) else: response = api_client.get(endpoint) # Should be 401 (unauthorized) - might get 422 if validation runs first assert response.status_code in [401, 403, 422] class TestPaymentsE2E: """Test payments endpoints with real server.""" def test_packages_public(self, api_client): """Packages endpoint is public.""" response = api_client.get("/payments/packages") assert response.status_code == 200 data = response.json() # Should return list of packages assert isinstance(data, (list, dict))