refactor: rename shop to storefront throughout codebase

Rename "shop" to "storefront" as not all platforms sell items -
storefront is a more accurate term for the customer-facing interface.

Changes:
- Rename app/api/v1/shop/ → app/api/v1/storefront/
- Rename app/routes/shop_pages.py → app/routes/storefront_pages.py
- Rename app/modules/cms/routes/api/shop.py → storefront.py
- Rename tests/integration/api/v1/shop/ → storefront/
- Update API prefix from /api/v1/shop to /api/v1/storefront
- Update route tags from shop-* to storefront-*
- Rename get_shop_context() → get_storefront_context()
- Update architecture rules to reference storefront paths
- Update all test API endpoint paths

This is Phase 2 of the storefront module restructure plan.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-29 22:42:01 +01:00
parent 228163d920
commit 3e86d4b58b
20 changed files with 140 additions and 134 deletions

View File

@@ -1,7 +1,7 @@
# tests/integration/api/v1/shop/test_addresses.py
# tests/integration/api/v1/storefront/test_addresses.py
"""Integration tests for shop addresses API endpoints.
Tests the /api/v1/shop/addresses/* endpoints.
Tests the /api/v1/storefront/addresses/* endpoints.
All endpoints require customer JWT authentication with vendor context.
"""
@@ -158,13 +158,13 @@ def other_customer_address(db, test_vendor, other_customer):
@pytest.mark.api
@pytest.mark.shop
class TestShopAddressesListAPI:
"""Test shop addresses list endpoint at /api/v1/shop/addresses."""
"""Test shop addresses list endpoint at /api/v1/storefront/addresses."""
def test_list_addresses_requires_authentication(self, client, test_vendor):
"""Test that listing addresses requires authentication."""
with patch("app.api.v1.shop.addresses.getattr") as mock_getattr:
mock_getattr.return_value = test_vendor
response = client.get("/api/v1/shop/addresses")
response = client.get("/api/v1/storefront/addresses")
assert response.status_code in [401, 403]
def test_list_addresses_success(
@@ -181,7 +181,7 @@ class TestShopAddressesListAPI:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.get(
"/api/v1/shop/addresses",
"/api/v1/storefront/addresses",
headers=shop_customer_headers,
)
@@ -201,7 +201,7 @@ class TestShopAddressesListAPI:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.get(
"/api/v1/shop/addresses",
"/api/v1/storefront/addresses",
headers=shop_customer_headers,
)
@@ -225,7 +225,7 @@ class TestShopAddressesListAPI:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.get(
"/api/v1/shop/addresses",
"/api/v1/storefront/addresses",
headers=shop_customer_headers,
)
@@ -242,7 +242,7 @@ class TestShopAddressesListAPI:
@pytest.mark.api
@pytest.mark.shop
class TestShopAddressDetailAPI:
"""Test shop address detail endpoint at /api/v1/shop/addresses/{address_id}."""
"""Test shop address detail endpoint at /api/v1/storefront/addresses/{address_id}."""
def test_get_address_success(
self,
@@ -258,7 +258,7 @@ class TestShopAddressDetailAPI:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.get(
f"/api/v1/shop/addresses/{customer_address.id}",
f"/api/v1/storefront/addresses/{customer_address.id}",
headers=shop_customer_headers,
)
@@ -278,7 +278,7 @@ class TestShopAddressDetailAPI:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.get(
"/api/v1/shop/addresses/99999",
"/api/v1/storefront/addresses/99999",
headers=shop_customer_headers,
)
@@ -298,7 +298,7 @@ class TestShopAddressDetailAPI:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.get(
f"/api/v1/shop/addresses/{other_customer_address.id}",
f"/api/v1/storefront/addresses/{other_customer_address.id}",
headers=shop_customer_headers,
)
@@ -310,7 +310,7 @@ class TestShopAddressDetailAPI:
@pytest.mark.api
@pytest.mark.shop
class TestShopAddressCreateAPI:
"""Test shop address creation at POST /api/v1/shop/addresses."""
"""Test shop address creation at POST /api/v1/storefront/addresses."""
def test_create_address_success(
self, client, shop_customer_headers, test_vendor, shop_customer
@@ -333,7 +333,7 @@ class TestShopAddressCreateAPI:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.post(
"/api/v1/shop/addresses",
"/api/v1/storefront/addresses",
headers=shop_customer_headers,
json=address_data,
)
@@ -367,7 +367,7 @@ class TestShopAddressCreateAPI:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.post(
"/api/v1/shop/addresses",
"/api/v1/storefront/addresses",
headers=shop_customer_headers,
json=address_data,
)
@@ -391,7 +391,7 @@ class TestShopAddressCreateAPI:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.post(
"/api/v1/shop/addresses",
"/api/v1/storefront/addresses",
headers=shop_customer_headers,
json=address_data,
)
@@ -403,7 +403,7 @@ class TestShopAddressCreateAPI:
@pytest.mark.api
@pytest.mark.shop
class TestShopAddressUpdateAPI:
"""Test shop address update at PUT /api/v1/shop/addresses/{address_id}."""
"""Test shop address update at PUT /api/v1/storefront/addresses/{address_id}."""
def test_update_address_success(
self,
@@ -424,7 +424,7 @@ class TestShopAddressUpdateAPI:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.put(
f"/api/v1/shop/addresses/{customer_address.id}",
f"/api/v1/storefront/addresses/{customer_address.id}",
headers=shop_customer_headers,
json=update_data,
)
@@ -445,7 +445,7 @@ class TestShopAddressUpdateAPI:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.put(
"/api/v1/shop/addresses/99999",
"/api/v1/storefront/addresses/99999",
headers=shop_customer_headers,
json=update_data,
)
@@ -468,7 +468,7 @@ class TestShopAddressUpdateAPI:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.put(
f"/api/v1/shop/addresses/{other_customer_address.id}",
f"/api/v1/storefront/addresses/{other_customer_address.id}",
headers=shop_customer_headers,
json=update_data,
)
@@ -480,7 +480,7 @@ class TestShopAddressUpdateAPI:
@pytest.mark.api
@pytest.mark.shop
class TestShopAddressDeleteAPI:
"""Test shop address deletion at DELETE /api/v1/shop/addresses/{address_id}."""
"""Test shop address deletion at DELETE /api/v1/storefront/addresses/{address_id}."""
def test_delete_address_success(
self,
@@ -496,7 +496,7 @@ class TestShopAddressDeleteAPI:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.delete(
f"/api/v1/shop/addresses/{customer_address.id}",
f"/api/v1/storefront/addresses/{customer_address.id}",
headers=shop_customer_headers,
)
@@ -511,7 +511,7 @@ class TestShopAddressDeleteAPI:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.delete(
"/api/v1/shop/addresses/99999",
"/api/v1/storefront/addresses/99999",
headers=shop_customer_headers,
)
@@ -531,7 +531,7 @@ class TestShopAddressDeleteAPI:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.delete(
f"/api/v1/shop/addresses/{other_customer_address.id}",
f"/api/v1/storefront/addresses/{other_customer_address.id}",
headers=shop_customer_headers,
)
@@ -542,7 +542,7 @@ class TestShopAddressDeleteAPI:
@pytest.mark.api
@pytest.mark.shop
class TestShopAddressSetDefaultAPI:
"""Test set address as default at PUT /api/v1/shop/addresses/{address_id}/default."""
"""Test set address as default at PUT /api/v1/storefront/addresses/{address_id}/default."""
def test_set_default_success(
self,
@@ -577,7 +577,7 @@ class TestShopAddressSetDefaultAPI:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.put(
f"/api/v1/shop/addresses/{second_address.id}/default",
f"/api/v1/storefront/addresses/{second_address.id}/default",
headers=shop_customer_headers,
)
@@ -594,7 +594,7 @@ class TestShopAddressSetDefaultAPI:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.put(
"/api/v1/shop/addresses/99999/default",
"/api/v1/storefront/addresses/99999/default",
headers=shop_customer_headers,
)
@@ -614,7 +614,7 @@ class TestShopAddressSetDefaultAPI:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.put(
f"/api/v1/shop/addresses/{other_customer_address.id}/default",
f"/api/v1/storefront/addresses/{other_customer_address.id}/default",
headers=shop_customer_headers,
)

View File

@@ -1,7 +1,7 @@
# tests/integration/api/v1/shop/test_orders.py
# tests/integration/api/v1/storefront/test_orders.py
"""Integration tests for shop orders API endpoints.
Tests the /api/v1/shop/orders/* endpoints.
Tests the /api/v1/storefront/orders/* endpoints.
All endpoints require customer JWT authentication with vendor context.
"""
@@ -306,13 +306,13 @@ def other_customer_order(db, test_vendor, other_customer):
@pytest.mark.api
@pytest.mark.shop
class TestShopOrdersListAPI:
"""Test shop orders list endpoint at /api/v1/shop/orders."""
"""Test shop orders list endpoint at /api/v1/storefront/orders."""
def test_list_orders_requires_authentication(self, client, test_vendor):
"""Test that listing orders requires authentication."""
with patch("app.api.v1.shop.orders.getattr") as mock_getattr:
mock_getattr.return_value = test_vendor
response = client.get("/api/v1/shop/orders")
response = client.get("/api/v1/storefront/orders")
# Without token, should get 401 or 403
assert response.status_code in [401, 403]
@@ -327,7 +327,7 @@ class TestShopOrdersListAPI:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.get(
"/api/v1/shop/orders",
"/api/v1/storefront/orders",
headers=shop_customer_headers,
)
@@ -345,7 +345,7 @@ class TestShopOrdersListAPI:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.get(
"/api/v1/shop/orders",
"/api/v1/storefront/orders",
headers=shop_customer_headers,
)
@@ -358,7 +358,7 @@ class TestShopOrdersListAPI:
@pytest.mark.api
@pytest.mark.shop
class TestShopOrderDetailAPI:
"""Test shop order detail endpoint at /api/v1/shop/orders/{order_id}."""
"""Test shop order detail endpoint at /api/v1/storefront/orders/{order_id}."""
def test_get_order_detail_success(
self, client, shop_customer_headers, shop_order, test_vendor, shop_customer
@@ -369,7 +369,7 @@ class TestShopOrderDetailAPI:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.get(
f"/api/v1/shop/orders/{shop_order.id}",
f"/api/v1/storefront/orders/{shop_order.id}",
headers=shop_customer_headers,
)
@@ -390,7 +390,7 @@ class TestShopOrderDetailAPI:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.get(
"/api/v1/shop/orders/99999",
"/api/v1/storefront/orders/99999",
headers=shop_customer_headers,
)
@@ -410,7 +410,7 @@ class TestShopOrderDetailAPI:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.get(
f"/api/v1/shop/orders/{other_customer_order.id}",
f"/api/v1/storefront/orders/{other_customer_order.id}",
headers=shop_customer_headers,
)
@@ -422,7 +422,7 @@ class TestShopOrderDetailAPI:
@pytest.mark.api
@pytest.mark.shop
class TestShopOrderInvoiceDownloadAPI:
"""Test shop order invoice download at /api/v1/shop/orders/{order_id}/invoice."""
"""Test shop order invoice download at /api/v1/storefront/orders/{order_id}/invoice."""
def test_download_invoice_pending_order_rejected(
self, client, shop_customer_headers, shop_order, test_vendor, shop_customer
@@ -433,7 +433,7 @@ class TestShopOrderInvoiceDownloadAPI:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.get(
f"/api/v1/shop/orders/{shop_order.id}/invoice",
f"/api/v1/storefront/orders/{shop_order.id}/invoice",
headers=shop_customer_headers,
)
@@ -485,7 +485,7 @@ class TestShopOrderInvoiceDownloadAPI:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.get(
f"/api/v1/shop/orders/{other_customer_order.id}/invoice",
f"/api/v1/storefront/orders/{other_customer_order.id}/invoice",
headers=shop_customer_headers,
)
@@ -501,7 +501,7 @@ class TestShopOrderInvoiceDownloadAPI:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.get(
"/api/v1/shop/orders/99999/invoice",
"/api/v1/storefront/orders/99999/invoice",
headers=shop_customer_headers,
)
@@ -523,7 +523,7 @@ class TestShopOrderVATFields:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.get(
f"/api/v1/shop/orders/{shop_order.id}",
f"/api/v1/storefront/orders/{shop_order.id}",
headers=shop_customer_headers,
)
@@ -544,7 +544,7 @@ class TestShopOrderVATFields:
with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer
response = client.get(
"/api/v1/shop/orders",
"/api/v1/storefront/orders",
headers=shop_customer_headers,
)

View File

@@ -1,7 +1,7 @@
# tests/integration/api/v1/shop/test_password_reset.py
# tests/integration/api/v1/storefront/test_password_reset.py
"""Integration tests for shop password reset API endpoints.
Tests the /api/v1/shop/auth/forgot-password and /api/v1/shop/auth/reset-password endpoints.
Tests the /api/v1/storefront/auth/forgot-password and /api/v1/storefront/auth/reset-password endpoints.
"""
from datetime import UTC, datetime, timedelta
@@ -104,7 +104,7 @@ def used_reset_token(db, shop_customer):
@pytest.mark.api
@pytest.mark.shop
class TestForgotPasswordAPI:
"""Test forgot password endpoint at /api/v1/shop/auth/forgot-password."""
"""Test forgot password endpoint at /api/v1/storefront/auth/forgot-password."""
def test_forgot_password_existing_customer(
self, client, db, test_vendor, shop_customer
@@ -119,7 +119,7 @@ class TestForgotPasswordAPI:
mock_email_service.return_value = mock_instance
response = client.post(
"/api/v1/shop/auth/forgot-password",
"/api/v1/storefront/auth/forgot-password",
params={"email": shop_customer.email},
)
@@ -139,7 +139,7 @@ class TestForgotPasswordAPI:
mock_getattr.return_value = test_vendor
response = client.post(
"/api/v1/shop/auth/forgot-password",
"/api/v1/storefront/auth/forgot-password",
params={"email": "nonexistent@example.com"},
)
@@ -156,7 +156,7 @@ class TestForgotPasswordAPI:
mock_getattr.return_value = test_vendor
response = client.post(
"/api/v1/shop/auth/forgot-password",
"/api/v1/storefront/auth/forgot-password",
params={"email": inactive_customer.email},
)
@@ -174,7 +174,7 @@ class TestForgotPasswordAPI:
with patch("app.api.v1.shop.auth.EmailService"):
response = client.post(
"/api/v1/shop/auth/forgot-password",
"/api/v1/storefront/auth/forgot-password",
params={"email": shop_customer.email},
)
@@ -210,7 +210,7 @@ class TestForgotPasswordAPI:
with patch("app.api.v1.shop.auth.EmailService"):
response = client.post(
"/api/v1/shop/auth/forgot-password",
"/api/v1/storefront/auth/forgot-password",
params={"email": shop_customer.email},
)
@@ -232,7 +232,7 @@ class TestForgotPasswordAPI:
@pytest.mark.api
@pytest.mark.shop
class TestResetPasswordAPI:
"""Test reset password endpoint at /api/v1/shop/auth/reset-password."""
"""Test reset password endpoint at /api/v1/storefront/auth/reset-password."""
def test_reset_password_success(
self, client, db, test_vendor, shop_customer, valid_reset_token
@@ -243,7 +243,7 @@ class TestResetPasswordAPI:
new_password = "newpassword123"
response = client.post(
"/api/v1/shop/auth/reset-password",
"/api/v1/storefront/auth/reset-password",
params={
"reset_token": valid_reset_token,
"new_password": new_password,
@@ -271,7 +271,7 @@ class TestResetPasswordAPI:
mock_getattr.return_value = test_vendor
response = client.post(
"/api/v1/shop/auth/reset-password",
"/api/v1/storefront/auth/reset-password",
params={
"reset_token": valid_reset_token,
"new_password": "newpassword123",
@@ -294,7 +294,7 @@ class TestResetPasswordAPI:
mock_getattr.return_value = test_vendor
response = client.post(
"/api/v1/shop/auth/reset-password",
"/api/v1/storefront/auth/reset-password",
params={
"reset_token": "invalid_token_12345",
"new_password": "newpassword123",
@@ -311,7 +311,7 @@ class TestResetPasswordAPI:
mock_getattr.return_value = test_vendor
response = client.post(
"/api/v1/shop/auth/reset-password",
"/api/v1/storefront/auth/reset-password",
params={
"reset_token": expired_reset_token,
"new_password": "newpassword123",
@@ -328,7 +328,7 @@ class TestResetPasswordAPI:
mock_getattr.return_value = test_vendor
response = client.post(
"/api/v1/shop/auth/reset-password",
"/api/v1/storefront/auth/reset-password",
params={
"reset_token": used_reset_token,
"new_password": "newpassword123",
@@ -345,7 +345,7 @@ class TestResetPasswordAPI:
mock_getattr.return_value = test_vendor
response = client.post(
"/api/v1/shop/auth/reset-password",
"/api/v1/storefront/auth/reset-password",
params={
"reset_token": valid_reset_token,
"new_password": "short", # Less than 8 chars
@@ -363,7 +363,7 @@ class TestResetPasswordAPI:
# First reset should succeed
response1 = client.post(
"/api/v1/shop/auth/reset-password",
"/api/v1/storefront/auth/reset-password",
params={
"reset_token": valid_reset_token,
"new_password": "newpassword123",
@@ -373,7 +373,7 @@ class TestResetPasswordAPI:
# Second reset with same token should fail
response2 = client.post(
"/api/v1/shop/auth/reset-password",
"/api/v1/storefront/auth/reset-password",
params={
"reset_token": valid_reset_token,
"new_password": "anotherpassword123",