Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
[TEST] Adding E2e utils (#13807)
Renatad7215a843a1e
diff --git a/.gitignore b/.gitignoreindex 25ae4db810..b714f58c6f 100644--- a/.gitignore+++ b/.gitignore@@ -19,7 +19,7 @@ dist//media//node_modules//static/-+/digital_contents/# Environments.env.venvdiff --git a/saleor/tests/e2e/checkout/test_checkout_create_from_order.py b/saleor/tests/e2e/checkout/test_checkout_create_from_order.pyindex 5097bee393..de1baa6da4 100644--- a/saleor/tests/e2e/checkout/test_checkout_create_from_order.py+++ b/saleor/tests/e2e/checkout/test_checkout_create_from_order.py@@ -1,36 +1,24 @@import pytest-from ..channel.utils import create_channelfrom ..orders.utils.draft_order import draft_order_createfrom ..orders.utils.order_lines import order_lines_create-from ..product.utils import (- create_category,- create_product,- create_product_channel_listing,- create_product_type,- create_product_variant,- create_product_variant_channel_listing,-)-from ..shipping_zone.utils import (- create_shipping_method,- create_shipping_method_channel_listing,- create_shipping_zone,-)+from ..product.utils.preparing_product import prepare_product+from ..shop.utils.preparing_shop import prepare_shopfrom ..utils import assign_permissions-from ..warehouse.utils import create_warehousefrom .utils import checkout_create_from_order-def prepare_product(+def test_checkout_create_from_order_core_0104(e2e_staff_api_client,permission_manage_products,permission_manage_channels,- permission_manage_shipping,permission_manage_product_types_and_attributes,+ permission_manage_shipping,permission_manage_orders,permission_manage_checkouts,- channel_slug,):+ # Beforepermissions = [permission_manage_products,permission_manage_channels,@@ -41,109 +29,30 @@ def prepare_product(]assign_permissions(e2e_staff_api_client, permissions)- warehouse_data = create_warehouse(e2e_staff_api_client)- warehouse_id = warehouse_data["id"]-- warehouse_ids = [warehouse_id]- channel_data = create_channel(- e2e_staff_api_client, slug=channel_slug, warehouse_ids=warehouse_ids- )- channel_id = channel_data["id"]-- channel_ids = [channel_id]- shipping_zone_data = create_shipping_zone(- e2e_staff_api_client,- warehouse_ids=warehouse_ids,- channel_ids=channel_ids,- )- shipping_zone_id = shipping_zone_data["id"]-- shipping_method_data = create_shipping_method(- e2e_staff_api_client, shipping_zone_id- )- shipping_method_id = shipping_method_data["id"]-- create_shipping_method_channel_listing(- e2e_staff_api_client, shipping_method_id, channel_id- )-- product_type_data = create_product_type(- e2e_staff_api_client,- )- product_type_id = product_type_data["id"]-- category_data = create_category(e2e_staff_api_client)- category_id = category_data["id"]-- product_data = create_product(e2e_staff_api_client, product_type_id, category_id)- product_id = product_data["id"]-- create_product_channel_listing(e2e_staff_api_client, product_id, channel_id)-- stocks = [- {- "warehouse": warehouse_id,- "quantity": 5,- }- ]- product_variant_data = create_product_variant(- e2e_staff_api_client,- product_id,- stocks=stocks,+ (+ result_warehouse_id,+ result_channel_id,+ _,+ _,+ ) = prepare_shop(e2e_staff_api_client)++ product_variant_id = prepare_product(+ e2e_staff_api_client, result_warehouse_id, result_channel_id)- product_variant_id = product_variant_data["id"]- create_product_variant_channel_listing(- e2e_staff_api_client,- product_variant_id,- channel_id,- )+ # Step 1 - Create checkout from orderdata = draft_order_create(e2e_staff_api_client,- channel_id,+ result_channel_id,)order_id = data["order"]["id"]+ assert order_id is not Noneorder_lines = [{"variantId": product_variant_id, "quantity": 1, "price": 100}]order_data = order_lines_create(e2e_staff_api_client, order_id, order_lines)order_product_variant_id = order_data["order"]["lines"][0]["variant"]order_product_quantity = order_data["order"]["lines"][0]["quantity"]- return (- order_id,- order_product_variant_id,- order_product_quantity,- )---def test_checkout_create_from_order_core_0104(- e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_product_types_and_attributes,- permission_manage_shipping,- permission_manage_orders,- permission_manage_checkouts,-):- # Before- (- order_id,- order_product_variant_id,- order_product_quantity,- ) = prepare_product(- e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_product_types_and_attributes,- permission_manage_shipping,- permission_manage_orders,- permission_manage_checkouts,- channel_slug="test",- )-- # Step 1 - Create checkout from order-checkout_data = checkout_create_from_order(e2e_staff_api_client, order_id)checkout_id = checkout_data["checkout"]["id"]assert checkout_id is not Nonediff --git a/saleor/tests/e2e/checkout/test_checkout_create_order_with_no_payment.py b/saleor/tests/e2e/checkout/test_checkout_create_order_with_no_payment.pyindex 7a9e5082a4..776b2aaf2a 100644--- a/saleor/tests/e2e/checkout/test_checkout_create_order_with_no_payment.py+++ b/saleor/tests/e2e/checkout/test_checkout_create_order_with_no_payment.py@@ -1,14 +1,7 @@import pytestfrom ..channel.utils import create_channel-from ..product.utils import (- create_category,- create_product,- create_product_channel_listing,- create_product_type,- create_product_variant,- create_product_variant_channel_listing,-)+from ..product.utils.preparing_product import prepare_productfrom ..shipping_zone.utils import (create_shipping_method,create_shipping_method_channel_listing,@@ -23,22 +16,25 @@ from .utils import ()-def prepare_product(+def create_shop_for_orders_without_payments(e2e_staff_api_client,permission_manage_products,permission_manage_channels,- permission_manage_shipping,permission_manage_product_types_and_attributes,- channel_slug,+ permission_manage_shipping,+ permission_manage_orders,+ permission_manage_checkouts,):+ channel_slug = "test-test"permissions = [permission_manage_products,permission_manage_channels,permission_manage_shipping,permission_manage_product_types_and_attributes,+ permission_manage_orders,+ permission_manage_checkouts,]assign_permissions(e2e_staff_api_client, permissions)-warehouse_data = create_warehouse(e2e_staff_api_client)warehouse_id = warehouse_data["id"]@@ -68,61 +64,39 @@ def prepare_product(create_shipping_method_channel_listing(e2e_staff_api_client, shipping_method_id, channel_id)-- product_type_data = create_product_type(- e2e_staff_api_client,- )- product_type_id = product_type_data["id"]-- category_data = create_category(e2e_staff_api_client)- category_id = category_data["id"]-- product_data = create_product(e2e_staff_api_client, product_type_id, category_id)- product_id = product_data["id"]-- create_product_channel_listing(e2e_staff_api_client, product_id, channel_id)-- stocks = [- {- "warehouse": warehouse_id,- "quantity": 5,- }- ]- product_variant_data = create_product_variant(- e2e_staff_api_client,- product_id,- stocks=stocks,- )- product_variant_id = product_variant_data["id"]-- create_product_variant_channel_listing(- e2e_staff_api_client,- product_variant_id,- channel_id,- )-- return product_variant_id+ return channel_slug, warehouse_id, channel_id, shipping_method_id@pytest.mark.e2e-def test_should_be_able_to_create_order_with_no_payment(+def test_should_be_able_to_create_order_with_no_payment_CORE_0111(e2e_staff_api_client,permission_manage_products,permission_manage_channels,- permission_manage_shipping,permission_manage_product_types_and_attributes,+ permission_manage_shipping,+ permission_manage_orders,+ permission_manage_checkouts,):# Before- channel_slug = "test-channel"- product_variant_id = prepare_product(+ (+ channel_slug,+ warehouse_id,+ channel_id,+ shipping_method_id,+ ) = create_shop_for_orders_without_payments(e2e_staff_api_client,permission_manage_products,permission_manage_channels,- permission_manage_shipping,permission_manage_product_types_and_attributes,- channel_slug,+ permission_manage_shipping,+ permission_manage_orders,+ permission_manage_checkouts,)+ product_variant_id = prepare_product(e2e_staff_api_client, warehouse_id, channel_id)++ assert shipping_method_id is not None+# Step 1 - Create checkout.lines = [{"variantId": product_variant_id, "quantity": 1},@@ -153,6 +127,7 @@ def test_should_be_able_to_create_order_with_no_payment(# Step 3 - Checkout complete results in the order creationdata = raw_checkout_complete(e2e_staff_api_client, checkout_id)order_data = data["order"]+ assert order_data is not Noneassert order_data["id"] is not Noneassert order_data["isShippingRequired"] is Trueassert order_data["paymentStatus"] == "NOT_CHARGED"diff --git a/saleor/tests/e2e/checkout/test_checkout_create_partially_paid_order.py b/saleor/tests/e2e/checkout/test_checkout_create_partially_paid_order.pyindex 981c1e7a45..720a289a25 100644--- a/saleor/tests/e2e/checkout/test_checkout_create_partially_paid_order.py+++ b/saleor/tests/e2e/checkout/test_checkout_create_partially_paid_order.py@@ -1,14 +1,7 @@import pytestfrom ..channel.utils import create_channel-from ..product.utils import (- create_category,- create_product,- create_product_channel_listing,- create_product_type,- create_product_variant,- create_product_variant_channel_listing,-)+from ..product.utils.preparing_product import prepare_productfrom ..shipping_zone.utils import (create_shipping_method,create_shipping_method_channel_listing,@@ -24,22 +17,27 @@ from .utils import ()-def prepare_product(+def create_shop_for_orders_without_payments(e2e_staff_api_client,permission_manage_products,permission_manage_channels,- permission_manage_shipping,permission_manage_product_types_and_attributes,- channel_slug,+ permission_manage_shipping,+ permission_manage_orders,+ permission_manage_checkouts,+ permission_manage_payments,):+ channel_slug = "test-test"permissions = [permission_manage_products,permission_manage_channels,permission_manage_shipping,permission_manage_product_types_and_attributes,+ permission_manage_orders,+ permission_manage_checkouts,+ permission_manage_payments,]assign_permissions(e2e_staff_api_client, permissions)-warehouse_data = create_warehouse(e2e_staff_api_client)warehouse_id = warehouse_data["id"]@@ -69,40 +67,7 @@ def prepare_product(create_shipping_method_channel_listing(e2e_staff_api_client, shipping_method_id, channel_id)-- product_type_data = create_product_type(- e2e_staff_api_client,- )- product_type_id = product_type_data["id"]-- category_data = create_category(e2e_staff_api_client)- category_id = category_data["id"]-- product_data = create_product(e2e_staff_api_client, product_type_id, category_id)- product_id = product_data["id"]-- create_product_channel_listing(e2e_staff_api_client, product_id, channel_id)-- stocks = [- {- "warehouse": warehouse_id,- "quantity": 5,- }- ]- product_variant_data = create_product_variant(- e2e_staff_api_client,- product_id,- stocks=stocks,- )- product_variant_id = product_variant_data["id"]-- create_product_variant_channel_listing(- e2e_staff_api_client,- product_variant_id,- channel_id,- )-- return product_variant_id+ return channel_slug, warehouse_id, channel_id, shipping_method_id@pytest.mark.e2e@@ -112,23 +77,33 @@ def test_should_be_able_to_create_partially_paid_order_core_0112(e2e_app_api_client,permission_manage_products,permission_manage_channels,- permission_manage_shipping,permission_manage_product_types_and_attributes,+ permission_manage_shipping,+ permission_manage_orders,+ permission_manage_checkouts,permission_manage_payments,):# Before- channel_slug = "test-channel"- product_variant_id = prepare_product(+ (+ channel_slug,+ warehouse_id,+ channel_id,+ shipping_method_id,+ ) = create_shop_for_orders_without_payments(e2e_staff_api_client,permission_manage_products,permission_manage_channels,- permission_manage_shipping,permission_manage_product_types_and_attributes,- channel_slug,+ permission_manage_shipping,+ permission_manage_orders,+ permission_manage_checkouts,+ permission_manage_payments,)app_permissions = [permission_manage_payments]assign_permissions(e2e_app_api_client, app_permissions)+ product_variant_id = prepare_product(e2e_staff_api_client, warehouse_id, channel_id)+ assert shipping_method_id is not None# Step 1 - Create checkout.lines = [{"variantId": product_variant_id, "quantity": 1},diff --git a/saleor/tests/e2e/checkout/test_checkout_purchase_with_no_payment.py b/saleor/tests/e2e/checkout/test_checkout_purchase_with_no_payment.pydeleted file mode 100644index ccb8797080..0000000000--- a/saleor/tests/e2e/checkout/test_checkout_purchase_with_no_payment.py+++ /dev/null@@ -1,165 +0,0 @@-import pytest--from ..channel.utils import create_channel-from ..product.utils import (- create_category,- create_product,- create_product_channel_listing,- create_product_type,- create_product_variant,- create_product_variant_channel_listing,-)-from ..shipping_zone.utils import (- create_shipping_method,- create_shipping_method_channel_listing,- create_shipping_zone,-)-from ..utils import assign_permissions-from ..warehouse.utils import create_warehouse-from .utils import (- checkout_create,- checkout_delivery_method_update,- raw_checkout_complete,-)---def prepare_product(- e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,- permission_manage_product_types_and_attributes,- channel_slug,-):- permissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,- permission_manage_product_types_and_attributes,- ]- assign_permissions(e2e_staff_api_client, permissions)-- warehouse_data = create_warehouse(e2e_staff_api_client)- warehouse_id = warehouse_data["id"]-- warehouse_ids = [warehouse_id]- channel_data = create_channel(- e2e_staff_api_client,- slug=channel_slug,- warehouse_ids=warehouse_ids,- )- channel_id = channel_data["id"]-- channel_ids = [channel_id]- shipping_zone_data = create_shipping_zone(- e2e_staff_api_client,- warehouse_ids=warehouse_ids,- channel_ids=channel_ids,- )- shipping_zone_id = shipping_zone_data["id"]-- shipping_method_data = create_shipping_method(- e2e_staff_api_client, shipping_zone_id- )- shipping_method_id = shipping_method_data["id"]-- create_shipping_method_channel_listing(- e2e_staff_api_client, shipping_method_id, channel_id- )-- product_type_data = create_product_type(- e2e_staff_api_client,- )- product_type_id = product_type_data["id"]-- category_data = create_category(e2e_staff_api_client)- category_id = category_data["id"]-- product_data = create_product(e2e_staff_api_client, product_type_id, category_id)- product_id = product_data["id"]-- create_product_channel_listing(e2e_staff_api_client, product_id, channel_id)-- stocks = [- {- "warehouse": warehouse_id,- "quantity": 5,- }- ]- product_variant_data = create_product_variant(- e2e_staff_api_client,- product_id,- stocks=stocks,- )- product_variant_id = product_variant_data["id"]-- create_product_variant_channel_listing(- e2e_staff_api_client,- product_variant_id,- channel_id,- )-- return product_variant_id---def test_should_not_be_able_to_make_purchase_with_no_payment(- e2e_staff_api_client,- e2e_not_logged_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,- permission_manage_product_types_and_attributes,-):- # Before- channel_slug = "test-channel"- product_variant_id = prepare_product(- e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,- permission_manage_product_types_and_attributes,- channel_slug,- )-- # Step 1 - Create checkout.- lines = [- {"variantId": product_variant_id, "quantity": 1},- ]- checkout_data = checkout_create(- e2e_not_logged_api_client,- lines,- channel_slug,- email="[email protected]",- set_default_billing_address=True,- set_default_shipping_address=True,- )- checkout_id = checkout_data["id"]-- assert checkout_data["isShippingRequired"] is True- assert checkout_data["deliveryMethod"] is None- assert checkout_data["shippingMethod"] is None- shipping_method_id = checkout_data["shippingMethods"][0]["id"]-- # Step 2 - Set shipping address and DeliveryMethod for checkout-- checkout_data = checkout_delivery_method_update(- e2e_not_logged_api_client,- checkout_id,- shipping_method_id,- )- assert checkout_data["deliveryMethod"]["id"] == shipping_method_id-- # Step 3 - Unable to complete checkout without payment- order_data = raw_checkout_complete(e2e_not_logged_api_client, checkout_id)- assert order_data["order"] is None- errors = order_data["errors"]- assert errors == [- {- "code": "CHECKOUT_NOT_FULLY_PAID",- "field": None,- "message": (- "Provided payment methods can not cover the checkout's total amount"- ),- }- ]diff --git a/saleor/tests/e2e/checkout/test_checkout_unable_to_make_purchase_with_no_payment.py b/saleor/tests/e2e/checkout/test_checkout_unable_to_make_purchase_with_no_payment.pynew file mode 100644index 0000000000..50cce50680--- /dev/null+++ b/saleor/tests/e2e/checkout/test_checkout_unable_to_make_purchase_with_no_payment.py@@ -0,0 +1,77 @@+import pytest++from ..product.utils.preparing_product import prepare_product+from ..shop.utils.preparing_shop import prepare_shop+from ..utils import assign_permissions+from .utils import (+ checkout_create,+ checkout_delivery_method_update,+ raw_checkout_complete,+)+++def test_should_not_be_able_to_make_purchase_with_no_payment_CORE_0113(+ e2e_staff_api_client,+ e2e_not_logged_api_client,+ permission_manage_products,+ permission_manage_channels,+ permission_manage_shipping,+ permission_manage_product_types_and_attributes,+):+ # Before+ permissions = [+ permission_manage_products,+ permission_manage_channels,+ permission_manage_shipping,+ permission_manage_product_types_and_attributes,+ ]+ assign_permissions(e2e_staff_api_client, permissions)++ warehouse_id, channel_id, channel_slug, shipping_method_id = prepare_shop(+ e2e_staff_api_client+ )++ product_variant_id = prepare_product(e2e_staff_api_client, warehouse_id, channel_id)++ # Step 1 - Create checkout.+ lines = [+ {"variantId": product_variant_id, "quantity": 1},+ ]+ checkout_data = checkout_create(+ e2e_not_logged_api_client,+ lines,+ channel_slug,+ email="[email protected]",+ set_default_billing_address=True,+ set_default_shipping_address=True,+ )+ checkout_id = checkout_data["id"]++ assert checkout_data["isShippingRequired"] is True+ assert checkout_data["deliveryMethod"] is None+ assert checkout_data["shippingMethod"] is None+ shipping_method_id = checkout_data["shippingMethods"][0]["id"]++ # Step 2 - Set shipping address and DeliveryMethod for checkout++ checkout_data = checkout_delivery_method_update(+ e2e_not_logged_api_client,+ checkout_id,+ shipping_method_id,+ )+ assert checkout_data["deliveryMethod"]["id"] == shipping_method_id++ # Step 3 - Unable to complete checkout without payment+ order_data = raw_checkout_complete(e2e_not_logged_api_client, checkout_id)+ assert order_data["order"] is None+ errors = order_data["errors"]+ assert errors == [+ {+ "code": "CHECKOUT_NOT_FULLY_PAID",+ "field": None,+ "message": (+ "Provided payment methods can not cover the checkout's total amount"+ ),+ }+ ]diff --git a/saleor/tests/e2e/checkout/test_logged_customer_is_unable_to_buy_more_products_than_the_limit_per_customer.py b/saleor/tests/e2e/checkout/test_logged_customer_is_unable_to_buy_more_products_than_the_limit_per_customer.pyindex 340725e031..4eb2e10efc 100644--- a/saleor/tests/e2e/checkout/test_logged_customer_is_unable_to_buy_more_products_than_the_limit_per_customer.py+++ b/saleor/tests/e2e/checkout/test_logged_customer_is_unable_to_buy_more_products_than_the_limit_per_customer.py@@ -1,6 +1,5 @@import pytest-from ..channel.utils import create_channelfrom ..product.utils import (create_category,create_product,@@ -9,23 +8,17 @@ from ..product.utils import (create_product_variant,create_product_variant_channel_listing,)-from ..shipping_zone.utils import (- create_shipping_method,- create_shipping_method_channel_listing,- create_shipping_zone,-)+from ..shop.utils.preparing_shop import prepare_shopfrom ..utils import assign_permissions-from ..warehouse.utils import create_warehousefrom .utils import checkout_create, checkout_lines_update-def prepare_product(+def prepare_product_with_limit(e2e_staff_api_client,permission_manage_products,permission_manage_channels,permission_manage_shipping,permission_manage_product_types_and_attributes,- channel_slug,):permissions = [permission_manage_products,@@ -35,30 +28,8 @@ def prepare_product(]assign_permissions(e2e_staff_api_client, permissions)- warehouse_data = create_warehouse(e2e_staff_api_client)- warehouse_id = warehouse_data["id"]-- warehouse_ids = [warehouse_id]- channel_data = create_channel(- e2e_staff_api_client, slug=channel_slug, warehouse_ids=warehouse_ids- )- channel_id = channel_data["id"]-- channel_ids = [channel_id]- shipping_zone_data = create_shipping_zone(- e2e_staff_api_client,- warehouse_ids=warehouse_ids,- channel_ids=channel_ids,- )- shipping_zone_id = shipping_zone_data["id"]-- shipping_method_data = create_shipping_method(- e2e_staff_api_client, shipping_zone_id- )- shipping_method_id = shipping_method_data["id"]-- create_shipping_method_channel_listing(- e2e_staff_api_client, shipping_method_id, channel_id+ result_warehouse_id, result_channel_id, result_channel_slug, _ = prepare_shop(+ e2e_staff_api_client)product_type_data = create_product_type(@@ -72,11 +43,11 @@ def prepare_product(product_data = create_product(e2e_staff_api_client, product_type_id, category_id)product_id = product_data["id"]- create_product_channel_listing(e2e_staff_api_client, product_id, channel_id)+ create_product_channel_listing(e2e_staff_api_client, product_id, result_channel_id)stocks = [{- "warehouse": warehouse_id,+ "warehouse": result_warehouse_id,"quantity": 5,}]@@ -95,13 +66,14 @@ def prepare_product(create_product_variant_channel_listing(e2e_staff_api_client,product_variant_id,- channel_id,+ result_channel_id,)return (product_variant_id,product_variant_name,product_variant_quantity_limit_per_customer,+ result_channel_slug,)@@ -115,19 +87,17 @@ def test_checkout_with_product_quantity_exceeding_the_limit_per_customer_core_01permission_manage_product_types_and_attributes,):# Before- channel_slug = "test-channel"-(product_variant_id,product_variant_name,product_variant_quantity_limit_per_customer,- ) = prepare_product(+ result_channel_slug,+ ) = prepare_product_with_limit(e2e_staff_api_client,permission_manage_products,permission_manage_channels,permission_manage_shipping,permission_manage_product_types_and_attributes,- channel_slug,)# Step 1 - Create checkout.@@ -137,7 +107,7 @@ def test_checkout_with_product_quantity_exceeding_the_limit_per_customer_core_01checkout_data = checkout_create(e2e_logged_api_client,lines,- channel_slug,+ result_channel_slug,email="[email protected]",set_default_billing_address=True,)diff --git a/saleor/tests/e2e/checkout/test_logged_in_customer_should_be_able_to_order_physical_product.py b/saleor/tests/e2e/checkout/test_logged_in_customer_should_be_able_to_order_physical_product.pyindex a3a89cbcd4..c0d5563182 100644--- a/saleor/tests/e2e/checkout/test_logged_in_customer_should_be_able_to_order_physical_product.py+++ b/saleor/tests/e2e/checkout/test_logged_in_customer_should_be_able_to_order_physical_product.py@@ -1,21 +1,8 @@import pytest-from ..channel.utils import create_channel-from ..product.utils import (- create_category,- create_product,- create_product_channel_listing,- create_product_type,- create_product_variant,- create_product_variant_channel_listing,-)-from ..shipping_zone.utils import (- create_shipping_method,- create_shipping_method_channel_listing,- create_shipping_zone,-)+from ..product.utils.preparing_product import prepare_product+from ..shop.utils.preparing_shop import prepare_shopfrom ..utils import assign_permissions-from ..warehouse.utils import create_warehousefrom .utils import (checkout_complete,checkout_create,@@ -24,109 +11,42 @@ from .utils import ()-def prepare_product(+def test_process_checkout_with_physical_product_CORE_0103(e2e_staff_api_client,+ e2e_logged_api_client,permission_manage_products,permission_manage_channels,- permission_manage_shipping,permission_manage_product_types_and_attributes,- channel_slug,+ permission_manage_shipping,+ permission_manage_orders,+ permission_manage_checkouts,):+ # Beforepermissions = [permission_manage_products,permission_manage_channels,permission_manage_shipping,permission_manage_product_types_and_attributes,+ permission_manage_orders,+ permission_manage_checkouts,]assign_permissions(e2e_staff_api_client, permissions)- warehouse_data = create_warehouse(e2e_staff_api_client)- warehouse_id = warehouse_data["id"]-- warehouse_ids = [warehouse_id]- channel_data = create_channel(- e2e_staff_api_client, slug=channel_slug, warehouse_ids=warehouse_ids- )- channel_id = channel_data["id"]-- channel_ids = [channel_id]- shipping_zone_data = create_shipping_zone(- e2e_staff_api_client,- warehouse_ids=warehouse_ids,- channel_ids=channel_ids,- )- shipping_zone_id = shipping_zone_data["id"]-- shipping_method_data = create_shipping_method(- e2e_staff_api_client, shipping_zone_id- )- shipping_method_id = shipping_method_data["id"]-- create_shipping_method_channel_listing(- e2e_staff_api_client, shipping_method_id, channel_id- )-- product_type_data = create_product_type(- e2e_staff_api_client,- )- product_type_id = product_type_data["id"]-- category_data = create_category(e2e_staff_api_client)- category_id = category_data["id"]-- product_data = create_product(e2e_staff_api_client, product_type_id, category_id)- product_id = product_data["id"]-- create_product_channel_listing(e2e_staff_api_client, product_id, channel_id)-- stocks = [- {- "warehouse": warehouse_id,- "quantity": 5,- }- ]- product_variant_data = create_product_variant(- e2e_staff_api_client,- product_id,- stocks=stocks,- )- product_variant_id = product_variant_data["id"]-- create_product_variant_channel_listing(- e2e_staff_api_client,- product_variant_id,+ (+ warehouse_id,channel_id,- )- return product_variant_id-+ channel_slug,+ shipping_method_id,+ ) = prepare_shop(e2e_staff_api_client)-def test_process_checkout_with_physical_product(- e2e_staff_api_client,- e2e_logged_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,- permission_manage_product_types_and_attributes,-):- # Before- channel_slug = "test-channel"product_variant_id = prepare_product(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,- permission_manage_product_types_and_attributes,- channel_slug,+ warehouse_id,+ channel_id,)- # Step 1 - Login as existing customer.-- # This step is implemented automatically by using a proper- # API client(eg. e2e_staff_api_client, e2e_not_logged_api_client,- # e2e_logged_api_client).-- # Step 2 - Create checkout.+ # Step 1 - Create checkout.lines = [{"variantId": product_variant_id, "quantity": 1},]diff --git a/saleor/tests/e2e/checkout/test_logged_in_customer_should_not_be_able_to_buy_unavailable_product.py b/saleor/tests/e2e/checkout/test_logged_in_customer_should_not_be_able_to_buy_unavailable_product.pyindex 56bf83a8c5..99b71e6ac3 100644--- a/saleor/tests/e2e/checkout/test_logged_in_customer_should_not_be_able_to_buy_unavailable_product.py+++ b/saleor/tests/e2e/checkout/test_logged_in_customer_should_not_be_able_to_buy_unavailable_product.py@@ -1,6 +1,5 @@import pytest-from ..channel.utils import create_channelfrom ..product.utils import (create_category,create_product,@@ -9,29 +8,29 @@ from ..product.utils import (create_product_variant_channel_listing,raw_create_product_channel_listing,)+from ..shop.utils.preparing_shop import prepare_shopfrom ..utils import assign_permissions-from ..warehouse.utils import create_warehousefrom .utils import raw_checkout_create-def prepare_product(+def prepare_unavailable_product(e2e_staff_api_client,permission_manage_products,permission_manage_channels,permission_manage_product_types_and_attributes,+ permission_manage_shipping,):permissions = [permission_manage_products,permission_manage_channels,permission_manage_product_types_and_attributes,+ permission_manage_shipping,]assign_permissions(e2e_staff_api_client, permissions)- warehouse_data = create_warehouse(e2e_staff_api_client)-- channel_data = create_channel(e2e_staff_api_client, warehouse_data["id"])- channel_id = channel_data["id"]- channel_slug = channel_data["slug"]+ result_warehouse_id, result_channel_id, result_channel_slug, _ = prepare_shop(+ e2e_staff_api_client+ )product_type_data = create_product_type(e2e_staff_api_client,@@ -53,7 +52,7 @@ def prepare_product(product_channel_listing = raw_create_product_channel_listing(e2e_staff_api_client,product_id,- channel_id,+ result_channel_id,is_available_for_purchase=False,available_for_purchase_datetime=None,)@@ -64,7 +63,7 @@ def prepare_product(stocks = [{- "warehouse": warehouse_data["id"],+ "warehouse": result_warehouse_id,"quantity": 5,}]@@ -76,10 +75,10 @@ def prepare_product(create_product_variant_channel_listing(e2e_staff_api_client,variant_id,- channel_id,+ result_channel_id,)- return variant_id, channel_slug+ return variant_id, result_channel_slug@pytest.mark.e2e@@ -89,13 +88,15 @@ def test_should_not_be_able_to_buy_unavailable_product_core_0108(permission_manage_products,permission_manage_channels,permission_manage_product_types_and_attributes,+ permission_manage_shipping,):# Before- variant_id, channel_slug = prepare_product(+ variant_id, channel_slug = prepare_unavailable_product(e2e_staff_api_client,permission_manage_products,permission_manage_channels,permission_manage_product_types_and_attributes,+ permission_manage_shipping,)# Step 1 - Create checkout with non available for purchase productlines = [diff --git a/saleor/tests/e2e/checkout/test_unlogged_customer_is_unable_to_buy_unpublished_product.py b/saleor/tests/e2e/checkout/test_unlogged_customer_is_unable_to_buy_unpublished_product.pyindex 626a3a0e30..6c0af2d8ad 100644--- a/saleor/tests/e2e/checkout/test_unlogged_customer_is_unable_to_buy_unpublished_product.py+++ b/saleor/tests/e2e/checkout/test_unlogged_customer_is_unable_to_buy_unpublished_product.py@@ -1,6 +1,5 @@import pytest-from ..channel.utils import create_channelfrom ..product.utils import (create_category,create_product,@@ -9,33 +8,28 @@ from ..product.utils import (create_product_variant_channel_listing,raw_create_product_channel_listing,)+from ..shop.utils.preparing_shop import prepare_shopfrom ..utils import assign_permissions-from ..warehouse.utils import create_warehousefrom .utils import raw_checkout_create-def prepare_product(+def prepare_unpublished_product(e2e_staff_api_client,permission_manage_products,permission_manage_channels,permission_manage_product_types_and_attributes,- channel_slug,+ permission_manage_shipping,):permissions = [permission_manage_products,permission_manage_channels,permission_manage_product_types_and_attributes,+ permission_manage_shipping,]assign_permissions(e2e_staff_api_client, permissions)-- warehouse_data = create_warehouse(e2e_staff_api_client)- warehouse_id = warehouse_data["id"]-- warehouse_ids = [warehouse_id]- channel_data = create_channel(- e2e_staff_api_client, slug=channel_slug, warehouse_ids=warehouse_ids+ result_warehouse_id, result_channel_id, result_channel_slug, _ = prepare_shop(+ e2e_staff_api_client)- channel_id = channel_data["id"]product_type_data = create_product_type(e2e_staff_api_client,@@ -51,14 +45,14 @@ def prepare_product(raw_create_product_channel_listing(e2e_staff_api_client,product_id,- channel_id,+ result_channel_id,is_published=False,is_available_for_purchase=True,)stocks = [{- "warehouse": warehouse_id,+ "warehouse": result_warehouse_id,"quantity": 5,}]@@ -72,10 +66,10 @@ def prepare_product(create_product_variant_channel_listing(e2e_staff_api_client,product_variant_id,- channel_id,+ result_channel_id,)- return product_variant_id, channel_id, product_id, permissions+ return product_variant_id, result_channel_slug@pytest.mark.e2e@@ -85,15 +79,15 @@ def test_unlogged_customer_is_unable_to_buy_unpublished_product_core_0109(permission_manage_products,permission_manage_channels,permission_manage_product_types_and_attributes,+ permission_manage_shipping,):# Before- channel_slug = "test-channel222"- product_variant_id, channel_id, product_id, permissions = prepare_product(+ product_variant_id, result_channel_slug = prepare_unpublished_product(e2e_staff_api_client,permission_manage_products,permission_manage_channels,permission_manage_product_types_and_attributes,- channel_slug,+ permission_manage_shipping,)# Step 1 - Create checkout with unpublished product variant@@ -104,7 +98,7 @@ def test_unlogged_customer_is_unable_to_buy_unpublished_product_core_0109(checkout_data = raw_checkout_create(e2e_not_logged_api_client,lines,- channel_slug,+ result_channel_slug,email="[email protected]",set_default_billing_address=True,)diff --git a/saleor/tests/e2e/checkout/test_unlogged_customer_should_be_able_to_buy_by_click_and_collect.py b/saleor/tests/e2e/checkout/test_unlogged_customer_should_be_able_to_buy_by_click_and_collect.pyindex fcaa0145ae..64813f571d 100644--- a/saleor/tests/e2e/checkout/test_unlogged_customer_should_be_able_to_buy_by_click_and_collect.py+++ b/saleor/tests/e2e/checkout/test_unlogged_customer_should_be_able_to_buy_by_click_and_collect.py@@ -1,14 +1,7 @@import pytestfrom ..channel.utils import create_channel-from ..product.utils import (- create_category,- create_product,- create_product_channel_listing,- create_product_type,- create_product_variant,- create_product_variant_channel_listing,-)+from ..product.utils.preparing_product import prepare_productfrom ..utils import assign_permissionsfrom ..warehouse.utils import create_warehouse, update_warehousefrom .utils import (@@ -19,7 +12,7 @@ from .utils import ()-def prepare_product(+def prepare_shop_click_and_collect(e2e_staff_api_client,permission_manage_products,permission_manage_channels,@@ -44,47 +37,11 @@ def prepare_product(channel_id = channel_data["id"]channel_slug = channel_data["slug"]- product_type_data = create_product_type(- e2e_staff_api_client,- )- product_type_id = product_type_data["id"]-- category_data = create_category(- e2e_staff_api_client,- )- category_id = category_data["id"]-- product_data = create_product(- e2e_staff_api_client,- product_type_id,- category_id,- )- product_id = product_data["id"]-- create_product_channel_listing(e2e_staff_api_client, product_id, channel_id)-- stocks = [- {- "warehouse": warehouse_data["id"],- "quantity": 5,- }- ]- variant_data = create_product_variant(- e2e_staff_api_client, product_id, stocks=stocks- )- variant_id = variant_data["id"]-- create_product_variant_channel_listing(- e2e_staff_api_client,- variant_id,- channel_id,- )-- return variant_id, channel_slug, warehouse_id+ return channel_id, channel_slug, warehouse_id@pytest.mark.e2e-def test_unlogged_customer_buy_by_click_and_collect(+def test_unlogged_customer_buy_by_click_and_collect_CORE_0105(e2e_not_logged_api_client,e2e_staff_api_client,permission_manage_products,@@ -92,16 +49,17 @@ def test_unlogged_customer_buy_by_click_and_collect(permission_manage_product_types_and_attributes,):# Before- variant_id, channel_slug, warehouse_id = prepare_product(+ channel_id, channel_slug, warehouse_id = prepare_shop_click_and_collect(e2e_staff_api_client,permission_manage_products,permission_manage_channels,permission_manage_product_types_and_attributes,)+ product_variant_id = prepare_product(e2e_staff_api_client, warehouse_id, channel_id)# Step 1 - Create checkout and check collection pointlines = [- {"variantId": variant_id, "quantity": 1},+ {"variantId": product_variant_id, "quantity": 1},]checkout_data = checkout_create(e2e_not_logged_api_client,diff --git a/saleor/tests/e2e/checkout/test_unlogged_customer_should_be_able_to_order_digital_product.py b/saleor/tests/e2e/checkout/test_unlogged_customer_should_be_able_to_order_digital_product.pyindex e9d1ec8605..bc55a17038 100644--- a/saleor/tests/e2e/checkout/test_unlogged_customer_should_be_able_to_order_digital_product.py+++ b/saleor/tests/e2e/checkout/test_unlogged_customer_should_be_able_to_order_digital_product.py@@ -1,6 +1,5 @@import pytest-from ..channel.utils import create_channelfrom ..product.utils import (create_category,create_digital_content,@@ -10,9 +9,8 @@ from ..product.utils import (create_product_variant,create_product_variant_channel_listing,)-from ..shipping_zone.utils import create_shipping_zone+from ..shop.utils.preparing_shop import prepare_shopfrom ..utils import assign_permissions-from ..warehouse.utils import create_warehousefrom .utils import (checkout_billing_address_update,checkout_complete,@@ -27,30 +25,16 @@ def prepare_product(permission_manage_channels,permission_manage_products,permission_manage_shipping,- channel_slug,):permissions = [- permission_manage_products,+ permission_manage_product_types_and_attributes,permission_manage_channels,+ permission_manage_products,permission_manage_shipping,- permission_manage_product_types_and_attributes,]assign_permissions(e2e_staff_api_client, permissions)-- warehouse_data = create_warehouse(e2e_staff_api_client)- warehouse_id = warehouse_data["id"]-- warehouse_ids = [warehouse_id]- channel_data = create_channel(- e2e_staff_api_client, slug=channel_slug, warehouse_ids=warehouse_ids- )- channel_id = channel_data["id"]-- channel_ids = [channel_id]- create_shipping_zone(- e2e_staff_api_client,- warehouse_ids=warehouse_ids,- channel_ids=channel_ids,+ result_warehouse_id, result_channel_id, result_channel_slug, _ = prepare_shop(+ e2e_staff_api_client)product_type_data = create_product_type(@@ -66,11 +50,11 @@ def prepare_product(product_data = create_product(e2e_staff_api_client, product_type_id, category_id)product_id = product_data["id"]- create_product_channel_listing(e2e_staff_api_client, product_id, channel_id)+ create_product_channel_listing(e2e_staff_api_client, product_id, result_channel_id)stocks = [{- "warehouse": warehouse_id,+ "warehouse": result_warehouse_id,"quantity": 5,}]@@ -84,32 +68,29 @@ def prepare_product(create_product_variant_channel_listing(e2e_staff_api_client,product_variant_id,- channel_id,+ result_channel_id,)create_digital_content(e2e_staff_api_client, product_variant_id)- return product_variant_id+ return product_variant_id, result_channel_slug@pytest.mark.e2e-def test_process_checkout_with_digital_product(+def test_process_checkout_with_digital_product_CORE_0101(e2e_not_logged_api_client,e2e_staff_api_client,permission_manage_product_types_and_attributes,permission_manage_channels,permission_manage_products,permission_manage_shipping,- media_root,):# Before- channel_slug = "test-channel"- product_variant_id = prepare_product(+ product_variant_id, result_channel_slug = prepare_product(e2e_staff_api_client,- permission_manage_products,+ permission_manage_product_types_and_attributes,permission_manage_channels,+ permission_manage_products,permission_manage_shipping,- permission_manage_product_types_and_attributes,- channel_slug,)# Step 1 - Create checkout.@@ -119,7 +100,7 @@ def test_process_checkout_with_digital_product(checkout_data = checkout_create(e2e_not_logged_api_client,lines,- channel_slug,+ result_channel_slug,email="[email protected]",)checkout_id = checkout_data["id"]diff --git a/saleor/tests/e2e/checkout/test_unlogged_customer_should_be_able_to_order_physical_product.py b/saleor/tests/e2e/checkout/test_unlogged_customer_should_be_able_to_order_physical_product.pyindex 8a988769e8..dbf94b374d 100644--- a/saleor/tests/e2e/checkout/test_unlogged_customer_should_be_able_to_order_physical_product.py+++ b/saleor/tests/e2e/checkout/test_unlogged_customer_should_be_able_to_order_physical_product.py@@ -1,21 +1,8 @@import pytest-from ..channel.utils import create_channel-from ..product.utils import (- create_category,- create_product,- create_product_channel_listing,- create_product_type,- create_product_variant,- create_product_variant_channel_listing,-)-from ..shipping_zone.utils import (- create_shipping_method,- create_shipping_method_channel_listing,- create_shipping_zone,-)+from ..product.utils.preparing_product import prepare_product+from ..shop.utils.preparing_shop import prepare_shopfrom ..utils import assign_permissions-from ..warehouse.utils import create_warehousefrom .utils import (checkout_complete,checkout_create,@@ -25,101 +12,39 @@ from .utils import ()-def prepare_product(+def test_process_checkout_with_physical_product_CORE_0102(e2e_staff_api_client,+ e2e_not_logged_api_client,permission_manage_products,permission_manage_channels,- permission_manage_shipping,permission_manage_product_types_and_attributes,- channel_slug,+ permission_manage_shipping,+ permission_manage_orders,+ permission_manage_checkouts,):+ # Beforepermissions = [permission_manage_products,permission_manage_channels,permission_manage_shipping,permission_manage_product_types_and_attributes,+ permission_manage_orders,+ permission_manage_checkouts,]assign_permissions(e2e_staff_api_client, permissions)- warehouse_data = create_warehouse(e2e_staff_api_client)- warehouse_id = warehouse_data["id"]-- warehouse_ids = [warehouse_id]- channel_data = create_channel(- e2e_staff_api_client, slug=channel_slug, warehouse_ids=warehouse_ids- )- channel_id = channel_data["id"]-- channel_ids = [channel_id]- shipping_zone_data = create_shipping_zone(- e2e_staff_api_client,- warehouse_ids=warehouse_ids,- channel_ids=channel_ids,- )- shipping_zone_id = shipping_zone_data["id"]-- shipping_method_data = create_shipping_method(- e2e_staff_api_client, shipping_zone_id- )- shipping_method_id = shipping_method_data["id"]-- create_shipping_method_channel_listing(- e2e_staff_api_client, shipping_method_id, channel_id- )-- product_type_data = create_product_type(- e2e_staff_api_client,- )- product_type_id = product_type_data["id"]-- category_data = create_category(e2e_staff_api_client)- category_id = category_data["id"]-- product_data = create_product(e2e_staff_api_client, product_type_id, category_id)- product_id = product_data["id"]-- create_product_channel_listing(e2e_staff_api_client, product_id, channel_id)-- stocks = [- {- "warehouse": warehouse_id,- "quantity": 5,- }- ]- product_variant_data = create_product_variant(- e2e_staff_api_client,- product_id,- stocks=stocks,- )- product_variant_id = product_variant_data["id"]-- create_product_variant_channel_listing(- e2e_staff_api_client,- product_variant_id,+ (+ warehouse_id,channel_id,- )-- return product_variant_id-+ channel_slug,+ shipping_method_id,+ ) = prepare_shop(e2e_staff_api_client)-def test_process_checkout_with_physical_product(- e2e_staff_api_client,- e2e_not_logged_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,- permission_manage_product_types_and_attributes,-):- # Before- channel_slug = "test-channel"product_variant_id = prepare_product(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,- permission_manage_product_types_and_attributes,- channel_slug,+ warehouse_id,+ channel_id,)# Step 1 - Create checkout.diff --git a/saleor/tests/e2e/checkout/test_unlogged_customer_should_not_be_able_to_buy_product_without_shipping_option.py b/saleor/tests/e2e/checkout/test_unlogged_customer_should_not_be_able_to_buy_product_without_shipping_option.pyindex 22d3e395db..c7a8977d8b 100644--- a/saleor/tests/e2e/checkout/test_unlogged_customer_should_not_be_able_to_buy_product_without_shipping_option.py+++ b/saleor/tests/e2e/checkout/test_unlogged_customer_should_not_be_able_to_buy_product_without_shipping_option.py@@ -1,21 +1,14 @@import pytestfrom ..channel.utils import create_channel-from ..product.utils import (- create_category,- create_product,- create_product_channel_listing,- create_product_type,- create_product_variant,- create_product_variant_channel_listing,-)+from ..product.utils.preparing_product import prepare_productfrom ..shipping_zone.utils import create_shipping_zonefrom ..utils import assign_permissionsfrom ..warehouse.utils import create_warehouse, update_warehousefrom .utils import checkout_create, raw_checkout_dummy_payment_create-def prepare_product(+def prepare_shop_with_no_shipping_method(e2e_staff_api_client,permission_manage_products,permission_manage_channels,@@ -46,55 +39,17 @@ def prepare_product(channel_ids = [channel_id]channel_slug = channel_data["slug"]- shipping_zone_data = create_shipping_zone(+ create_shipping_zone(e2e_staff_api_client,warehouse_ids=warehouse_ids,channel_ids=channel_ids,)- shipping_zone_id = shipping_zone_data["id"]- product_type_data = create_product_type(- e2e_staff_api_client,- is_shipping_required=True,- )- product_type_id = product_type_data["id"]-- category_data = create_category(- e2e_staff_api_client,- )- category_id = category_data["id"]-- product_data = create_product(- e2e_staff_api_client,- product_type_id,- category_id,- )- product_id = product_data["id"]-- create_product_channel_listing(e2e_staff_api_client, product_id, channel_id)-- stocks = [- {- "warehouse": warehouse_data["id"],- "quantity": 5,- }- ]- variant_data = create_product_variant(- e2e_staff_api_client, product_id, stocks=stocks- )- variant_id = variant_data["id"]-- create_product_variant_channel_listing(- e2e_staff_api_client,- variant_id,- channel_id,- )-- return variant_id, channel_slug, warehouse_id, shipping_zone_id+ return channel_id, channel_slug, warehouse_id@pytest.mark.e2e-def test_unlogged_customer_should_not_be_able_to_buy_product_without_shipping_option(+def test_unlogged_customer_unable_to_buy_product_without_shipping_option_CORE_0106(e2e_not_logged_api_client,e2e_staff_api_client,permission_manage_products,@@ -103,17 +58,22 @@ def test_unlogged_customer_should_not_be_able_to_buy_product_without_shipping_oppermission_manage_shipping,):# Before- variant_id, channel_slug, shipping_zone_id, warehouse_id = prepare_product(+ (+ channel_id,+ channel_slug,+ warehouse_id,+ ) = prepare_shop_with_no_shipping_method(e2e_staff_api_client,permission_manage_products,permission_manage_channels,permission_manage_product_types_and_attributes,permission_manage_shipping,)+ product_variant_id = prepare_product(e2e_staff_api_client, warehouse_id, channel_id)# Step 1 - Create checkout with no shipping methodlines = [- {"variantId": variant_id, "quantity": 1},+ {"variantId": product_variant_id, "quantity": 1},]checkout_data = checkout_create(e2e_not_logged_api_client,diff --git a/saleor/tests/e2e/checkout/test_unlogged_customer_should_not_be_able_to_order_product_quantity_greater_than_stock.py b/saleor/tests/e2e/checkout/test_unlogged_customer_should_not_be_able_to_order_product_quantity_greater_than_stock.pyindex cd340ba381..852c7676b0 100644--- a/saleor/tests/e2e/checkout/test_unlogged_customer_should_not_be_able_to_order_product_quantity_greater_than_stock.py+++ b/saleor/tests/e2e/checkout/test_unlogged_customer_should_not_be_able_to_order_product_quantity_greater_than_stock.py@@ -1,6 +1,5 @@import pytest-from ..channel.utils import create_channelfrom ..product.utils import (create_category,create_product,@@ -9,9 +8,8 @@ from ..product.utils import (create_product_variant_channel_listing,raw_create_product_variant,)-from ..shipping_zone.utils import create_shipping_zone+from ..shop.utils.preparing_shop import prepare_shopfrom ..utils import assign_permissions-from ..warehouse.utils import create_warehousefrom .utils import raw_checkout_create@@ -28,20 +26,14 @@ def prepare_product(permission_manage_product_types_and_attributes,permission_manage_shipping,]-assign_permissions(e2e_staff_api_client, permissions)- warehouse_data = create_warehouse(e2e_staff_api_client)- warehouse_id = warehouse_data["id"]- channel_data = create_channel(e2e_staff_api_client, warehouse_data["id"])- channel_id = channel_data["id"]- channel_slug = channel_data["slug"]-- create_shipping_zone(- e2e_staff_api_client,- warehouse_ids=[warehouse_id],- channel_ids=[channel_id],- )+ (+ result_warehouse_id,+ result_channel_id,+ result_channel_slug,+ _,+ ) = prepare_shop(e2e_staff_api_client)product_type_data = create_product_type(e2e_staff_api_client,@@ -61,26 +53,29 @@ def prepare_product()product_id = product_data["id"]- create_product_channel_listing(e2e_staff_api_client, product_id, channel_id)+ create_product_channel_listing(e2e_staff_api_client, product_id, result_channel_id)++ stock_quantity = 5stocks = [{- "warehouse": warehouse_data["id"],- "quantity": 5,+ "warehouse": result_warehouse_id,+ "quantity": stock_quantity,}]variant_data = raw_create_product_variant(e2e_staff_api_client, product_id, stocks=stocks)- variant_id = variant_data["productVariant"]["id"]+ product_variant_id = variant_data["productVariant"]["id"]+ product_variant_name = variant_data["productVariant"]["name"]create_product_variant_channel_listing(e2e_staff_api_client,- variant_id,- channel_id,+ product_variant_id,+ result_channel_id,)- return variant_id, channel_slug+ return product_variant_id, product_variant_name, result_channel_slug, stock_quantity@pytest.mark.e2e@@ -93,7 +88,12 @@ def test_unlogged_customer_cannot_buy_product_in_quantity_grater_than_stock_corepermission_manage_shipping,):# Before- variant_id, channel_slug = prepare_product(+ (+ product_variant_id,+ product_variant_name,+ result_channel_slug,+ stock_quantity,+ ) = prepare_product(e2e_staff_api_client,permission_manage_products,permission_manage_channels,@@ -102,12 +102,12 @@ def test_unlogged_customer_cannot_buy_product_in_quantity_grater_than_stock_core)# Step 1 - Create checkout with product quantity greater than the available stocklines = [- {"variantId": variant_id, "quantity": 10},+ {"variantId": product_variant_id, "quantity": stock_quantity + 1},]checkout_data = raw_checkout_create(e2e_not_logged_api_client,lines,- channel_slug,+ result_channel_slug,email="[email protected]",set_default_billing_address=True,set_default_shipping_address=True,@@ -117,6 +117,6 @@ def test_unlogged_customer_cannot_buy_product_in_quantity_grater_than_stock_coreassert errors[0]["code"] == "INSUFFICIENT_STOCK"assert errors[0]["field"] == "quantity"assert (- errors[0]["message"]- == "Could not add items Test product variant. Only 5 remaining in stock."+ errors[0]["message"] == f"Could not add items {product_variant_name}. "+ f"Only {stock_quantity} remaining in stock.")diff --git a/saleor/tests/e2e/conftest.py b/saleor/tests/e2e/conftest.pyindex 15a1ded664..4dceef95c6 100644--- a/saleor/tests/e2e/conftest.py+++ b/saleor/tests/e2e/conftest.py@@ -53,6 +53,7 @@ def e2e_staff_api_client():is_staff=True,is_active=True,)+return E2eApiClient(user=e2e_staff_user)diff --git a/saleor/tests/e2e/product/utils/preparing_product.py b/saleor/tests/e2e/product/utils/preparing_product.pynew file mode 100644index 0000000000..25f3838c2d--- /dev/null+++ b/saleor/tests/e2e/product/utils/preparing_product.py@@ -0,0 +1,55 @@+from . import (+ create_category,+ create_product,+ create_product_channel_listing,+ create_product_type,+ create_product_variant,+ create_product_variant_channel_listing,+)+++def prepare_product(+ e2e_staff_api_client,+ warehouse_id,+ channel_id,+):+ product_type_data = create_product_type(+ e2e_staff_api_client,+ )+ product_type_id = product_type_data["id"]++ category_data = create_category(e2e_staff_api_client)+ category_id = category_data["id"]++ product_data = create_product(+ e2e_staff_api_client,+ product_type_id,+ category_id,+ )+ product_id = product_data["id"]++ create_product_channel_listing(+ e2e_staff_api_client,+ product_id,+ channel_id,+ )++ stocks = [+ {+ "warehouse": warehouse_id,+ "quantity": 5,+ }+ ]+ product_variant_data = create_product_variant(+ e2e_staff_api_client,+ product_id,+ stocks=stocks,+ )+ product_variant_id = product_variant_data["id"]++ create_product_variant_channel_listing(+ e2e_staff_api_client,+ product_variant_id,+ channel_id,+ )+ return product_variant_iddiff --git a/saleor/tests/e2e/shop/utils/__init__.py b/saleor/tests/e2e/shop/utils/__init__.pynew file mode 100644index 0000000000..b8b18a8ac9--- /dev/null+++ b/saleor/tests/e2e/shop/utils/__init__.py@@ -0,0 +1,7 @@+from .preparing_shop import prepare_shop+from .shop_update_settings import update_shop_settings++__all__ = [+ "prepare_shop",+ "update_shop_settings",+]diff --git a/saleor/tests/e2e/shop/utils/preparing_shop.py b/saleor/tests/e2e/shop/utils/preparing_shop.pynew file mode 100644index 0000000000..d05e7dcd7f--- /dev/null+++ b/saleor/tests/e2e/shop/utils/preparing_shop.py@@ -0,0 +1,36 @@+from ...channel.utils import create_channel+from ...shipping_zone.utils.shipping_method import create_shipping_method+from ...shipping_zone.utils.shipping_method_channel_listing import (+ create_shipping_method_channel_listing,+)+from ...shipping_zone.utils.shipping_zone import create_shipping_zone+from ...warehouse.utils import create_warehouse+++def prepare_shop(e2e_staff_api_client):+ warehouse_data = create_warehouse(e2e_staff_api_client)+ warehouse_id = warehouse_data["id"]+ channel_slug = "test"+ warehouse_ids = [warehouse_id]+ channel_data = create_channel(+ e2e_staff_api_client,+ slug=channel_slug,+ warehouse_ids=warehouse_ids,+ )+ channel_id = channel_data["id"]+ channel_ids = [channel_id]+ shipping_zone_data = create_shipping_zone(+ e2e_staff_api_client,+ warehouse_ids=warehouse_ids,+ channel_ids=channel_ids,+ )+ shipping_zone_id = shipping_zone_data["id"]++ shipping_method_data = create_shipping_method(+ e2e_staff_api_client, shipping_zone_id+ )+ shipping_method_id = shipping_method_data["id"]+ create_shipping_method_channel_listing(+ e2e_staff_api_client, shipping_method_id, channel_id+ )+ return warehouse_id, channel_id, channel_slug, shipping_method_iddiff --git a/saleor/tests/e2e/shop/utils.py b/saleor/tests/e2e/shop/utils/shop_update_settings.pysimilarity index 95%rename from saleor/tests/e2e/shop/utils.pyrename to saleor/tests/e2e/shop/utils/shop_update_settings.pyindex 4e0074af3e..27c94ac733 100644--- a/saleor/tests/e2e/shop/utils.py+++ b/saleor/tests/e2e/shop/utils/shop_update_settings.py@@ -1,4 +1,4 @@-from ..utils import get_graphql_content+from ...utils import get_graphql_contentSHOP_SETTING_UPDATE_MUTATION = """mutation ShopSettingsUpdate($input: ShopSettingsInput!) {