fix: update test patch paths for module routes
Update test files to use new module route paths: - test_password_reset.py: app.api.v1.shop.auth -> app.modules.customers.routes.api.storefront - test_addresses.py: app.api.v1.shop.addresses -> app.modules.customers.routes.api.storefront - test_orders.py: app.api.v1.shop.orders -> app.modules.orders.routes.api.storefront Note: Some tests still fail due to patching built-in functions incorrectly. These tests need further refactoring to match the new module architecture. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -162,7 +162,7 @@ class TestShopAddressesListAPI:
|
||||
|
||||
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:
|
||||
with patch("app.modules.customers.routes.api.storefront.addresses.getattr") as mock_getattr:
|
||||
mock_getattr.return_value = test_vendor
|
||||
response = client.get("/api/v1/storefront/addresses")
|
||||
assert response.status_code in [401, 403]
|
||||
@@ -176,7 +176,7 @@ class TestShopAddressesListAPI:
|
||||
shop_customer,
|
||||
):
|
||||
"""Test listing customer addresses successfully."""
|
||||
with patch("app.api.v1.shop.addresses.getattr") as mock_getattr:
|
||||
with patch("app.modules.customers.routes.api.storefront.addresses.getattr") as mock_getattr:
|
||||
mock_getattr.return_value = test_vendor
|
||||
with patch("app.api.deps._validate_customer_token") as mock_validate:
|
||||
mock_validate.return_value = shop_customer
|
||||
@@ -196,7 +196,7 @@ class TestShopAddressesListAPI:
|
||||
self, client, shop_customer_headers, test_vendor, shop_customer
|
||||
):
|
||||
"""Test listing addresses when customer has none."""
|
||||
with patch("app.api.v1.shop.addresses.getattr") as mock_getattr:
|
||||
with patch("app.modules.customers.routes.api.storefront.addresses.getattr") as mock_getattr:
|
||||
mock_getattr.return_value = test_vendor
|
||||
with patch("app.api.deps._validate_customer_token") as mock_validate:
|
||||
mock_validate.return_value = shop_customer
|
||||
@@ -220,7 +220,7 @@ class TestShopAddressesListAPI:
|
||||
shop_customer,
|
||||
):
|
||||
"""Test listing addresses includes both shipping and billing."""
|
||||
with patch("app.api.v1.shop.addresses.getattr") as mock_getattr:
|
||||
with patch("app.modules.customers.routes.api.storefront.addresses.getattr") as mock_getattr:
|
||||
mock_getattr.return_value = test_vendor
|
||||
with patch("app.api.deps._validate_customer_token") as mock_validate:
|
||||
mock_validate.return_value = shop_customer
|
||||
@@ -253,7 +253,7 @@ class TestShopAddressDetailAPI:
|
||||
shop_customer,
|
||||
):
|
||||
"""Test getting address details successfully."""
|
||||
with patch("app.api.v1.shop.addresses.getattr") as mock_getattr:
|
||||
with patch("app.modules.customers.routes.api.storefront.addresses.getattr") as mock_getattr:
|
||||
mock_getattr.return_value = test_vendor
|
||||
with patch("app.api.deps._validate_customer_token") as mock_validate:
|
||||
mock_validate.return_value = shop_customer
|
||||
@@ -273,7 +273,7 @@ class TestShopAddressDetailAPI:
|
||||
self, client, shop_customer_headers, test_vendor, shop_customer
|
||||
):
|
||||
"""Test getting non-existent address returns 404."""
|
||||
with patch("app.api.v1.shop.addresses.getattr") as mock_getattr:
|
||||
with patch("app.modules.customers.routes.api.storefront.addresses.getattr") as mock_getattr:
|
||||
mock_getattr.return_value = test_vendor
|
||||
with patch("app.api.deps._validate_customer_token") as mock_validate:
|
||||
mock_validate.return_value = shop_customer
|
||||
@@ -293,7 +293,7 @@ class TestShopAddressDetailAPI:
|
||||
shop_customer,
|
||||
):
|
||||
"""Test cannot access another customer's address."""
|
||||
with patch("app.api.v1.shop.addresses.getattr") as mock_getattr:
|
||||
with patch("app.modules.customers.routes.api.storefront.addresses.getattr") as mock_getattr:
|
||||
mock_getattr.return_value = test_vendor
|
||||
with patch("app.api.deps._validate_customer_token") as mock_validate:
|
||||
mock_validate.return_value = shop_customer
|
||||
@@ -328,7 +328,7 @@ class TestShopAddressCreateAPI:
|
||||
"is_default": False,
|
||||
}
|
||||
|
||||
with patch("app.api.v1.shop.addresses.getattr") as mock_getattr:
|
||||
with patch("app.modules.customers.routes.api.storefront.addresses.getattr") as mock_getattr:
|
||||
mock_getattr.return_value = test_vendor
|
||||
with patch("app.api.deps._validate_customer_token") as mock_validate:
|
||||
mock_validate.return_value = shop_customer
|
||||
@@ -362,7 +362,7 @@ class TestShopAddressCreateAPI:
|
||||
"is_default": True,
|
||||
}
|
||||
|
||||
with patch("app.api.v1.shop.addresses.getattr") as mock_getattr:
|
||||
with patch("app.modules.customers.routes.api.storefront.addresses.getattr") as mock_getattr:
|
||||
mock_getattr.return_value = test_vendor
|
||||
with patch("app.api.deps._validate_customer_token") as mock_validate:
|
||||
mock_validate.return_value = shop_customer
|
||||
@@ -386,7 +386,7 @@ class TestShopAddressCreateAPI:
|
||||
# Missing required fields
|
||||
}
|
||||
|
||||
with patch("app.api.v1.shop.addresses.getattr") as mock_getattr:
|
||||
with patch("app.modules.customers.routes.api.storefront.addresses.getattr") as mock_getattr:
|
||||
mock_getattr.return_value = test_vendor
|
||||
with patch("app.api.deps._validate_customer_token") as mock_validate:
|
||||
mock_validate.return_value = shop_customer
|
||||
@@ -419,7 +419,7 @@ class TestShopAddressUpdateAPI:
|
||||
"city": "Esch-sur-Alzette",
|
||||
}
|
||||
|
||||
with patch("app.api.v1.shop.addresses.getattr") as mock_getattr:
|
||||
with patch("app.modules.customers.routes.api.storefront.addresses.getattr") as mock_getattr:
|
||||
mock_getattr.return_value = test_vendor
|
||||
with patch("app.api.deps._validate_customer_token") as mock_validate:
|
||||
mock_validate.return_value = shop_customer
|
||||
@@ -440,7 +440,7 @@ class TestShopAddressUpdateAPI:
|
||||
"""Test updating non-existent address returns 404."""
|
||||
update_data = {"first_name": "Test"}
|
||||
|
||||
with patch("app.api.v1.shop.addresses.getattr") as mock_getattr:
|
||||
with patch("app.modules.customers.routes.api.storefront.addresses.getattr") as mock_getattr:
|
||||
mock_getattr.return_value = test_vendor
|
||||
with patch("app.api.deps._validate_customer_token") as mock_validate:
|
||||
mock_validate.return_value = shop_customer
|
||||
@@ -463,7 +463,7 @@ class TestShopAddressUpdateAPI:
|
||||
"""Test cannot update another customer's address."""
|
||||
update_data = {"first_name": "Hacked"}
|
||||
|
||||
with patch("app.api.v1.shop.addresses.getattr") as mock_getattr:
|
||||
with patch("app.modules.customers.routes.api.storefront.addresses.getattr") as mock_getattr:
|
||||
mock_getattr.return_value = test_vendor
|
||||
with patch("app.api.deps._validate_customer_token") as mock_validate:
|
||||
mock_validate.return_value = shop_customer
|
||||
@@ -491,7 +491,7 @@ class TestShopAddressDeleteAPI:
|
||||
shop_customer,
|
||||
):
|
||||
"""Test deleting an address."""
|
||||
with patch("app.api.v1.shop.addresses.getattr") as mock_getattr:
|
||||
with patch("app.modules.customers.routes.api.storefront.addresses.getattr") as mock_getattr:
|
||||
mock_getattr.return_value = test_vendor
|
||||
with patch("app.api.deps._validate_customer_token") as mock_validate:
|
||||
mock_validate.return_value = shop_customer
|
||||
@@ -506,7 +506,7 @@ class TestShopAddressDeleteAPI:
|
||||
self, client, shop_customer_headers, test_vendor, shop_customer
|
||||
):
|
||||
"""Test deleting non-existent address returns 404."""
|
||||
with patch("app.api.v1.shop.addresses.getattr") as mock_getattr:
|
||||
with patch("app.modules.customers.routes.api.storefront.addresses.getattr") as mock_getattr:
|
||||
mock_getattr.return_value = test_vendor
|
||||
with patch("app.api.deps._validate_customer_token") as mock_validate:
|
||||
mock_validate.return_value = shop_customer
|
||||
@@ -526,7 +526,7 @@ class TestShopAddressDeleteAPI:
|
||||
shop_customer,
|
||||
):
|
||||
"""Test cannot delete another customer's address."""
|
||||
with patch("app.api.v1.shop.addresses.getattr") as mock_getattr:
|
||||
with patch("app.modules.customers.routes.api.storefront.addresses.getattr") as mock_getattr:
|
||||
mock_getattr.return_value = test_vendor
|
||||
with patch("app.api.deps._validate_customer_token") as mock_validate:
|
||||
mock_validate.return_value = shop_customer
|
||||
@@ -572,7 +572,7 @@ class TestShopAddressSetDefaultAPI:
|
||||
db.commit()
|
||||
db.refresh(second_address)
|
||||
|
||||
with patch("app.api.v1.shop.addresses.getattr") as mock_getattr:
|
||||
with patch("app.modules.customers.routes.api.storefront.addresses.getattr") as mock_getattr:
|
||||
mock_getattr.return_value = test_vendor
|
||||
with patch("app.api.deps._validate_customer_token") as mock_validate:
|
||||
mock_validate.return_value = shop_customer
|
||||
@@ -589,7 +589,7 @@ class TestShopAddressSetDefaultAPI:
|
||||
self, client, shop_customer_headers, test_vendor, shop_customer
|
||||
):
|
||||
"""Test setting default on non-existent address returns 404."""
|
||||
with patch("app.api.v1.shop.addresses.getattr") as mock_getattr:
|
||||
with patch("app.modules.customers.routes.api.storefront.addresses.getattr") as mock_getattr:
|
||||
mock_getattr.return_value = test_vendor
|
||||
with patch("app.api.deps._validate_customer_token") as mock_validate:
|
||||
mock_validate.return_value = shop_customer
|
||||
@@ -609,7 +609,7 @@ class TestShopAddressSetDefaultAPI:
|
||||
shop_customer,
|
||||
):
|
||||
"""Test cannot set default on another customer's address."""
|
||||
with patch("app.api.v1.shop.addresses.getattr") as mock_getattr:
|
||||
with patch("app.modules.customers.routes.api.storefront.addresses.getattr") as mock_getattr:
|
||||
mock_getattr.return_value = test_vendor
|
||||
with patch("app.api.deps._validate_customer_token") as mock_validate:
|
||||
mock_validate.return_value = shop_customer
|
||||
|
||||
Reference in New Issue
Block a user