Spaces:
Build error
Build error
| """ | |
| E2E Tests for Payments API Endpoints | |
| Tests payment flow: packages β create-order β verify β history | |
| Razorpay API is external so actual payment tests are limited. | |
| """ | |
| import pytest | |
| class TestPaymentsPackagesE2E: | |
| """Test /payments/packages endpoint (public).""" | |
| def test_get_packages(self, api_client): | |
| """Packages endpoint returns available packages.""" | |
| response = api_client.get("/payments/packages") | |
| assert response.status_code == 200 | |
| data = response.json() | |
| assert "packages" in data | |
| assert isinstance(data["packages"], list) | |
| if len(data["packages"]) > 0: | |
| pkg = data["packages"][0] | |
| assert "id" in pkg | |
| assert "name" in pkg | |
| assert "credits" in pkg | |
| assert "amount_paise" in pkg | |
| class TestPaymentsProtectionE2E: | |
| """Test that payment endpoints require authentication.""" | |
| def test_create_order_requires_auth(self, api_client): | |
| """Create order requires authentication.""" | |
| response = api_client.post("/payments/create-order", json={ | |
| "package_id": "starter" | |
| }) | |
| assert response.status_code == 401 | |
| def test_verify_requires_auth(self, api_client): | |
| """Verify payment requires authentication.""" | |
| response = api_client.post("/payments/verify", json={ | |
| "razorpay_order_id": "order_test", | |
| "razorpay_payment_id": "pay_test", | |
| "razorpay_signature": "sig_test" | |
| }) | |
| assert response.status_code == 401 | |
| def test_history_requires_auth(self, api_client): | |
| """Payment history requires authentication.""" | |
| response = api_client.get("/payments/history") | |
| assert response.status_code == 401 | |
| def test_analytics_requires_auth(self, api_client): | |
| """Payment analytics requires authentication.""" | |
| response = api_client.get("/payments/analytics") | |
| assert response.status_code == 401 | |