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:
2026-01-30 10:16:28 +01:00
parent 0e041a33ac
commit a123341aa8
3 changed files with 45 additions and 45 deletions

View File

@@ -162,7 +162,7 @@ class TestShopAddressesListAPI:
def test_list_addresses_requires_authentication(self, client, test_vendor): def test_list_addresses_requires_authentication(self, client, test_vendor):
"""Test that listing addresses requires authentication.""" """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 mock_getattr.return_value = test_vendor
response = client.get("/api/v1/storefront/addresses") response = client.get("/api/v1/storefront/addresses")
assert response.status_code in [401, 403] assert response.status_code in [401, 403]
@@ -176,7 +176,7 @@ class TestShopAddressesListAPI:
shop_customer, shop_customer,
): ):
"""Test listing customer addresses successfully.""" """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 mock_getattr.return_value = test_vendor
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer mock_validate.return_value = shop_customer
@@ -196,7 +196,7 @@ class TestShopAddressesListAPI:
self, client, shop_customer_headers, test_vendor, shop_customer self, client, shop_customer_headers, test_vendor, shop_customer
): ):
"""Test listing addresses when customer has none.""" """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 mock_getattr.return_value = test_vendor
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer mock_validate.return_value = shop_customer
@@ -220,7 +220,7 @@ class TestShopAddressesListAPI:
shop_customer, shop_customer,
): ):
"""Test listing addresses includes both shipping and billing.""" """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 mock_getattr.return_value = test_vendor
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer mock_validate.return_value = shop_customer
@@ -253,7 +253,7 @@ class TestShopAddressDetailAPI:
shop_customer, shop_customer,
): ):
"""Test getting address details successfully.""" """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 mock_getattr.return_value = test_vendor
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer mock_validate.return_value = shop_customer
@@ -273,7 +273,7 @@ class TestShopAddressDetailAPI:
self, client, shop_customer_headers, test_vendor, shop_customer self, client, shop_customer_headers, test_vendor, shop_customer
): ):
"""Test getting non-existent address returns 404.""" """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 mock_getattr.return_value = test_vendor
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer mock_validate.return_value = shop_customer
@@ -293,7 +293,7 @@ class TestShopAddressDetailAPI:
shop_customer, shop_customer,
): ):
"""Test cannot access another customer's address.""" """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 mock_getattr.return_value = test_vendor
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer mock_validate.return_value = shop_customer
@@ -328,7 +328,7 @@ class TestShopAddressCreateAPI:
"is_default": False, "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 mock_getattr.return_value = test_vendor
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer mock_validate.return_value = shop_customer
@@ -362,7 +362,7 @@ class TestShopAddressCreateAPI:
"is_default": True, "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 mock_getattr.return_value = test_vendor
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer mock_validate.return_value = shop_customer
@@ -386,7 +386,7 @@ class TestShopAddressCreateAPI:
# Missing required fields # 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 mock_getattr.return_value = test_vendor
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer mock_validate.return_value = shop_customer
@@ -419,7 +419,7 @@ class TestShopAddressUpdateAPI:
"city": "Esch-sur-Alzette", "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 mock_getattr.return_value = test_vendor
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer mock_validate.return_value = shop_customer
@@ -440,7 +440,7 @@ class TestShopAddressUpdateAPI:
"""Test updating non-existent address returns 404.""" """Test updating non-existent address returns 404."""
update_data = {"first_name": "Test"} 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 mock_getattr.return_value = test_vendor
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer mock_validate.return_value = shop_customer
@@ -463,7 +463,7 @@ class TestShopAddressUpdateAPI:
"""Test cannot update another customer's address.""" """Test cannot update another customer's address."""
update_data = {"first_name": "Hacked"} 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 mock_getattr.return_value = test_vendor
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer mock_validate.return_value = shop_customer
@@ -491,7 +491,7 @@ class TestShopAddressDeleteAPI:
shop_customer, shop_customer,
): ):
"""Test deleting an address.""" """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 mock_getattr.return_value = test_vendor
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer mock_validate.return_value = shop_customer
@@ -506,7 +506,7 @@ class TestShopAddressDeleteAPI:
self, client, shop_customer_headers, test_vendor, shop_customer self, client, shop_customer_headers, test_vendor, shop_customer
): ):
"""Test deleting non-existent address returns 404.""" """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 mock_getattr.return_value = test_vendor
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer mock_validate.return_value = shop_customer
@@ -526,7 +526,7 @@ class TestShopAddressDeleteAPI:
shop_customer, shop_customer,
): ):
"""Test cannot delete another customer's address.""" """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 mock_getattr.return_value = test_vendor
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer mock_validate.return_value = shop_customer
@@ -572,7 +572,7 @@ class TestShopAddressSetDefaultAPI:
db.commit() db.commit()
db.refresh(second_address) 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 mock_getattr.return_value = test_vendor
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer mock_validate.return_value = shop_customer
@@ -589,7 +589,7 @@ class TestShopAddressSetDefaultAPI:
self, client, shop_customer_headers, test_vendor, shop_customer self, client, shop_customer_headers, test_vendor, shop_customer
): ):
"""Test setting default on non-existent address returns 404.""" """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 mock_getattr.return_value = test_vendor
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer mock_validate.return_value = shop_customer
@@ -609,7 +609,7 @@ class TestShopAddressSetDefaultAPI:
shop_customer, shop_customer,
): ):
"""Test cannot set default on another customer's address.""" """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 mock_getattr.return_value = test_vendor
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer mock_validate.return_value = shop_customer

View File

@@ -310,7 +310,7 @@ class TestShopOrdersListAPI:
def test_list_orders_requires_authentication(self, client, test_vendor): def test_list_orders_requires_authentication(self, client, test_vendor):
"""Test that listing orders requires authentication.""" """Test that listing orders requires authentication."""
with patch("app.api.v1.shop.orders.getattr") as mock_getattr: with patch("app.modules.orders.routes.api.storefront.getattr") as mock_getattr:
mock_getattr.return_value = test_vendor mock_getattr.return_value = test_vendor
response = client.get("/api/v1/storefront/orders") response = client.get("/api/v1/storefront/orders")
# Without token, should get 401 or 403 # Without token, should get 401 or 403
@@ -321,7 +321,7 @@ class TestShopOrdersListAPI:
): ):
"""Test listing customer orders successfully.""" """Test listing customer orders successfully."""
# Mock vendor context and customer auth # Mock vendor context and customer auth
with patch("app.api.v1.shop.orders.getattr") as mock_getattr: with patch("app.modules.orders.routes.api.storefront.getattr") as mock_getattr:
mock_getattr.return_value = test_vendor mock_getattr.return_value = test_vendor
# Mock the dependency to return our customer # Mock the dependency to return our customer
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
@@ -340,7 +340,7 @@ class TestShopOrdersListAPI:
self, client, shop_customer_headers, test_vendor, shop_customer self, client, shop_customer_headers, test_vendor, shop_customer
): ):
"""Test listing orders when customer has none.""" """Test listing orders when customer has none."""
with patch("app.api.v1.shop.orders.getattr") as mock_getattr: with patch("app.modules.orders.routes.api.storefront.getattr") as mock_getattr:
mock_getattr.return_value = test_vendor mock_getattr.return_value = test_vendor
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer mock_validate.return_value = shop_customer
@@ -364,7 +364,7 @@ class TestShopOrderDetailAPI:
self, client, shop_customer_headers, shop_order, test_vendor, shop_customer self, client, shop_customer_headers, shop_order, test_vendor, shop_customer
): ):
"""Test getting order details successfully.""" """Test getting order details successfully."""
with patch("app.api.v1.shop.orders.getattr") as mock_getattr: with patch("app.modules.orders.routes.api.storefront.getattr") as mock_getattr:
mock_getattr.return_value = test_vendor mock_getattr.return_value = test_vendor
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer mock_validate.return_value = shop_customer
@@ -385,7 +385,7 @@ class TestShopOrderDetailAPI:
self, client, shop_customer_headers, test_vendor, shop_customer self, client, shop_customer_headers, test_vendor, shop_customer
): ):
"""Test getting non-existent order returns 404.""" """Test getting non-existent order returns 404."""
with patch("app.api.v1.shop.orders.getattr") as mock_getattr: with patch("app.modules.orders.routes.api.storefront.getattr") as mock_getattr:
mock_getattr.return_value = test_vendor mock_getattr.return_value = test_vendor
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer mock_validate.return_value = shop_customer
@@ -405,7 +405,7 @@ class TestShopOrderDetailAPI:
shop_customer, shop_customer,
): ):
"""Test cannot access another customer's order.""" """Test cannot access another customer's order."""
with patch("app.api.v1.shop.orders.getattr") as mock_getattr: with patch("app.modules.orders.routes.api.storefront.getattr") as mock_getattr:
mock_getattr.return_value = test_vendor mock_getattr.return_value = test_vendor
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer mock_validate.return_value = shop_customer
@@ -428,7 +428,7 @@ class TestShopOrderInvoiceDownloadAPI:
self, client, shop_customer_headers, shop_order, test_vendor, shop_customer self, client, shop_customer_headers, shop_order, test_vendor, shop_customer
): ):
"""Test cannot download invoice for pending orders.""" """Test cannot download invoice for pending orders."""
with patch("app.api.v1.shop.orders.getattr") as mock_getattr: with patch("app.modules.orders.routes.api.storefront.getattr") as mock_getattr:
mock_getattr.return_value = test_vendor mock_getattr.return_value = test_vendor
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer mock_validate.return_value = shop_customer
@@ -480,7 +480,7 @@ class TestShopOrderInvoiceDownloadAPI:
shop_customer, shop_customer,
): ):
"""Test cannot download invoice for another customer's order.""" """Test cannot download invoice for another customer's order."""
with patch("app.api.v1.shop.orders.getattr") as mock_getattr: with patch("app.modules.orders.routes.api.storefront.getattr") as mock_getattr:
mock_getattr.return_value = test_vendor mock_getattr.return_value = test_vendor
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer mock_validate.return_value = shop_customer
@@ -496,7 +496,7 @@ class TestShopOrderInvoiceDownloadAPI:
self, client, shop_customer_headers, test_vendor, shop_customer self, client, shop_customer_headers, test_vendor, shop_customer
): ):
"""Test downloading invoice for non-existent order.""" """Test downloading invoice for non-existent order."""
with patch("app.api.v1.shop.orders.getattr") as mock_getattr: with patch("app.modules.orders.routes.api.storefront.getattr") as mock_getattr:
mock_getattr.return_value = test_vendor mock_getattr.return_value = test_vendor
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer mock_validate.return_value = shop_customer
@@ -518,7 +518,7 @@ class TestShopOrderVATFields:
self, client, shop_customer_headers, shop_order, test_vendor, shop_customer self, client, shop_customer_headers, shop_order, test_vendor, shop_customer
): ):
"""Test order response includes VAT fields.""" """Test order response includes VAT fields."""
with patch("app.api.v1.shop.orders.getattr") as mock_getattr: with patch("app.modules.orders.routes.api.storefront.getattr") as mock_getattr:
mock_getattr.return_value = test_vendor mock_getattr.return_value = test_vendor
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer mock_validate.return_value = shop_customer
@@ -539,7 +539,7 @@ class TestShopOrderVATFields:
self, client, shop_customer_headers, shop_order, test_vendor, shop_customer self, client, shop_customer_headers, shop_order, test_vendor, shop_customer
): ):
"""Test order list includes VAT fields.""" """Test order list includes VAT fields."""
with patch("app.api.v1.shop.orders.getattr") as mock_getattr: with patch("app.modules.orders.routes.api.storefront.getattr") as mock_getattr:
mock_getattr.return_value = test_vendor mock_getattr.return_value = test_vendor
with patch("app.api.deps._validate_customer_token") as mock_validate: with patch("app.api.deps._validate_customer_token") as mock_validate:
mock_validate.return_value = shop_customer mock_validate.return_value = shop_customer

View File

@@ -110,11 +110,11 @@ class TestForgotPasswordAPI:
self, client, db, test_vendor, shop_customer self, client, db, test_vendor, shop_customer
): ):
"""Test password reset request for existing customer.""" """Test password reset request for existing customer."""
with patch("app.api.v1.shop.auth.getattr") as mock_getattr: with patch("app.modules.customers.routes.api.storefront.auth.getattr") as mock_getattr:
mock_getattr.return_value = test_vendor mock_getattr.return_value = test_vendor
# Mock email service to avoid actual email sending # Mock email service to avoid actual email sending
with patch("app.api.v1.shop.auth.EmailService") as mock_email_service: with patch("app.modules.customers.routes.api.storefront.auth.EmailService") as mock_email_service:
mock_instance = MagicMock() mock_instance = MagicMock()
mock_email_service.return_value = mock_instance mock_email_service.return_value = mock_instance
@@ -135,7 +135,7 @@ class TestForgotPasswordAPI:
def test_forgot_password_nonexistent_email(self, client, db, test_vendor): def test_forgot_password_nonexistent_email(self, client, db, test_vendor):
"""Test password reset request for non-existent email (same response).""" """Test password reset request for non-existent email (same response)."""
with patch("app.api.v1.shop.auth.getattr") as mock_getattr: with patch("app.modules.customers.routes.api.storefront.auth.getattr") as mock_getattr:
mock_getattr.return_value = test_vendor mock_getattr.return_value = test_vendor
response = client.post( response = client.post(
@@ -152,7 +152,7 @@ class TestForgotPasswordAPI:
self, client, db, test_vendor, inactive_customer self, client, db, test_vendor, inactive_customer
): ):
"""Test password reset request for inactive customer.""" """Test password reset request for inactive customer."""
with patch("app.api.v1.shop.auth.getattr") as mock_getattr: with patch("app.modules.customers.routes.api.storefront.auth.getattr") as mock_getattr:
mock_getattr.return_value = test_vendor mock_getattr.return_value = test_vendor
response = client.post( response = client.post(
@@ -169,10 +169,10 @@ class TestForgotPasswordAPI:
self, client, db, test_vendor, shop_customer self, client, db, test_vendor, shop_customer
): ):
"""Test that forgot password creates a token in the database.""" """Test that forgot password creates a token in the database."""
with patch("app.api.v1.shop.auth.getattr") as mock_getattr: with patch("app.modules.customers.routes.api.storefront.auth.getattr") as mock_getattr:
mock_getattr.return_value = test_vendor mock_getattr.return_value = test_vendor
with patch("app.api.v1.shop.auth.EmailService"): with patch("app.modules.customers.routes.api.storefront.auth.EmailService"):
response = client.post( response = client.post(
"/api/v1/storefront/auth/forgot-password", "/api/v1/storefront/auth/forgot-password",
params={"email": shop_customer.email}, params={"email": shop_customer.email},
@@ -205,10 +205,10 @@ class TestForgotPasswordAPI:
) )
assert old_token_count == 1 assert old_token_count == 1
with patch("app.api.v1.shop.auth.getattr") as mock_getattr: with patch("app.modules.customers.routes.api.storefront.auth.getattr") as mock_getattr:
mock_getattr.return_value = test_vendor mock_getattr.return_value = test_vendor
with patch("app.api.v1.shop.auth.EmailService"): with patch("app.modules.customers.routes.api.storefront.auth.EmailService"):
response = client.post( response = client.post(
"/api/v1/storefront/auth/forgot-password", "/api/v1/storefront/auth/forgot-password",
params={"email": shop_customer.email}, params={"email": shop_customer.email},
@@ -238,7 +238,7 @@ class TestResetPasswordAPI:
self, client, db, test_vendor, shop_customer, valid_reset_token self, client, db, test_vendor, shop_customer, valid_reset_token
): ):
"""Test successful password reset.""" """Test successful password reset."""
with patch("app.api.v1.shop.auth.getattr") as mock_getattr: with patch("app.modules.customers.routes.api.storefront.auth.getattr") as mock_getattr:
mock_getattr.return_value = test_vendor mock_getattr.return_value = test_vendor
new_password = "newpassword123" new_password = "newpassword123"
@@ -267,7 +267,7 @@ class TestResetPasswordAPI:
self, client, db, test_vendor, shop_customer, valid_reset_token self, client, db, test_vendor, shop_customer, valid_reset_token
): ):
"""Test that token is marked as used after successful reset.""" """Test that token is marked as used after successful reset."""
with patch("app.api.v1.shop.auth.getattr") as mock_getattr: with patch("app.modules.customers.routes.api.storefront.auth.getattr") as mock_getattr:
mock_getattr.return_value = test_vendor mock_getattr.return_value = test_vendor
response = client.post( response = client.post(
@@ -290,7 +290,7 @@ class TestResetPasswordAPI:
def test_reset_password_invalid_token(self, client, db, test_vendor): def test_reset_password_invalid_token(self, client, db, test_vendor):
"""Test reset with invalid token.""" """Test reset with invalid token."""
with patch("app.api.v1.shop.auth.getattr") as mock_getattr: with patch("app.modules.customers.routes.api.storefront.auth.getattr") as mock_getattr:
mock_getattr.return_value = test_vendor mock_getattr.return_value = test_vendor
response = client.post( response = client.post(
@@ -307,7 +307,7 @@ class TestResetPasswordAPI:
self, client, db, test_vendor, shop_customer, expired_reset_token self, client, db, test_vendor, shop_customer, expired_reset_token
): ):
"""Test reset with expired token.""" """Test reset with expired token."""
with patch("app.api.v1.shop.auth.getattr") as mock_getattr: with patch("app.modules.customers.routes.api.storefront.auth.getattr") as mock_getattr:
mock_getattr.return_value = test_vendor mock_getattr.return_value = test_vendor
response = client.post( response = client.post(
@@ -324,7 +324,7 @@ class TestResetPasswordAPI:
self, client, db, test_vendor, shop_customer, used_reset_token self, client, db, test_vendor, shop_customer, used_reset_token
): ):
"""Test reset with already used token.""" """Test reset with already used token."""
with patch("app.api.v1.shop.auth.getattr") as mock_getattr: with patch("app.modules.customers.routes.api.storefront.auth.getattr") as mock_getattr:
mock_getattr.return_value = test_vendor mock_getattr.return_value = test_vendor
response = client.post( response = client.post(
@@ -341,7 +341,7 @@ class TestResetPasswordAPI:
self, client, db, test_vendor, shop_customer, valid_reset_token self, client, db, test_vendor, shop_customer, valid_reset_token
): ):
"""Test reset with password that's too short.""" """Test reset with password that's too short."""
with patch("app.api.v1.shop.auth.getattr") as mock_getattr: with patch("app.modules.customers.routes.api.storefront.auth.getattr") as mock_getattr:
mock_getattr.return_value = test_vendor mock_getattr.return_value = test_vendor
response = client.post( response = client.post(
@@ -358,7 +358,7 @@ class TestResetPasswordAPI:
self, client, db, test_vendor, shop_customer, valid_reset_token self, client, db, test_vendor, shop_customer, valid_reset_token
): ):
"""Test that token cannot be reused after successful reset.""" """Test that token cannot be reused after successful reset."""
with patch("app.api.v1.shop.auth.getattr") as mock_getattr: with patch("app.modules.customers.routes.api.storefront.auth.getattr") as mock_getattr:
mock_getattr.return_value = test_vendor mock_getattr.return_value = test_vendor
# First reset should succeed # First reset should succeed