Spaces:
Build error
Build error
File size: 2,040 Bytes
3e6248e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
"""
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
|