refactor: migrate templates and static files to self-contained modules

Templates Migration:
- Migrate admin templates to modules (tenancy, billing, monitoring, marketplace, etc.)
- Migrate vendor templates to modules (tenancy, billing, orders, messaging, etc.)
- Migrate storefront templates to modules (catalog, customers, orders, cart, checkout, cms)
- Migrate public templates to modules (billing, marketplace, cms)
- Keep shared templates in app/templates/ (base.html, errors/, partials/, macros/)
- Migrate letzshop partials to marketplace module

Static Files Migration:
- Migrate admin JS to modules: tenancy (23 files), core (5 files), monitoring (1 file)
- Migrate vendor JS to modules: tenancy (4 files), core (2 files)
- Migrate shared JS: vendor-selector.js to core, media-picker.js to cms
- Migrate storefront JS: storefront-layout.js to core
- Keep framework JS in static/ (api-client, utils, money, icons, log-config, lib/)
- Update all template references to use module_static paths

Naming Consistency:
- Rename static/platform/ to static/public/
- Rename app/templates/platform/ to app/templates/public/
- Update all extends and static references

Documentation:
- Update module-system.md with shared templates documentation
- Update frontend-structure.md with new module JS organization

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-01 14:34:16 +01:00
parent 843703258f
commit 4e28d91a78
542 changed files with 11603 additions and 9037 deletions

View File

@@ -178,7 +178,7 @@ class TestAdminLetzshopCredentialsAPI:
class TestAdminLetzshopConnectionAPI:
"""Test admin Letzshop connection testing endpoints."""
@patch("app.services.letzshop.client_service.requests.Session.post")
@patch("app.modules.marketplace.services.letzshop.client_service.requests.Session.post")
def test_test_vendor_connection(
self, mock_post, client, admin_headers, test_vendor
):
@@ -206,7 +206,7 @@ class TestAdminLetzshopConnectionAPI:
data = response.json()
assert data["success"] is True
@patch("app.services.letzshop.client_service.requests.Session.post")
@patch("app.modules.marketplace.services.letzshop.client_service.requests.Session.post")
def test_test_api_key_directly(self, mock_post, client, admin_headers):
"""Test any API key without associating with vendor."""
mock_response = MagicMock()
@@ -290,7 +290,7 @@ class TestAdminLetzshopOrdersAPI:
assert data["total"] == 1
assert data["orders"][0]["customer_email"] == "admin-test@example.com"
@patch("app.services.letzshop.client_service.requests.Session.post")
@patch("app.modules.marketplace.services.letzshop.client_service.requests.Session.post")
def test_trigger_vendor_sync(self, mock_post, client, admin_headers, test_vendor):
"""Test triggering sync for a vendor."""
# Mock response

View File

@@ -1,2 +0,0 @@
# tests/integration/api/v1/platform/__init__.py
"""Platform API integration tests."""

View File

@@ -0,0 +1,8 @@
# tests/integration/api/v1/public/__init__.py
"""Public API integration tests.
Tests for unauthenticated public endpoints:
- /api/v1/public/signup/* - Multi-step signup flow
- /api/v1/public/pricing/* - Subscription tiers and pricing
- /api/v1/public/letzshop-vendors/* - Vendor lookup for signup
"""

View File

@@ -1,7 +1,7 @@
# tests/integration/api/v1/platform/test_letzshop_vendors.py
# tests/integration/api/v1/public/test_letzshop_vendors.py
"""Integration tests for platform Letzshop vendor lookup API endpoints.
Tests the /api/v1/platform/letzshop-vendors/* endpoints.
Tests the /api/v1/public/letzshop-vendors/* endpoints.
"""
import pytest
@@ -62,15 +62,15 @@ def claimed_vendor(db, test_company):
@pytest.mark.api
@pytest.mark.platform
class TestLetzshopVendorLookupAPI:
"""Test Letzshop vendor lookup endpoints at /api/v1/platform/letzshop-vendors/*."""
"""Test Letzshop vendor lookup endpoints at /api/v1/public/letzshop-vendors/*."""
# =========================================================================
# GET /api/v1/platform/letzshop-vendors
# GET /api/v1/public/letzshop-vendors
# =========================================================================
def test_list_vendors_returns_empty_list(self, client):
"""Test listing vendors returns empty list (placeholder)."""
response = client.get("/api/v1/platform/letzshop-vendors")
response = client.get("/api/v1/public/letzshop-vendors")
assert response.status_code == 200
data = response.json()
@@ -83,7 +83,7 @@ class TestLetzshopVendorLookupAPI:
def test_list_vendors_with_pagination(self, client):
"""Test listing vendors with pagination parameters."""
response = client.get("/api/v1/platform/letzshop-vendors?page=2&limit=10")
response = client.get("/api/v1/public/letzshop-vendors?page=2&limit=10")
assert response.status_code == 200
data = response.json()
@@ -92,7 +92,7 @@ class TestLetzshopVendorLookupAPI:
def test_list_vendors_with_search(self, client):
"""Test listing vendors with search parameter."""
response = client.get("/api/v1/platform/letzshop-vendors?search=my-shop")
response = client.get("/api/v1/public/letzshop-vendors?search=my-shop")
assert response.status_code == 200
data = response.json()
@@ -101,7 +101,7 @@ class TestLetzshopVendorLookupAPI:
def test_list_vendors_with_filters(self, client):
"""Test listing vendors with category and city filters."""
response = client.get(
"/api/v1/platform/letzshop-vendors?category=fashion&city=luxembourg"
"/api/v1/public/letzshop-vendors?category=fashion&city=luxembourg"
)
assert response.status_code == 200
@@ -111,17 +111,17 @@ class TestLetzshopVendorLookupAPI:
def test_list_vendors_limit_validation(self, client):
"""Test that limit parameter is validated."""
# Maximum limit is 50
response = client.get("/api/v1/platform/letzshop-vendors?limit=100")
response = client.get("/api/v1/public/letzshop-vendors?limit=100")
assert response.status_code == 422
# =========================================================================
# POST /api/v1/platform/letzshop-vendors/lookup
# POST /api/v1/public/letzshop-vendors/lookup
# =========================================================================
def test_lookup_vendor_by_full_url(self, client):
"""Test looking up vendor by full Letzshop URL."""
response = client.post(
"/api/v1/platform/letzshop-vendors/lookup",
"/api/v1/public/letzshop-vendors/lookup",
json={"url": "https://letzshop.lu/vendors/my-test-shop"},
)
@@ -134,7 +134,7 @@ class TestLetzshopVendorLookupAPI:
def test_lookup_vendor_by_url_with_language(self, client):
"""Test looking up vendor by URL with language prefix."""
response = client.post(
"/api/v1/platform/letzshop-vendors/lookup",
"/api/v1/public/letzshop-vendors/lookup",
json={"url": "https://letzshop.lu/en/vendors/my-shop"},
)
@@ -146,7 +146,7 @@ class TestLetzshopVendorLookupAPI:
def test_lookup_vendor_by_url_without_protocol(self, client):
"""Test looking up vendor by URL without https://."""
response = client.post(
"/api/v1/platform/letzshop-vendors/lookup",
"/api/v1/public/letzshop-vendors/lookup",
json={"url": "letzshop.lu/vendors/test-shop"},
)
@@ -158,7 +158,7 @@ class TestLetzshopVendorLookupAPI:
def test_lookup_vendor_by_slug_only(self, client):
"""Test looking up vendor by slug alone."""
response = client.post(
"/api/v1/platform/letzshop-vendors/lookup",
"/api/v1/public/letzshop-vendors/lookup",
json={"url": "my-shop-name"},
)
@@ -170,7 +170,7 @@ class TestLetzshopVendorLookupAPI:
def test_lookup_vendor_normalizes_slug(self, client):
"""Test that slug is normalized to lowercase."""
response = client.post(
"/api/v1/platform/letzshop-vendors/lookup",
"/api/v1/public/letzshop-vendors/lookup",
json={"url": "https://letzshop.lu/vendors/MY-SHOP-NAME"},
)
@@ -181,7 +181,7 @@ class TestLetzshopVendorLookupAPI:
def test_lookup_vendor_shows_claimed_status(self, client, claimed_vendor):
"""Test that lookup shows if vendor is already claimed."""
response = client.post(
"/api/v1/platform/letzshop-vendors/lookup",
"/api/v1/public/letzshop-vendors/lookup",
json={"url": "claimed-shop"},
)
@@ -193,7 +193,7 @@ class TestLetzshopVendorLookupAPI:
def test_lookup_vendor_shows_unclaimed_status(self, client):
"""Test that lookup shows if vendor is not claimed."""
response = client.post(
"/api/v1/platform/letzshop-vendors/lookup",
"/api/v1/public/letzshop-vendors/lookup",
json={"url": "unclaimed-new-shop"},
)
@@ -205,7 +205,7 @@ class TestLetzshopVendorLookupAPI:
def test_lookup_vendor_empty_url(self, client):
"""Test lookup with empty URL."""
response = client.post(
"/api/v1/platform/letzshop-vendors/lookup",
"/api/v1/public/letzshop-vendors/lookup",
json={"url": ""},
)
@@ -217,7 +217,7 @@ class TestLetzshopVendorLookupAPI:
def test_lookup_vendor_response_has_expected_fields(self, client):
"""Test that vendor lookup response has all expected fields."""
response = client.post(
"/api/v1/platform/letzshop-vendors/lookup",
"/api/v1/public/letzshop-vendors/lookup",
json={"url": "test-vendor"},
)
@@ -230,12 +230,12 @@ class TestLetzshopVendorLookupAPI:
assert "is_claimed" in vendor
# =========================================================================
# GET /api/v1/platform/letzshop-vendors/{slug}
# GET /api/v1/public/letzshop-vendors/{slug}
# =========================================================================
def test_get_vendor_by_slug(self, client):
"""Test getting vendor by slug."""
response = client.get("/api/v1/platform/letzshop-vendors/my-shop")
response = client.get("/api/v1/public/letzshop-vendors/my-shop")
assert response.status_code == 200
data = response.json()
@@ -246,7 +246,7 @@ class TestLetzshopVendorLookupAPI:
def test_get_vendor_normalizes_slug(self, client):
"""Test that get vendor normalizes slug to lowercase."""
response = client.get("/api/v1/platform/letzshop-vendors/MY-SHOP")
response = client.get("/api/v1/public/letzshop-vendors/MY-SHOP")
assert response.status_code == 200
data = response.json()
@@ -254,7 +254,7 @@ class TestLetzshopVendorLookupAPI:
def test_get_claimed_vendor_shows_status(self, client, claimed_vendor):
"""Test that get vendor shows claimed status correctly."""
response = client.get("/api/v1/platform/letzshop-vendors/claimed-shop")
response = client.get("/api/v1/public/letzshop-vendors/claimed-shop")
assert response.status_code == 200
data = response.json()
@@ -262,7 +262,7 @@ class TestLetzshopVendorLookupAPI:
def test_get_unclaimed_vendor_shows_status(self, client):
"""Test that get vendor shows unclaimed status correctly."""
response = client.get("/api/v1/platform/letzshop-vendors/new-unclaimed-shop")
response = client.get("/api/v1/public/letzshop-vendors/new-unclaimed-shop")
assert response.status_code == 200
data = response.json()
@@ -278,7 +278,7 @@ class TestLetzshopSlugExtraction:
def test_extract_from_full_https_url(self, client):
"""Test extraction from https://letzshop.lu/vendors/slug."""
response = client.post(
"/api/v1/platform/letzshop-vendors/lookup",
"/api/v1/public/letzshop-vendors/lookup",
json={"url": "https://letzshop.lu/vendors/cafe-luxembourg"},
)
assert response.json()["vendor"]["slug"] == "cafe-luxembourg"
@@ -286,7 +286,7 @@ class TestLetzshopSlugExtraction:
def test_extract_from_http_url(self, client):
"""Test extraction from http://letzshop.lu/vendors/slug."""
response = client.post(
"/api/v1/platform/letzshop-vendors/lookup",
"/api/v1/public/letzshop-vendors/lookup",
json={"url": "http://letzshop.lu/vendors/my-shop"},
)
assert response.json()["vendor"]["slug"] == "my-shop"
@@ -294,7 +294,7 @@ class TestLetzshopSlugExtraction:
def test_extract_from_url_with_trailing_slash(self, client):
"""Test extraction from URL with trailing slash."""
response = client.post(
"/api/v1/platform/letzshop-vendors/lookup",
"/api/v1/public/letzshop-vendors/lookup",
json={"url": "https://letzshop.lu/vendors/my-shop/"},
)
assert response.json()["vendor"]["slug"] == "my-shop"
@@ -302,7 +302,7 @@ class TestLetzshopSlugExtraction:
def test_extract_from_url_with_query_params(self, client):
"""Test extraction from URL with query parameters."""
response = client.post(
"/api/v1/platform/letzshop-vendors/lookup",
"/api/v1/public/letzshop-vendors/lookup",
json={"url": "https://letzshop.lu/vendors/my-shop?ref=google"},
)
assert response.json()["vendor"]["slug"] == "my-shop"
@@ -310,7 +310,7 @@ class TestLetzshopSlugExtraction:
def test_extract_from_french_url(self, client):
"""Test extraction from French language URL."""
response = client.post(
"/api/v1/platform/letzshop-vendors/lookup",
"/api/v1/public/letzshop-vendors/lookup",
json={"url": "https://letzshop.lu/fr/vendors/boulangerie-paul"},
)
assert response.json()["vendor"]["slug"] == "boulangerie-paul"
@@ -318,7 +318,7 @@ class TestLetzshopSlugExtraction:
def test_extract_from_german_url(self, client):
"""Test extraction from German language URL."""
response = client.post(
"/api/v1/platform/letzshop-vendors/lookup",
"/api/v1/public/letzshop-vendors/lookup",
json={"url": "https://letzshop.lu/de/vendors/backerei-muller"},
)
assert response.json()["vendor"]["slug"] == "backerei-muller"

View File

@@ -1,7 +1,7 @@
# tests/integration/api/v1/platform/test_pricing.py
# tests/integration/api/v1/public/test_pricing.py
"""Integration tests for platform pricing API endpoints.
Tests the /api/v1/platform/pricing/* endpoints.
Tests the /api/v1/public/pricing/* endpoints.
"""
import pytest
@@ -18,15 +18,15 @@ from app.modules.billing.models import (
@pytest.mark.api
@pytest.mark.platform
class TestPlatformPricingAPI:
"""Test platform pricing endpoints at /api/v1/platform/*."""
"""Test platform pricing endpoints at /api/v1/public/*."""
# =========================================================================
# GET /api/v1/platform/tiers
# GET /api/v1/public/tiers
# =========================================================================
def test_get_tiers_returns_all_public_tiers(self, client):
"""Test getting all subscription tiers."""
response = client.get("/api/v1/platform/tiers")
response = client.get("/api/v1/public/tiers")
assert response.status_code == 200
data = response.json()
@@ -35,7 +35,7 @@ class TestPlatformPricingAPI:
def test_get_tiers_has_expected_fields(self, client):
"""Test that tier response has all expected fields."""
response = client.get("/api/v1/platform/tiers")
response = client.get("/api/v1/public/tiers")
assert response.status_code == 200
data = response.json()
@@ -55,7 +55,7 @@ class TestPlatformPricingAPI:
def test_get_tiers_includes_essential(self, client):
"""Test that Essential tier is included."""
response = client.get("/api/v1/platform/tiers")
response = client.get("/api/v1/public/tiers")
assert response.status_code == 200
data = response.json()
@@ -64,7 +64,7 @@ class TestPlatformPricingAPI:
def test_get_tiers_includes_professional(self, client):
"""Test that Professional tier is included and marked as popular."""
response = client.get("/api/v1/platform/tiers")
response = client.get("/api/v1/public/tiers")
assert response.status_code == 200
data = response.json()
@@ -77,7 +77,7 @@ class TestPlatformPricingAPI:
def test_get_tiers_includes_enterprise(self, client):
"""Test that Enterprise tier is included and marked appropriately."""
response = client.get("/api/v1/platform/tiers")
response = client.get("/api/v1/public/tiers")
assert response.status_code == 200
data = response.json()
@@ -108,7 +108,7 @@ class TestPlatformPricingAPI:
db.add(tier)
db.commit()
response = client.get("/api/v1/platform/tiers")
response = client.get("/api/v1/public/tiers")
assert response.status_code == 200
data = response.json()
@@ -116,12 +116,12 @@ class TestPlatformPricingAPI:
assert "test_tier" in tier_codes
# =========================================================================
# GET /api/v1/platform/tiers/{tier_code}
# GET /api/v1/public/tiers/{tier_code}
# =========================================================================
def test_get_tier_by_code_success(self, client):
"""Test getting a specific tier by code."""
response = client.get(f"/api/v1/platform/tiers/{TierCode.PROFESSIONAL.value}")
response = client.get(f"/api/v1/public/tiers/{TierCode.PROFESSIONAL.value}")
assert response.status_code == 200
data = response.json()
@@ -130,7 +130,7 @@ class TestPlatformPricingAPI:
def test_get_tier_by_code_essential(self, client):
"""Test getting Essential tier details."""
response = client.get(f"/api/v1/platform/tiers/{TierCode.ESSENTIAL.value}")
response = client.get(f"/api/v1/public/tiers/{TierCode.ESSENTIAL.value}")
assert response.status_code == 200
data = response.json()
@@ -139,19 +139,19 @@ class TestPlatformPricingAPI:
def test_get_tier_by_code_not_found(self, client):
"""Test getting a non-existent tier returns 404."""
response = client.get("/api/v1/platform/tiers/nonexistent_tier")
response = client.get("/api/v1/public/tiers/nonexistent_tier")
assert response.status_code == 404
data = response.json()
assert "not found" in data["message"].lower()
# =========================================================================
# GET /api/v1/platform/addons
# GET /api/v1/public/addons
# =========================================================================
def test_get_addons_empty_when_none_configured(self, client):
"""Test getting add-ons when none are configured."""
response = client.get("/api/v1/platform/addons")
response = client.get("/api/v1/public/addons")
assert response.status_code == 200
data = response.json()
@@ -173,7 +173,7 @@ class TestPlatformPricingAPI:
db.add(addon)
db.commit()
response = client.get("/api/v1/platform/addons")
response = client.get("/api/v1/public/addons")
assert response.status_code == 200
data = response.json()
@@ -197,7 +197,7 @@ class TestPlatformPricingAPI:
db.add(addon)
db.commit()
response = client.get("/api/v1/platform/addons")
response = client.get("/api/v1/public/addons")
assert response.status_code == 200
data = response.json()
@@ -236,7 +236,7 @@ class TestPlatformPricingAPI:
db.add_all([active_addon, inactive_addon])
db.commit()
response = client.get("/api/v1/platform/addons")
response = client.get("/api/v1/public/addons")
assert response.status_code == 200
data = response.json()
@@ -245,12 +245,12 @@ class TestPlatformPricingAPI:
assert "inactive_addon" not in addon_codes
# =========================================================================
# GET /api/v1/platform/pricing
# GET /api/v1/public/pricing
# =========================================================================
def test_get_pricing_returns_complete_info(self, client):
"""Test getting complete pricing information."""
response = client.get("/api/v1/platform/pricing")
response = client.get("/api/v1/public/pricing")
assert response.status_code == 200
data = response.json()
@@ -262,7 +262,7 @@ class TestPlatformPricingAPI:
def test_get_pricing_includes_trial_days(self, client):
"""Test that pricing includes correct trial period."""
response = client.get("/api/v1/platform/pricing")
response = client.get("/api/v1/public/pricing")
assert response.status_code == 200
data = response.json()
@@ -270,7 +270,7 @@ class TestPlatformPricingAPI:
def test_get_pricing_includes_annual_discount(self, client):
"""Test that pricing includes annual discount info."""
response = client.get("/api/v1/platform/pricing")
response = client.get("/api/v1/public/pricing")
assert response.status_code == 200
data = response.json()
@@ -278,7 +278,7 @@ class TestPlatformPricingAPI:
def test_get_pricing_tiers_not_empty(self, client):
"""Test that pricing always includes tiers."""
response = client.get("/api/v1/platform/pricing")
response = client.get("/api/v1/public/pricing")
assert response.status_code == 200
data = response.json()

View File

@@ -1,7 +1,7 @@
# tests/integration/api/v1/platform/test_signup.py
# tests/integration/api/v1/public/test_signup.py
"""Integration tests for platform signup API endpoints.
Tests the /api/v1/platform/signup/* endpoints.
Tests the /api/v1/public/signup/* endpoints.
"""
from unittest.mock import MagicMock, patch
@@ -17,7 +17,7 @@ from models.database.vendor import Vendor
@pytest.fixture
def mock_stripe_service():
"""Mock the Stripe service for tests."""
with patch("app.services.platform_signup_service.stripe_service") as mock:
with patch("app.modules.marketplace.services.platform_signup_service.stripe_service") as mock:
mock.create_customer.return_value = "cus_test_123"
mock.create_setup_intent.return_value = MagicMock(
id="seti_test_123",
@@ -37,7 +37,7 @@ def mock_stripe_service():
def signup_session(client):
"""Create a signup session for testing."""
response = client.post(
"/api/v1/platform/signup/start",
"/api/v1/public/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/platform/signup/start."""
"""Test signup start endpoint at /api/v1/public/signup/start."""
def test_start_signup_success(self, client):
"""Test starting a signup session."""
response = client.post(
"/api/v1/platform/signup/start",
"/api/v1/public/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/platform/signup/start",
"/api/v1/public/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/platform/signup/start",
"/api/v1/public/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/platform/signup/start",
"/api/v1/public/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/platform/signup/start",
"/api/v1/public/signup/start",
json={"tier_code": TierCode.ESSENTIAL.value, "is_annual": False},
)
response2 = client.post(
"/api/v1/platform/signup/start",
"/api/v1/public/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/platform/signup/claim-vendor."""
"""Test claim vendor endpoint at /api/v1/public/signup/claim-vendor."""
def test_claim_vendor_success(self, client, signup_session):
"""Test claiming a Letzshop vendor."""
response = client.post(
"/api/v1/platform/signup/claim-vendor",
"/api/v1/public/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/platform/signup/claim-vendor",
"/api/v1/public/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/platform/signup/claim-vendor",
"/api/v1/public/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/platform/signup/claim-vendor",
"/api/v1/public/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/platform/signup/create-account."""
"""Test create account endpoint at /api/v1/public/signup/create-account."""
def test_create_account_success(self, client, signup_session, mock_stripe_service):
"""Test creating an account."""
response = client.post(
"/api/v1/platform/signup/create-account",
"/api/v1/public/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/platform/signup/create-account",
"/api/v1/public/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/platform/signup/create-account",
"/api/v1/public/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/platform/signup/create-account",
"/api/v1/public/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/platform/signup/create-account",
"/api/v1/public/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/platform/signup/start",
"/api/v1/public/signup/start",
json={"tier_code": TierCode.PROFESSIONAL.value, "is_annual": False},
)
session_id = start_response.json()["session_id"]
# Claim vendor
client.post(
"/api/v1/platform/signup/claim-vendor",
"/api/v1/public/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/platform/signup/create-account",
"/api/v1/public/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/platform/signup/setup-payment."""
"""Test setup payment endpoint at /api/v1/public/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/platform/signup/create-account",
"/api/v1/public/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/platform/signup/setup-payment",
"/api/v1/public/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/platform/signup/setup-payment",
"/api/v1/public/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/platform/signup/setup-payment",
"/api/v1/public/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/platform/signup/complete."""
"""Test complete signup endpoint at /api/v1/public/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/platform/signup/create-account",
"/api/v1/public/signup/create-account",
json={
"session_id": signup_session,
"email": "complete@example.com",
@@ -442,13 +442,13 @@ class TestCompleteSignupAPI:
# Setup payment
client.post(
"/api/v1/platform/signup/setup-payment",
"/api/v1/public/signup/setup-payment",
json={"session_id": signup_session},
)
# Complete signup
response = client.post(
"/api/v1/platform/signup/complete",
"/api/v1/public/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/platform/signup/create-account",
"/api/v1/public/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/platform/signup/setup-payment",
"/api/v1/public/signup/setup-payment",
json={"session_id": signup_session},
)
# Complete signup
response = client.post(
"/api/v1/platform/signup/complete",
"/api/v1/public/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/platform/signup/create-account",
"/api/v1/public/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/platform/signup/setup-payment",
"/api/v1/public/signup/setup-payment",
json={"session_id": signup_session},
)
# Complete signup
complete_response = client.post(
"/api/v1/platform/signup/complete",
"/api/v1/public/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/platform/signup/create-account",
"/api/v1/public/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/platform/signup/setup-payment",
"/api/v1/public/signup/setup-payment",
json={"session_id": signup_session},
)
# Complete signup
response = client.post(
"/api/v1/platform/signup/complete",
"/api/v1/public/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/platform/signup/complete",
"/api/v1/public/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/platform/signup/create-account",
"/api/v1/public/signup/create-account",
json={
"session_id": signup_session,
"email": "fail@example.com",
@@ -616,7 +616,7 @@ class TestCompleteSignupAPI:
# Setup payment
client.post(
"/api/v1/platform/signup/setup-payment",
"/api/v1/public/signup/setup-payment",
json={"session_id": signup_session},
)
@@ -629,7 +629,7 @@ class TestCompleteSignupAPI:
# Complete signup
response = client.post(
"/api/v1/platform/signup/complete",
"/api/v1/public/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/platform/signup/session/{session_id}."""
"""Test get signup session endpoint at /api/v1/public/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/platform/signup/session/{signup_session}")
response = client.get(f"/api/v1/public/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/platform/signup/claim-vendor",
"/api/v1/public/signup/claim-vendor",
json={
"session_id": signup_session,
"letzshop_slug": "my-session-shop",
},
)
response = client.get(f"/api/v1/platform/signup/session/{signup_session}")
response = client.get(f"/api/v1/public/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/platform/signup/session/invalid_id")
response = client.get("/api/v1/public/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/platform/signup/start",
"/api/v1/public/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/platform/signup/claim-vendor",
"/api/v1/public/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/platform/signup/create-account",
"/api/v1/public/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/platform/signup/setup-payment",
"/api/v1/public/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/platform/signup/complete",
"/api/v1/public/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/platform/signup/start",
"/api/v1/public/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/platform/signup/create-account",
"/api/v1/public/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/platform/signup/setup-payment",
"/api/v1/public/signup/setup-payment",
json={"session_id": session_id},
)
complete_response = client.post(
"/api/v1/platform/signup/complete",
"/api/v1/public/signup/complete",
json={
"session_id": session_id,
"setup_intent_id": "seti_test_123",

View File

@@ -165,7 +165,7 @@ class TestVendorLetzshopConnectionAPI:
assert data["success"] is False
assert "not configured" in data["error_details"]
@patch("app.services.letzshop.client_service.requests.Session.post")
@patch("app.modules.marketplace.services.letzshop.client_service.requests.Session.post")
def test_test_connection_success(
self, mock_post, client, vendor_user_headers, test_vendor_with_vendor_user
):
@@ -193,7 +193,7 @@ class TestVendorLetzshopConnectionAPI:
assert data["success"] is True
assert data["response_time_ms"] is not None
@patch("app.services.letzshop.client_service.requests.Session.post")
@patch("app.modules.marketplace.services.letzshop.client_service.requests.Session.post")
def test_test_api_key_without_saving(
self, mock_post, client, vendor_user_headers, test_vendor_with_vendor_user
):
@@ -382,7 +382,7 @@ class TestVendorLetzshopOrdersAPI:
assert response.status_code == 422 # Validation error
@patch("app.services.letzshop.client_service.requests.Session.post")
@patch("app.modules.marketplace.services.letzshop.client_service.requests.Session.post")
def test_import_orders_success(
self,
mock_post,
@@ -445,7 +445,7 @@ class TestVendorLetzshopOrdersAPI:
class TestVendorLetzshopFulfillmentAPI:
"""Test vendor Letzshop fulfillment endpoints."""
@patch("app.services.letzshop.client_service.requests.Session.post")
@patch("app.modules.marketplace.services.letzshop.client_service.requests.Session.post")
def test_confirm_order(
self,
mock_post,
@@ -534,7 +534,7 @@ class TestVendorLetzshopFulfillmentAPI:
data = response.json()
assert data["success"] is True
@patch("app.services.letzshop.client_service.requests.Session.post")
@patch("app.modules.marketplace.services.letzshop.client_service.requests.Session.post")
def test_set_tracking(
self,
mock_post,