refactor: rename public routes and templates to platform
Complete the public -> platform naming migration across the codebase. This aligns with the naming convention where "platform" refers to the marketing/public-facing pages of the platform itself. Changes: - Update all imports from public to platform modules - Update template references from public/ to platform/ - Update route registrations to use platform prefix - Update documentation to reflect new naming - Update test files for platform API endpoints Files affected: - app/api/main.py - router imports - app/modules/*/routes/*/platform.py - route definitions - app/modules/*/templates/*/platform/ - template files - app/modules/routes.py - route discovery - docs/* - documentation updates - tests/integration/api/v1/platform/ - test files Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# tests/integration/api/v1/public/test_signup.py
|
||||
# tests/integration/api/v1/platform/test_signup.py
|
||||
"""Integration tests for platform signup API endpoints.
|
||||
|
||||
Tests the /api/v1/public/signup/* endpoints.
|
||||
Tests the /api/v1/platform/signup/* endpoints.
|
||||
"""
|
||||
|
||||
from unittest.mock import MagicMock, patch
|
||||
@@ -37,7 +37,7 @@ def mock_stripe_service():
|
||||
def signup_session(client):
|
||||
"""Create a signup session for testing."""
|
||||
response = client.post(
|
||||
"/api/v1/public/signup/start",
|
||||
"/api/v1/platform/signup/start",
|
||||
json={"tier_code": TierCode.PROFESSIONAL.value, "is_annual": False},
|
||||
)
|
||||
return response.json()["session_id"]
|
||||
@@ -104,12 +104,12 @@ def claimed_letzshop_vendor(db, claimed_owner_user):
|
||||
@pytest.mark.api
|
||||
@pytest.mark.platform
|
||||
class TestSignupStartAPI:
|
||||
"""Test signup start endpoint at /api/v1/public/signup/start."""
|
||||
"""Test signup start endpoint at /api/v1/platform/signup/start."""
|
||||
|
||||
def test_start_signup_success(self, client):
|
||||
"""Test starting a signup session."""
|
||||
response = client.post(
|
||||
"/api/v1/public/signup/start",
|
||||
"/api/v1/platform/signup/start",
|
||||
json={"tier_code": TierCode.ESSENTIAL.value, "is_annual": False},
|
||||
)
|
||||
|
||||
@@ -122,7 +122,7 @@ class TestSignupStartAPI:
|
||||
def test_start_signup_with_annual_billing(self, client):
|
||||
"""Test starting signup with annual billing."""
|
||||
response = client.post(
|
||||
"/api/v1/public/signup/start",
|
||||
"/api/v1/platform/signup/start",
|
||||
json={"tier_code": TierCode.PROFESSIONAL.value, "is_annual": True},
|
||||
)
|
||||
|
||||
@@ -134,7 +134,7 @@ class TestSignupStartAPI:
|
||||
"""Test starting signup for all valid tiers."""
|
||||
for tier in [TierCode.ESSENTIAL, TierCode.PROFESSIONAL, TierCode.BUSINESS, TierCode.ENTERPRISE]:
|
||||
response = client.post(
|
||||
"/api/v1/public/signup/start",
|
||||
"/api/v1/platform/signup/start",
|
||||
json={"tier_code": tier.value, "is_annual": False},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
@@ -143,7 +143,7 @@ class TestSignupStartAPI:
|
||||
def test_start_signup_invalid_tier(self, client):
|
||||
"""Test starting signup with invalid tier code."""
|
||||
response = client.post(
|
||||
"/api/v1/public/signup/start",
|
||||
"/api/v1/platform/signup/start",
|
||||
json={"tier_code": "invalid_tier", "is_annual": False},
|
||||
)
|
||||
|
||||
@@ -154,11 +154,11 @@ class TestSignupStartAPI:
|
||||
def test_start_signup_session_id_is_unique(self, client):
|
||||
"""Test that each signup session gets a unique ID."""
|
||||
response1 = client.post(
|
||||
"/api/v1/public/signup/start",
|
||||
"/api/v1/platform/signup/start",
|
||||
json={"tier_code": TierCode.ESSENTIAL.value, "is_annual": False},
|
||||
)
|
||||
response2 = client.post(
|
||||
"/api/v1/public/signup/start",
|
||||
"/api/v1/platform/signup/start",
|
||||
json={"tier_code": TierCode.ESSENTIAL.value, "is_annual": False},
|
||||
)
|
||||
|
||||
@@ -169,12 +169,12 @@ class TestSignupStartAPI:
|
||||
@pytest.mark.api
|
||||
@pytest.mark.platform
|
||||
class TestClaimVendorAPI:
|
||||
"""Test claim vendor endpoint at /api/v1/public/signup/claim-vendor."""
|
||||
"""Test claim vendor endpoint at /api/v1/platform/signup/claim-vendor."""
|
||||
|
||||
def test_claim_vendor_success(self, client, signup_session):
|
||||
"""Test claiming a Letzshop vendor."""
|
||||
response = client.post(
|
||||
"/api/v1/public/signup/claim-vendor",
|
||||
"/api/v1/platform/signup/claim-vendor",
|
||||
json={
|
||||
"session_id": signup_session,
|
||||
"letzshop_slug": "my-new-shop",
|
||||
@@ -190,7 +190,7 @@ class TestClaimVendorAPI:
|
||||
def test_claim_vendor_with_vendor_id(self, client, signup_session):
|
||||
"""Test claiming vendor with Letzshop vendor ID."""
|
||||
response = client.post(
|
||||
"/api/v1/public/signup/claim-vendor",
|
||||
"/api/v1/platform/signup/claim-vendor",
|
||||
json={
|
||||
"session_id": signup_session,
|
||||
"letzshop_slug": "my-shop",
|
||||
@@ -205,7 +205,7 @@ class TestClaimVendorAPI:
|
||||
def test_claim_vendor_invalid_session(self, client):
|
||||
"""Test claiming vendor with invalid session."""
|
||||
response = client.post(
|
||||
"/api/v1/public/signup/claim-vendor",
|
||||
"/api/v1/platform/signup/claim-vendor",
|
||||
json={
|
||||
"session_id": "invalid_session_id",
|
||||
"letzshop_slug": "my-shop",
|
||||
@@ -219,7 +219,7 @@ class TestClaimVendorAPI:
|
||||
def test_claim_vendor_already_claimed(self, client, signup_session, claimed_letzshop_vendor):
|
||||
"""Test claiming a vendor that's already claimed."""
|
||||
response = client.post(
|
||||
"/api/v1/public/signup/claim-vendor",
|
||||
"/api/v1/platform/signup/claim-vendor",
|
||||
json={
|
||||
"session_id": signup_session,
|
||||
"letzshop_slug": "already-claimed-shop",
|
||||
@@ -235,12 +235,12 @@ class TestClaimVendorAPI:
|
||||
@pytest.mark.api
|
||||
@pytest.mark.platform
|
||||
class TestCreateAccountAPI:
|
||||
"""Test create account endpoint at /api/v1/public/signup/create-account."""
|
||||
"""Test create account endpoint at /api/v1/platform/signup/create-account."""
|
||||
|
||||
def test_create_account_success(self, client, signup_session, mock_stripe_service):
|
||||
"""Test creating an account."""
|
||||
response = client.post(
|
||||
"/api/v1/public/signup/create-account",
|
||||
"/api/v1/platform/signup/create-account",
|
||||
json={
|
||||
"session_id": signup_session,
|
||||
"email": "newuser@example.com",
|
||||
@@ -261,7 +261,7 @@ class TestCreateAccountAPI:
|
||||
def test_create_account_with_phone(self, client, signup_session, mock_stripe_service):
|
||||
"""Test creating an account with phone number."""
|
||||
response = client.post(
|
||||
"/api/v1/public/signup/create-account",
|
||||
"/api/v1/platform/signup/create-account",
|
||||
json={
|
||||
"session_id": signup_session,
|
||||
"email": "user2@example.com",
|
||||
@@ -280,7 +280,7 @@ class TestCreateAccountAPI:
|
||||
def test_create_account_invalid_session(self, client, mock_stripe_service):
|
||||
"""Test creating account with invalid session."""
|
||||
response = client.post(
|
||||
"/api/v1/public/signup/create-account",
|
||||
"/api/v1/platform/signup/create-account",
|
||||
json={
|
||||
"session_id": "invalid_session",
|
||||
"email": "test@example.com",
|
||||
@@ -298,7 +298,7 @@ class TestCreateAccountAPI:
|
||||
):
|
||||
"""Test creating account with existing email."""
|
||||
response = client.post(
|
||||
"/api/v1/public/signup/create-account",
|
||||
"/api/v1/platform/signup/create-account",
|
||||
json={
|
||||
"session_id": signup_session,
|
||||
"email": "existing@example.com",
|
||||
@@ -316,7 +316,7 @@ class TestCreateAccountAPI:
|
||||
def test_create_account_invalid_email(self, client, signup_session):
|
||||
"""Test creating account with invalid email format."""
|
||||
response = client.post(
|
||||
"/api/v1/public/signup/create-account",
|
||||
"/api/v1/platform/signup/create-account",
|
||||
json={
|
||||
"session_id": signup_session,
|
||||
"email": "not-an-email",
|
||||
@@ -333,14 +333,14 @@ class TestCreateAccountAPI:
|
||||
"""Test creating account after claiming Letzshop vendor."""
|
||||
# Start signup
|
||||
start_response = client.post(
|
||||
"/api/v1/public/signup/start",
|
||||
"/api/v1/platform/signup/start",
|
||||
json={"tier_code": TierCode.PROFESSIONAL.value, "is_annual": False},
|
||||
)
|
||||
session_id = start_response.json()["session_id"]
|
||||
|
||||
# Claim vendor
|
||||
client.post(
|
||||
"/api/v1/public/signup/claim-vendor",
|
||||
"/api/v1/platform/signup/claim-vendor",
|
||||
json={
|
||||
"session_id": session_id,
|
||||
"letzshop_slug": "my-shop-claim",
|
||||
@@ -349,7 +349,7 @@ class TestCreateAccountAPI:
|
||||
|
||||
# Create account
|
||||
response = client.post(
|
||||
"/api/v1/public/signup/create-account",
|
||||
"/api/v1/platform/signup/create-account",
|
||||
json={
|
||||
"session_id": session_id,
|
||||
"email": "shop@example.com",
|
||||
@@ -369,13 +369,13 @@ class TestCreateAccountAPI:
|
||||
@pytest.mark.api
|
||||
@pytest.mark.platform
|
||||
class TestSetupPaymentAPI:
|
||||
"""Test setup payment endpoint at /api/v1/public/signup/setup-payment."""
|
||||
"""Test setup payment endpoint at /api/v1/platform/signup/setup-payment."""
|
||||
|
||||
def test_setup_payment_success(self, client, signup_session, mock_stripe_service):
|
||||
"""Test setting up payment after account creation."""
|
||||
# Create account first
|
||||
client.post(
|
||||
"/api/v1/public/signup/create-account",
|
||||
"/api/v1/platform/signup/create-account",
|
||||
json={
|
||||
"session_id": signup_session,
|
||||
"email": "payment@example.com",
|
||||
@@ -388,7 +388,7 @@ class TestSetupPaymentAPI:
|
||||
|
||||
# Setup payment
|
||||
response = client.post(
|
||||
"/api/v1/public/signup/setup-payment",
|
||||
"/api/v1/platform/signup/setup-payment",
|
||||
json={"session_id": signup_session},
|
||||
)
|
||||
|
||||
@@ -401,7 +401,7 @@ class TestSetupPaymentAPI:
|
||||
def test_setup_payment_invalid_session(self, client, mock_stripe_service):
|
||||
"""Test setup payment with invalid session."""
|
||||
response = client.post(
|
||||
"/api/v1/public/signup/setup-payment",
|
||||
"/api/v1/platform/signup/setup-payment",
|
||||
json={"session_id": "invalid_session"},
|
||||
)
|
||||
|
||||
@@ -410,7 +410,7 @@ class TestSetupPaymentAPI:
|
||||
def test_setup_payment_without_account(self, client, signup_session, mock_stripe_service):
|
||||
"""Test setup payment without creating account first."""
|
||||
response = client.post(
|
||||
"/api/v1/public/signup/setup-payment",
|
||||
"/api/v1/platform/signup/setup-payment",
|
||||
json={"session_id": signup_session},
|
||||
)
|
||||
|
||||
@@ -423,13 +423,13 @@ class TestSetupPaymentAPI:
|
||||
@pytest.mark.api
|
||||
@pytest.mark.platform
|
||||
class TestCompleteSignupAPI:
|
||||
"""Test complete signup endpoint at /api/v1/public/signup/complete."""
|
||||
"""Test complete signup endpoint at /api/v1/platform/signup/complete."""
|
||||
|
||||
def test_complete_signup_success(self, client, signup_session, mock_stripe_service, db):
|
||||
"""Test completing signup after payment setup."""
|
||||
# Create account
|
||||
client.post(
|
||||
"/api/v1/public/signup/create-account",
|
||||
"/api/v1/platform/signup/create-account",
|
||||
json={
|
||||
"session_id": signup_session,
|
||||
"email": "complete@example.com",
|
||||
@@ -442,13 +442,13 @@ class TestCompleteSignupAPI:
|
||||
|
||||
# Setup payment
|
||||
client.post(
|
||||
"/api/v1/public/signup/setup-payment",
|
||||
"/api/v1/platform/signup/setup-payment",
|
||||
json={"session_id": signup_session},
|
||||
)
|
||||
|
||||
# Complete signup
|
||||
response = client.post(
|
||||
"/api/v1/public/signup/complete",
|
||||
"/api/v1/platform/signup/complete",
|
||||
json={
|
||||
"session_id": signup_session,
|
||||
"setup_intent_id": "seti_test_123",
|
||||
@@ -469,7 +469,7 @@ class TestCompleteSignupAPI:
|
||||
"""Test that completing signup returns a valid JWT access token for auto-login."""
|
||||
# Create account
|
||||
client.post(
|
||||
"/api/v1/public/signup/create-account",
|
||||
"/api/v1/platform/signup/create-account",
|
||||
json={
|
||||
"session_id": signup_session,
|
||||
"email": "token_test@example.com",
|
||||
@@ -482,13 +482,13 @@ class TestCompleteSignupAPI:
|
||||
|
||||
# Setup payment
|
||||
client.post(
|
||||
"/api/v1/public/signup/setup-payment",
|
||||
"/api/v1/platform/signup/setup-payment",
|
||||
json={"session_id": signup_session},
|
||||
)
|
||||
|
||||
# Complete signup
|
||||
response = client.post(
|
||||
"/api/v1/public/signup/complete",
|
||||
"/api/v1/platform/signup/complete",
|
||||
json={
|
||||
"session_id": signup_session,
|
||||
"setup_intent_id": "seti_test_123",
|
||||
@@ -509,7 +509,7 @@ class TestCompleteSignupAPI:
|
||||
"""Test that the returned access token can be used to authenticate API calls."""
|
||||
# Create account
|
||||
client.post(
|
||||
"/api/v1/public/signup/create-account",
|
||||
"/api/v1/platform/signup/create-account",
|
||||
json={
|
||||
"session_id": signup_session,
|
||||
"email": "auth_test@example.com",
|
||||
@@ -522,13 +522,13 @@ class TestCompleteSignupAPI:
|
||||
|
||||
# Setup payment
|
||||
client.post(
|
||||
"/api/v1/public/signup/setup-payment",
|
||||
"/api/v1/platform/signup/setup-payment",
|
||||
json={"session_id": signup_session},
|
||||
)
|
||||
|
||||
# Complete signup
|
||||
complete_response = client.post(
|
||||
"/api/v1/public/signup/complete",
|
||||
"/api/v1/platform/signup/complete",
|
||||
json={
|
||||
"session_id": signup_session,
|
||||
"setup_intent_id": "seti_test_123",
|
||||
@@ -553,7 +553,7 @@ class TestCompleteSignupAPI:
|
||||
"""Test that completing signup sets the vendor_token HTTP-only cookie."""
|
||||
# Create account
|
||||
client.post(
|
||||
"/api/v1/public/signup/create-account",
|
||||
"/api/v1/platform/signup/create-account",
|
||||
json={
|
||||
"session_id": signup_session,
|
||||
"email": "cookie_test@example.com",
|
||||
@@ -566,13 +566,13 @@ class TestCompleteSignupAPI:
|
||||
|
||||
# Setup payment
|
||||
client.post(
|
||||
"/api/v1/public/signup/setup-payment",
|
||||
"/api/v1/platform/signup/setup-payment",
|
||||
json={"session_id": signup_session},
|
||||
)
|
||||
|
||||
# Complete signup
|
||||
response = client.post(
|
||||
"/api/v1/public/signup/complete",
|
||||
"/api/v1/platform/signup/complete",
|
||||
json={
|
||||
"session_id": signup_session,
|
||||
"setup_intent_id": "seti_test_123",
|
||||
@@ -588,7 +588,7 @@ class TestCompleteSignupAPI:
|
||||
def test_complete_signup_invalid_session(self, client, mock_stripe_service):
|
||||
"""Test completing signup with invalid session."""
|
||||
response = client.post(
|
||||
"/api/v1/public/signup/complete",
|
||||
"/api/v1/platform/signup/complete",
|
||||
json={
|
||||
"session_id": "invalid_session",
|
||||
"setup_intent_id": "seti_test_123",
|
||||
@@ -603,7 +603,7 @@ class TestCompleteSignupAPI:
|
||||
"""Test completing signup when payment setup failed."""
|
||||
# Create account
|
||||
client.post(
|
||||
"/api/v1/public/signup/create-account",
|
||||
"/api/v1/platform/signup/create-account",
|
||||
json={
|
||||
"session_id": signup_session,
|
||||
"email": "fail@example.com",
|
||||
@@ -616,7 +616,7 @@ class TestCompleteSignupAPI:
|
||||
|
||||
# Setup payment
|
||||
client.post(
|
||||
"/api/v1/public/signup/setup-payment",
|
||||
"/api/v1/platform/signup/setup-payment",
|
||||
json={"session_id": signup_session},
|
||||
)
|
||||
|
||||
@@ -629,7 +629,7 @@ class TestCompleteSignupAPI:
|
||||
|
||||
# Complete signup
|
||||
response = client.post(
|
||||
"/api/v1/public/signup/complete",
|
||||
"/api/v1/platform/signup/complete",
|
||||
json={
|
||||
"session_id": signup_session,
|
||||
"setup_intent_id": "seti_failed",
|
||||
@@ -645,11 +645,11 @@ class TestCompleteSignupAPI:
|
||||
@pytest.mark.api
|
||||
@pytest.mark.platform
|
||||
class TestGetSignupSessionAPI:
|
||||
"""Test get signup session endpoint at /api/v1/public/signup/session/{session_id}."""
|
||||
"""Test get signup session endpoint at /api/v1/platform/signup/session/{session_id}."""
|
||||
|
||||
def test_get_session_after_start(self, client, signup_session):
|
||||
"""Test getting session after starting signup."""
|
||||
response = client.get(f"/api/v1/public/signup/session/{signup_session}")
|
||||
response = client.get(f"/api/v1/platform/signup/session/{signup_session}")
|
||||
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
@@ -661,14 +661,14 @@ class TestGetSignupSessionAPI:
|
||||
def test_get_session_after_claim(self, client, signup_session):
|
||||
"""Test getting session after claiming vendor."""
|
||||
client.post(
|
||||
"/api/v1/public/signup/claim-vendor",
|
||||
"/api/v1/platform/signup/claim-vendor",
|
||||
json={
|
||||
"session_id": signup_session,
|
||||
"letzshop_slug": "my-session-shop",
|
||||
},
|
||||
)
|
||||
|
||||
response = client.get(f"/api/v1/public/signup/session/{signup_session}")
|
||||
response = client.get(f"/api/v1/platform/signup/session/{signup_session}")
|
||||
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
@@ -677,7 +677,7 @@ class TestGetSignupSessionAPI:
|
||||
|
||||
def test_get_session_invalid_id(self, client):
|
||||
"""Test getting non-existent session."""
|
||||
response = client.get("/api/v1/public/signup/session/invalid_id")
|
||||
response = client.get("/api/v1/platform/signup/session/invalid_id")
|
||||
|
||||
assert response.status_code == 404
|
||||
|
||||
@@ -692,7 +692,7 @@ class TestSignupFullFlow:
|
||||
"""Test the complete signup flow from start to finish."""
|
||||
# Step 1: Start signup
|
||||
start_response = client.post(
|
||||
"/api/v1/public/signup/start",
|
||||
"/api/v1/platform/signup/start",
|
||||
json={"tier_code": TierCode.BUSINESS.value, "is_annual": True},
|
||||
)
|
||||
assert start_response.status_code == 200
|
||||
@@ -700,7 +700,7 @@ class TestSignupFullFlow:
|
||||
|
||||
# Step 2: Claim Letzshop vendor (optional)
|
||||
claim_response = client.post(
|
||||
"/api/v1/public/signup/claim-vendor",
|
||||
"/api/v1/platform/signup/claim-vendor",
|
||||
json={
|
||||
"session_id": session_id,
|
||||
"letzshop_slug": "full-flow-shop",
|
||||
@@ -710,7 +710,7 @@ class TestSignupFullFlow:
|
||||
|
||||
# Step 3: Create account
|
||||
account_response = client.post(
|
||||
"/api/v1/public/signup/create-account",
|
||||
"/api/v1/platform/signup/create-account",
|
||||
json={
|
||||
"session_id": session_id,
|
||||
"email": "fullflow@example.com",
|
||||
@@ -726,7 +726,7 @@ class TestSignupFullFlow:
|
||||
|
||||
# Step 4: Setup payment
|
||||
payment_response = client.post(
|
||||
"/api/v1/public/signup/setup-payment",
|
||||
"/api/v1/platform/signup/setup-payment",
|
||||
json={"session_id": session_id},
|
||||
)
|
||||
assert payment_response.status_code == 200
|
||||
@@ -734,7 +734,7 @@ class TestSignupFullFlow:
|
||||
|
||||
# Step 5: Complete signup
|
||||
complete_response = client.post(
|
||||
"/api/v1/public/signup/complete",
|
||||
"/api/v1/platform/signup/complete",
|
||||
json={
|
||||
"session_id": session_id,
|
||||
"setup_intent_id": "seti_test_123",
|
||||
@@ -753,14 +753,14 @@ class TestSignupFullFlow:
|
||||
"""Test signup flow skipping Letzshop claim step."""
|
||||
# Step 1: Start signup
|
||||
start_response = client.post(
|
||||
"/api/v1/public/signup/start",
|
||||
"/api/v1/platform/signup/start",
|
||||
json={"tier_code": TierCode.ESSENTIAL.value, "is_annual": False},
|
||||
)
|
||||
session_id = start_response.json()["session_id"]
|
||||
|
||||
# Skip Step 2, go directly to Step 3
|
||||
account_response = client.post(
|
||||
"/api/v1/public/signup/create-account",
|
||||
"/api/v1/platform/signup/create-account",
|
||||
json={
|
||||
"session_id": session_id,
|
||||
"email": "noletzshop@example.com",
|
||||
@@ -775,12 +775,12 @@ class TestSignupFullFlow:
|
||||
|
||||
# Step 4 & 5: Payment and complete
|
||||
client.post(
|
||||
"/api/v1/public/signup/setup-payment",
|
||||
"/api/v1/platform/signup/setup-payment",
|
||||
json={"session_id": session_id},
|
||||
)
|
||||
|
||||
complete_response = client.post(
|
||||
"/api/v1/public/signup/complete",
|
||||
"/api/v1/platform/signup/complete",
|
||||
json={
|
||||
"session_id": session_id,
|
||||
"setup_intent_id": "seti_test_123",
|
||||
|
||||
Reference in New Issue
Block a user