Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
[TEST] [E2E] Prepare_shop refactor (#14779)
Renata204ac6551c2e
diff --git a/saleor/tests/e2e/account/test_should_create_account_without_email_confirmation.py b/saleor/tests/e2e/account/test_should_create_account_without_email_confirmation.pyindex 7391461bcb..f24a87bb95 100644--- a/saleor/tests/e2e/account/test_should_create_account_without_email_confirmation.py+++ b/saleor/tests/e2e/account/test_should_create_account_without_email_confirmation.py@@ -1,7 +1,6 @@import pytest-from ..channel.utils import create_channel-from ..shop.utils import update_shop_settings+from ..shop.utils import prepare_shopfrom ..utils import assign_permissionsfrom .utils import account_register, token_create@@ -10,25 +9,39 @@ from .utils import account_register, token_createdef test_should_create_account_without_email_confirmation_core_1502(e2e_not_logged_api_client,e2e_staff_api_client,- permission_manage_channels,- permission_manage_settings,+ shop_permissions,+ permission_manage_product_types_and_attributes,):# Before- permissions = [permission_manage_channels, permission_manage_settings]+ permissions = [+ permission_manage_product_types_and_attributes,+ *shop_permissions,+ ]assign_permissions(e2e_staff_api_client, permissions)- chanel_data = create_channel(e2e_staff_api_client)- channel_slug = chanel_data["slug"]-- input = {- "enableAccountConfirmationByEmail": False,- }-- update_shop_settings(e2e_staff_api_client, input)+ shop_data, _tax_config = prepare_shop(+ e2e_staff_api_client,+ channels=[+ {+ "shipping_zones": [+ {+ "shipping_methods": [+ {},+ ],+ },+ ],+ "order_settings": {},+ }+ ],+ shop_settings={+ "enableAccountConfirmationByEmail": False,+ },+ )+ channel_slug = shop_data[0]["slug"]test_email = "[email protected]"test_password = "password!"- redirect_url = ""+ redirect_url = "https://www.example.com"# Step 1 - Create account for the new customeruser_account = account_register(@@ -42,7 +55,6 @@ def test_should_create_account_without_email_confirmation_core_1502(assert user_account["user"]["isActive"] is True# Step 2 - Authenticate as new created user-login_data = token_create(e2e_not_logged_api_client, test_email, test_password)assert login_data["user"]["id"] == user_iddiff --git a/saleor/tests/e2e/account/test_should_login_before_email_confirmation.py b/saleor/tests/e2e/account/test_should_login_before_email_confirmation.pyindex 974de7dd04..1f859e9bb7 100644--- a/saleor/tests/e2e/account/test_should_login_before_email_confirmation.py+++ b/saleor/tests/e2e/account/test_should_login_before_email_confirmation.py@@ -1,7 +1,6 @@import pytest-from ..channel.utils import create_channel-from ..shop.utils import update_shop_settings+from ..shop.utils import prepare_shopfrom ..utils import assign_permissionsfrom .utils import account_register, token_create@@ -10,22 +9,36 @@ from .utils import account_register, token_createdef test_should_login_before_email_confirmation_core_1510(e2e_not_logged_api_client,e2e_staff_api_client,- permission_manage_channels,- permission_manage_settings,+ permission_manage_product_types_and_attributes,+ shop_permissions,):# Before- permissions = [permission_manage_channels, permission_manage_settings]+ permissions = [+ permission_manage_product_types_and_attributes,+ *shop_permissions,+ ]assign_permissions(e2e_staff_api_client, permissions)- channel_data = create_channel(e2e_staff_api_client)- channel_slug = channel_data["slug"]-- input_data = {- "enableAccountConfirmationByEmail": True,- "allowLoginWithoutConfirmation": True,- }-- update_shop_settings(e2e_staff_api_client, input_data)+ shop_data, _tax_config = prepare_shop(+ e2e_staff_api_client,+ channels=[+ {+ "shipping_zones": [+ {+ "shipping_methods": [+ {},+ ],+ },+ ],+ "order_settings": {},+ },+ ],+ shop_settings={+ "enableAccountConfirmationByEmail": True,+ "allowLoginWithoutConfirmation": True,+ },+ )+ channel_slug = shop_data[0]["slug"]test_email = "[email protected]"test_password = "Password!"diff --git a/saleor/tests/e2e/account/test_should_not_be_able_to_create_account_with_existing_email.py b/saleor/tests/e2e/account/test_should_not_be_able_to_create_account_with_existing_email.pyindex 4c38ef2d54..bb8245ae85 100644--- a/saleor/tests/e2e/account/test_should_not_be_able_to_create_account_with_existing_email.py+++ b/saleor/tests/e2e/account/test_should_not_be_able_to_create_account_with_existing_email.py@@ -1,7 +1,6 @@import pytest-from ..channel.utils import create_channel-from ..shop.utils import update_shop_settings+from ..shop.utils import prepare_shopfrom ..utils import assign_permissionsfrom .utils import account_register, raw_account_register@@ -10,22 +9,35 @@ from .utils import account_register, raw_account_registerdef test_should_not_be_able_to_create_account_with_existing_email_core_1503(e2e_not_logged_api_client,e2e_staff_api_client,- permission_manage_channels,- permission_manage_settings,+ permission_manage_product_types_and_attributes,+ shop_permissions,):# Before- permissions = [permission_manage_channels, permission_manage_settings]+ permissions = [+ permission_manage_product_types_and_attributes,+ *shop_permissions,+ ]assign_permissions(e2e_staff_api_client, permissions)- chanel_data = create_channel(e2e_staff_api_client)- channel_slug = chanel_data["slug"]-- input_data = {- "enableAccountConfirmationByEmail": False,- }-- update_shop_settings(e2e_staff_api_client, input_data)-+ shop_data, _tax_config = prepare_shop(+ e2e_staff_api_client,+ channels=[+ {+ "shipping_zones": [+ {+ "shipping_methods": [+ {},+ ],+ },+ ],+ "order_settings": {},+ }+ ],+ shop_settings={+ "enableAccountConfirmationByEmail": False,+ },+ )+ channel_slug = shop_data[0]["slug"]user_email = "[email protected]"user_password = "Test1234!"diff --git a/saleor/tests/e2e/account/test_should_not_be_able_to_login_with_invalid_credentials.py b/saleor/tests/e2e/account/test_should_not_be_able_to_login_with_invalid_credentials.pyindex 546fdd44f0..53d863bfdd 100644--- a/saleor/tests/e2e/account/test_should_not_be_able_to_login_with_invalid_credentials.py+++ b/saleor/tests/e2e/account/test_should_not_be_able_to_login_with_invalid_credentials.py@@ -1,7 +1,6 @@import pytest-from ..channel.utils import create_channel-from ..shop.utils import update_shop_settings+from ..shop.utils import prepare_shopfrom ..utils import assign_permissionsfrom .utils import account_register, raw_token_create@@ -10,22 +9,35 @@ from .utils import account_register, raw_token_createdef test_should_not_be_able_to_login_with_invalid_credentials_core_1506(e2e_not_logged_api_client,e2e_staff_api_client,- permission_manage_channels,- permission_manage_settings,+ permission_manage_product_types_and_attributes,+ shop_permissions,):# Before- permissions = [permission_manage_channels, permission_manage_settings]+ permissions = [+ permission_manage_product_types_and_attributes,+ *shop_permissions,+ ]assign_permissions(e2e_staff_api_client, permissions)- chanel_data = create_channel(e2e_staff_api_client)- channel_slug = chanel_data["slug"]-- input_data = {- "enableAccountConfirmationByEmail": False,- }-- update_shop_settings(e2e_staff_api_client, input_data)-+ shop_data, _tax_config = prepare_shop(+ e2e_staff_api_client,+ channels=[+ {+ "shipping_zones": [+ {+ "shipping_methods": [+ {},+ ],+ },+ ],+ "order_settings": {},+ }+ ],+ shop_settings={+ "enableAccountConfirmationByEmail": False,+ },+ )+ channel_slug = shop_data[0]["slug"]user_email = "[email protected]"user_password = "Test1234!"diff --git a/saleor/tests/e2e/channel/utils/channel_create.py b/saleor/tests/e2e/channel/utils/channel_create.pyindex 446031c371..686bd211c4 100644--- a/saleor/tests/e2e/channel/utils/channel_create.py+++ b/saleor/tests/e2e/channel/utils/channel_create.py@@ -1,3 +1,5 @@+import uuid+from ...utils import get_graphql_contentCHANNEL_CREATE_MUTATION = """@@ -16,9 +18,28 @@ mutation ChannelCreate($input: ChannelCreateInput!) {defaultCountry {code}+ warehouses {+ id+ slug+ shippingZones(first: 10) {+ edges {+ node {+ id+ }+ }+ }+ }+ stockSettings {+ allocationStrategy+ }isActiveorderSettings {+ markAsPaidStrategy+ automaticallyConfirmAllNewOrders+ allowUnpaidOrdersautomaticallyConfirmAllNewOrders+ expireOrdersAfter+ deleteExpiredOrdersAfter}}}@@ -30,19 +51,19 @@ def create_channel(staff_api_client,warehouse_ids=None,channel_name="Test channel",- slug="test-slug",+ slug=None,currency="USD",country="US",+ shipping_zones=None,is_active=True,- automatically_fulfill_non_shippable_giftcard=False,- allow_unpaid_orders=False,- automatically_confirm_all_new_orders=True,- mark_as_paid_strategy="PAYMENT_FLOW",- expire_orders_after=0,+ order_settings={},):if not warehouse_ids:warehouse_ids = []+ if slug is None:+ slug = f"channel_slug_{uuid.uuid4()}"+variables = {"input": {"name": channel_name,@@ -51,16 +72,15 @@ def create_channel("defaultCountry": country,"isActive": is_active,"addWarehouses": warehouse_ids,+ "addShippingZones": shipping_zones,"orderSettings": {- "markAsPaidStrategy": mark_as_paid_strategy,- "automaticallyFulfillNonShippableGiftCard": (- automatically_fulfill_non_shippable_giftcard- ),- "allowUnpaidOrders": allow_unpaid_orders,- "automaticallyConfirmAllNewOrders": (- automatically_confirm_all_new_orders- ),- "expireOrdersAfter": expire_orders_after,+ "markAsPaidStrategy": "PAYMENT_FLOW",+ "automaticallyFulfillNonShippableGiftCard": False,+ "allowUnpaidOrders": False,+ "automaticallyConfirmAllNewOrders": True,+ "expireOrdersAfter": 60,+ "deleteExpiredOrdersAfter": 1,+ **order_settings,},}}diff --git a/saleor/tests/e2e/checkout/discounts/promotions/test_checkout_products_on_fixed_promotion.py b/saleor/tests/e2e/checkout/discounts/promotions/test_checkout_products_on_fixed_promotion.pyindex 64306c9430..5f5572c24f 100644--- a/saleor/tests/e2e/checkout/discounts/promotions/test_checkout_products_on_fixed_promotion.py+++ b/saleor/tests/e2e/checkout/discounts/promotions/test_checkout_products_on_fixed_promotion.py@@ -2,7 +2,7 @@ import pytestfrom ....product.utils.preparing_product import prepare_productfrom ....promotions.utils import create_promotion, create_promotion_rule-from ....shop.utils.preparing_shop import prepare_shop+from ....shop.utils import prepare_default_shopfrom ....utils import assign_permissionsfrom ...utils import (checkout_complete,@@ -16,29 +16,24 @@ from ...utils import (def test_checkout_products_on_fixed_promotion_core_2102(e2e_not_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](product_id,@@ -85,7 +80,6 @@ def test_checkout_products_on_fixed_promotion_core_2102()checkout_id = checkout_data["id"]checkout_lines = checkout_data["lines"][0]- shipping_method_id = checkout_data["shippingMethods"][0]["id"]unit_price = float(product_variant_price) - discount_valueassert checkout_data["isShippingRequired"] is Truediff --git a/saleor/tests/e2e/checkout/discounts/promotions/test_checkout_products_on_percentage_promotion.py b/saleor/tests/e2e/checkout/discounts/promotions/test_checkout_products_on_percentage_promotion.pyindex 191264e803..c506ae6459 100644--- a/saleor/tests/e2e/checkout/discounts/promotions/test_checkout_products_on_percentage_promotion.py+++ b/saleor/tests/e2e/checkout/discounts/promotions/test_checkout_products_on_percentage_promotion.py@@ -2,7 +2,7 @@ import pytestfrom ....product.utils.preparing_product import prepare_productfrom ....promotions.utils import create_promotion, create_promotion_rule-from ....shop.utils.preparing_shop import prepare_shop+from ....shop.utils import prepare_default_shopfrom ....utils import assign_permissionsfrom ...utils import (checkout_complete,@@ -16,29 +16,24 @@ from ...utils import (def test_checkout_products_on_percentage_promotion_core_2104(e2e_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](product_id,@@ -85,7 +80,6 @@ def test_checkout_products_on_percentage_promotion_core_2104()checkout_id = checkout_data["id"]checkout_lines = checkout_data["lines"][0]- shipping_method_id = checkout_data["shippingMethods"][0]["id"]line_discount = round(float(product_variant_price) * discount_value / 100, 2)unit_price = float(product_variant_price) - line_discountdiff --git a/saleor/tests/e2e/checkout/discounts/promotions/test_checkout_with_fixed_promotion_should_not_result_in_negative_price_not.py b/saleor/tests/e2e/checkout/discounts/promotions/test_checkout_with_fixed_promotion_should_not_result_in_negative_price_not.pyindex b525703ed4..6e09fe335f 100644--- a/saleor/tests/e2e/checkout/discounts/promotions/test_checkout_with_fixed_promotion_should_not_result_in_negative_price_not.py+++ b/saleor/tests/e2e/checkout/discounts/promotions/test_checkout_with_fixed_promotion_should_not_result_in_negative_price_not.py@@ -3,7 +3,7 @@ import pytestfrom ....product.utils import get_productfrom ....product.utils.preparing_product import prepare_productfrom ....promotions.utils import create_promotion, create_promotion_rule-from ....shop.utils.preparing_shop import prepare_shop+from ....shop.utils import prepare_default_shopfrom ....utils import assign_permissionsfrom ...utils import checkout_create@@ -12,38 +12,30 @@ from ...utils import checkout_createdef test_checkout_with_fixed_promotion_should_not_result_in_negative_price_CORE_2111(e2e_staff_api_client,e2e_not_logged_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_orders,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_orders,]assign_permissions(e2e_staff_api_client, permissions)- (- result_warehouse_id,- result_channel_id,- result_channel_slug,- _,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"](product_id,product_variant_id,product_variant_price,- ) = prepare_product(- e2e_staff_api_client, result_warehouse_id, result_channel_id, variant_price=5- )+ ) = prepare_product(e2e_staff_api_client, warehouse_id, channel_id, variant_price=5)promotion_name = "Promotion Fixed"@@ -69,14 +61,14 @@ def test_checkout_with_fixed_promotion_should_not_result_in_negative_price_CORE_discount_type,discount_value,promotion_rule_name,- result_channel_id,+ channel_id,)product_predicate = promotion_rule["cataloguePredicate"]["productPredicate"]["ids"]- assert promotion_rule["channels"][0]["id"] == result_channel_id+ assert promotion_rule["channels"][0]["id"] == channel_idassert product_predicate[0] == product_id# Step 2 - Get product and check if it is on promotion- product_data = get_product(e2e_staff_api_client, product_id, result_channel_slug)+ product_data = get_product(e2e_staff_api_client, product_id, channel_slug)assert product_data["id"] == product_idassert product_data["pricing"]["onSale"] is Truevariant_data = product_data["variants"][0]@@ -91,7 +83,7 @@ def test_checkout_with_fixed_promotion_should_not_result_in_negative_price_CORE_checkout_data = checkout_create(e2e_not_logged_api_client,lines,- result_channel_slug,+ channel_slug,email="[email protected]",set_default_billing_address=True,set_default_shipping_address=True,diff --git a/saleor/tests/e2e/checkout/discounts/sales/test_checkout_product_on_fixed_sale.py b/saleor/tests/e2e/checkout/discounts/sales/test_checkout_product_on_fixed_sale.pyindex 0ea90ebf56..77a7ffcec4 100644--- a/saleor/tests/e2e/checkout/discounts/sales/test_checkout_product_on_fixed_sale.py+++ b/saleor/tests/e2e/checkout/discounts/sales/test_checkout_product_on_fixed_sale.py@@ -6,7 +6,7 @@ from ....sales.utils import (create_sale_channel_listing,sale_catalogues_add,)-from ....shop.utils.preparing_shop import prepare_shop+from ....shop.utils import prepare_default_shopfrom ....utils import assign_permissionsfrom ...utils import (checkout_complete,@@ -55,28 +55,23 @@ def prepare_sale_for_product(def test_checkout_products_on_fixed_sale_core_1002(e2e_not_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](product_id,@@ -111,7 +106,6 @@ def test_checkout_products_on_fixed_sale_core_1002()checkout_id = checkout_data["id"]checkout_lines = checkout_data["lines"][0]- shipping_method_id = checkout_data["shippingMethods"][0]["id"]unit_price = float(product_variant_price) - sale_discount_valueassert checkout_data["isShippingRequired"] is Truediff --git a/saleor/tests/e2e/checkout/discounts/sales/test_checkout_product_on_percentage_sale.py b/saleor/tests/e2e/checkout/discounts/sales/test_checkout_product_on_percentage_sale.pyindex de66f19860..ec9daf11a1 100644--- a/saleor/tests/e2e/checkout/discounts/sales/test_checkout_product_on_percentage_sale.py+++ b/saleor/tests/e2e/checkout/discounts/sales/test_checkout_product_on_percentage_sale.py@@ -6,7 +6,7 @@ from ....sales.utils import (create_sale_channel_listing,sale_catalogues_add,)-from ....shop.utils.preparing_shop import prepare_shop+from ....shop.utils import prepare_default_shopfrom ....utils import assign_permissionsfrom ...utils import (checkout_complete,@@ -55,28 +55,23 @@ def prepare_sale_for_product(def test_checkout_products_on_percentage_sale_core_1004(e2e_not_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](product_id,@@ -114,7 +109,6 @@ def test_checkout_products_on_percentage_sale_core_1004()checkout_id = checkout_data["id"]checkout_lines = checkout_data["lines"][0]- shipping_method_id = checkout_data["shippingMethods"][0]["id"]line_discount = round(float(product_variant_price) * sale_discount_value / 100, 2)unit_price = float(product_variant_price) - line_discountdiff --git a/saleor/tests/e2e/checkout/discounts/test_checkout_calculate_correct_discount_for_sale_and_voucher.py b/saleor/tests/e2e/checkout/discounts/test_checkout_calculate_correct_discount_for_sale_and_voucher.pyindex f36adf81af..378878b35b 100644--- a/saleor/tests/e2e/checkout/discounts/test_checkout_calculate_correct_discount_for_sale_and_voucher.py+++ b/saleor/tests/e2e/checkout/discounts/test_checkout_calculate_correct_discount_for_sale_and_voucher.py@@ -2,7 +2,7 @@ import pytestfrom ...product.utils.preparing_product import prepare_productfrom ...sales.utils import create_sale, create_sale_channel_listing, sale_catalogues_add-from ...shop.utils.preparing_shop import prepare_shop+from ...shop.utils.preparing_shop import prepare_default_shopfrom ...utils import assign_permissionsfrom ...vouchers.utils import create_voucher, create_voucher_channel_listingfrom ..utils import (@@ -101,9 +101,7 @@ def prepare_voucher(def test_checkout_calculate_discount_for_sale_and_voucher_1014(e2e_not_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,variant_price,@@ -117,20 +115,17 @@ def test_checkout_calculate_discount_for_sale_and_voucher_1014():# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](_product_id,@@ -173,7 +168,6 @@ def test_checkout_calculate_discount_for_sale_and_voucher_1014()checkout_id = checkout_data["id"]checkout_lines = checkout_data["lines"][0]- shipping_method_id = checkout_data["shippingMethods"][0]["id"]assert checkout_data["isShippingRequired"] is Trueunit_price_on_sale = round(float(product_variant_price - expected_sale_discount), 2)diff --git a/saleor/tests/e2e/checkout/discounts/test_checkout_with_promotion_and_voucher.py b/saleor/tests/e2e/checkout/discounts/test_checkout_with_promotion_and_voucher.pyindex b566ce4399..cc5fd01bcc 100644--- a/saleor/tests/e2e/checkout/discounts/test_checkout_with_promotion_and_voucher.py+++ b/saleor/tests/e2e/checkout/discounts/test_checkout_with_promotion_and_voucher.py@@ -2,7 +2,7 @@ import pytestfrom ...product.utils.preparing_product import prepare_productfrom ...promotions.utils import create_promotion, create_promotion_rule-from ...shop.utils.preparing_shop import prepare_shop+from ...shop.utils.preparing_shop import prepare_default_shopfrom ...utils import assign_permissionsfrom ...vouchers.utils import (add_catalogue_to_voucher,@@ -121,9 +121,7 @@ def prepare_voucher(def test_checkout_with_promotion_and_voucher_CORE_2107(e2e_not_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,variant_price,@@ -137,20 +135,17 @@ def test_checkout_with_promotion_and_voucher_CORE_2107():# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](product_id,@@ -193,7 +188,6 @@ def test_checkout_with_promotion_and_voucher_CORE_2107()checkout_id = checkout_data["id"]checkout_lines = checkout_data["lines"][0]- shipping_method_id = checkout_data["shippingMethods"][0]["id"]assert checkout_data["isShippingRequired"] is Trueunit_price_with_promotion = round(diff --git a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_apply_voucher_to_the_specific_product_per_order.py b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_apply_voucher_to_the_specific_product_per_order.pyindex 66d8fed29a..40e881c4f0 100644--- a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_apply_voucher_to_the_specific_product_per_order.py+++ b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_apply_voucher_to_the_specific_product_per_order.py@@ -8,7 +8,7 @@ from ....product.utils import (create_product_variant,create_product_variant_channel_listing,)-from ....shop.utils.preparing_shop import prepare_shop+from ....shop.utils import prepare_default_shopfrom ....utils import assign_permissionsfrom ....vouchers.utils import (create_voucher,@@ -162,30 +162,25 @@ def prepare_voucher(def test_checkout_apply_voucher_to_the_specific_product_per_order_CORE_0915(e2e_not_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_checkouts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_checkouts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](first_product_id,@@ -232,7 +227,6 @@ def test_checkout_apply_voucher_to_the_specific_product_per_order_CORE_0915()checkout_id = checkout["id"]checkout_line = checkout["lines"]- shipping_method_id = checkout["shippingMethods"][0]["id"]first_product_unit_price = float(first_product_variant_price)second_product_unit_price = float(second_product_variant_price)total_gross_amount = checkout["totalPrice"]["gross"]["amount"]diff --git a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_unable_to_exceed_voucher_usage_limit.py b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_unable_to_exceed_voucher_usage_limit.pyindex 312a39f189..27e274d05b 100644--- a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_unable_to_exceed_voucher_usage_limit.py+++ b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_unable_to_exceed_voucher_usage_limit.py@@ -1,7 +1,7 @@import pytestfrom ....product.utils.preparing_product import prepare_product-from ....shop.utils.preparing_shop import prepare_shop+from ....shop.utils import prepare_default_shopfrom ....utils import assign_permissionsfrom ....vouchers.utils import (create_voucher,@@ -57,30 +57,25 @@ def test_checkout_unable_to_exceed_voucher_usage_limit_CORE_0909(e2e_not_logged_api_client,e2e_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_checkouts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_checkouts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](product_id,@@ -120,7 +115,6 @@ def test_checkout_unable_to_exceed_voucher_usage_limit_CORE_0909()checkout_id = checkout["id"]checkout_lines = checkout["lines"][0]- shipping_method_id = checkout["shippingMethods"][0]["id"]unit_price = float(product_variant_price)total_gross_amount = checkout["totalPrice"]["gross"]["amount"]assert checkout["isShippingRequired"] is Truediff --git a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_unable_to_update_single_use_settings_after_usage.py b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_unable_to_update_single_use_settings_after_usage.pyindex 2a0a758762..9256da2425 100644--- a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_unable_to_update_single_use_settings_after_usage.py+++ b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_unable_to_update_single_use_settings_after_usage.py@@ -1,7 +1,7 @@import pytestfrom ....product.utils.preparing_product import prepare_product-from ....shop.utils.preparing_shop import prepare_shop+from ....shop.utils import prepare_default_shopfrom ....utils import assign_permissionsfrom ....vouchers.utils import (create_voucher,@@ -53,30 +53,25 @@ def prepare_voucher(def test_checkout_unable_to_update_single_use_settings_after_usage_CORE_0926(e2e_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_checkouts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_checkouts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](_product_id,@@ -113,7 +108,6 @@ def test_checkout_unable_to_update_single_use_settings_after_usage_CORE_0926()checkout_id = checkout["id"]checkout_lines = checkout["lines"][0]- shipping_method_id = checkout["shippingMethods"][0]["id"]unit_price = float(product_variant_price)assert checkout["isShippingRequired"] is Trueassert checkout_lines["unitPrice"]["gross"]["amount"] == unit_pricediff --git a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_unable_to_use_deleted_voucher.py b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_unable_to_use_deleted_voucher.pyindex a8682e4871..ee6acabb4d 100644--- a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_unable_to_use_deleted_voucher.py+++ b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_unable_to_use_deleted_voucher.py@@ -1,7 +1,7 @@import pytestfrom ....product.utils.preparing_product import prepare_product-from ....shop.utils.preparing_shop import prepare_shop+from ....shop.utils import prepare_default_shopfrom ....utils import assign_permissionsfrom ....vouchers.utils import (create_voucher,@@ -47,30 +47,24 @@ def prepare_voucher(def test_checkout_unable_to_use_deleted_voucher_CORE_0923(e2e_staff_api_client,e2e_not_logged_api_client,- permission_manage_channels,- permission_manage_shipping,- permission_manage_products,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_checkouts,):# Beforepermissions = [- permission_manage_channels,- permission_manage_shipping,- permission_manage_products,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_checkouts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- _shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"](_product_id,diff --git a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_unable_to_use_deleted_voucher_code.py b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_unable_to_use_deleted_voucher_code.pyindex 338a68583c..d4ef023a73 100644--- a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_unable_to_use_deleted_voucher_code.py+++ b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_unable_to_use_deleted_voucher_code.py@@ -1,7 +1,7 @@import pytestfrom ....product.utils.preparing_product import prepare_product-from ....shop.utils.preparing_shop import prepare_shop+from ....shop.utils import prepare_default_shopfrom ....utils import assign_permissionsfrom ....vouchers.utils import (create_voucher,@@ -47,30 +47,25 @@ def create_voucher_with_multiple_codes(e2e_staff_api_client, channel_id):def test_checkout_unable_to_use_deleted_voucher_code_CORE_0914(e2e_staff_api_client,e2e_logged_api_client,- permission_manage_channels,- permission_manage_shipping,- permission_manage_products,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_checkouts,):# Beforepermissions = [- permission_manage_channels,- permission_manage_shipping,- permission_manage_products,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_checkouts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- _shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+(_product_id,product_variant_id,diff --git a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_unable_to_use_expired_voucher.py b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_unable_to_use_expired_voucher.pyindex de04497f37..858f2bc281 100644--- a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_unable_to_use_expired_voucher.py+++ b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_unable_to_use_expired_voucher.py@@ -4,7 +4,7 @@ import pytestfrom django.utils import timezonefrom ....product.utils.preparing_product import prepare_product-from ....shop.utils.preparing_shop import prepare_shop+from ....shop.utils import prepare_default_shopfrom ....utils import assign_permissionsfrom ....vouchers.utils import (create_voucher,@@ -60,33 +60,28 @@ def prepare_voucher(def test_checkout_unable_to_use_expired_voucher_CORE_0921(e2e_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_checkouts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_checkouts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](- product_id,+ _product_id,product_variant_id,product_variant_price,) = prepare_product(@@ -126,7 +121,6 @@ def test_checkout_unable_to_use_expired_voucher_CORE_0921()checkout_id = checkout["id"]checkout_lines = checkout["lines"][0]- shipping_method_id = checkout["shippingMethods"][0]["id"]unit_price = float(product_variant_price)total_gross_amount = checkout["totalPrice"]["gross"]["amount"]assert checkout["isShippingRequired"] is Truediff --git a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_unable_to_use_not_started_voucher.py b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_unable_to_use_not_started_voucher.pyindex 4f4c348564..73651c07d9 100644--- a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_unable_to_use_not_started_voucher.py+++ b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_unable_to_use_not_started_voucher.py@@ -4,7 +4,7 @@ import pytestfrom django.utils import timezonefrom ....product.utils.preparing_product import prepare_product-from ....shop.utils.preparing_shop import prepare_shop+from ....shop.utils import prepare_default_shopfrom ....utils import assign_permissionsfrom ....vouchers.utils import (create_voucher,@@ -59,30 +59,25 @@ def prepare_voucher(def test_checkout_unable_to_use_not_started_voucher_CORE_0920(e2e_not_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_checkouts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_checkouts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](_product_id,@@ -125,7 +120,6 @@ def test_checkout_unable_to_use_not_started_voucher_CORE_0920()checkout_id = checkout["id"]checkout_lines = checkout["lines"][0]- shipping_method_id = checkout["shippingMethods"][0]["id"]unit_price = float(product_variant_price)total_gross_amount = checkout["totalPrice"]["gross"]["amount"]assert checkout["isShippingRequired"] is Truediff --git a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_use_voucher_for_cheapest_product.py b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_use_voucher_for_cheapest_product.pyindex 4bb6a78369..0e651d7bae 100644--- a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_use_voucher_for_cheapest_product.py+++ b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_use_voucher_for_cheapest_product.py@@ -5,7 +5,7 @@ from ....product.utils import (create_product_variant_channel_listing,)from ....product.utils.preparing_product import prepare_product-from ....shop.utils.preparing_shop import prepare_shop+from ....shop.utils import prepare_default_shopfrom ....utils import assign_permissionsfrom ....vouchers.utils import create_voucher, create_voucher_channel_listingfrom ...utils import (@@ -63,9 +63,7 @@ def prepare_voucher_for_cheapest_product(def test_checkout_use_voucher_for_cheapest_product_0907(e2e_not_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,first_variant_price,@@ -76,20 +74,17 @@ def test_checkout_use_voucher_for_cheapest_product_0907():# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](product_id,@@ -147,7 +142,6 @@ def test_checkout_use_voucher_for_cheapest_product_0907()checkout_id = checkout_data["id"]checkout_lines = checkout_data["lines"]- shipping_method_id = checkout_data["shippingMethods"][0]["id"]assert checkout_data["isShippingRequired"] is Truefirst_line = checkout_lines[0]diff --git a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_user_cannot_use_voucher_for_staff_only.py b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_user_cannot_use_voucher_for_staff_only.pyindex 227402a491..be50a88ab7 100644--- a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_user_cannot_use_voucher_for_staff_only.py+++ b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_user_cannot_use_voucher_for_staff_only.py@@ -1,7 +1,7 @@import pytestfrom ....product.utils.preparing_product import prepare_product-from ....shop.utils.preparing_shop import prepare_shop+from ....shop.utils import prepare_default_shopfrom ....utils import assign_permissionsfrom ....vouchers.utils import create_voucher, create_voucher_channel_listingfrom ...utils import checkout_create, raw_checkout_add_promo_code@@ -42,29 +42,23 @@ def prepare_voucher_for_staff_only(def test_user_cannot_use_voucher_for_staff_only_in_checkout_core_0905(e2e_staff_api_client,e2e_not_logged_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- _shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"](_product_id,diff --git a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_voucher_is_still_active_when_checkout_fails.py b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_voucher_is_still_active_when_checkout_fails.pyindex 6b4408ba5a..978abbefd8 100644--- a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_voucher_is_still_active_when_checkout_fails.py+++ b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_voucher_is_still_active_when_checkout_fails.py@@ -2,7 +2,7 @@ import pytestfrom ....product.utils import product_variant_stock_updatefrom ....product.utils.preparing_product import prepare_product-from ....shop.utils.preparing_shop import prepare_shop+from ....shop.utils import prepare_default_shopfrom ....utils import assign_permissionsfrom ....vouchers.utils import (create_voucher,@@ -53,30 +53,25 @@ def prepare_voucher(def test_checkout_voucher_is_still_active_when_checkout_fails_core_0918(e2e_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_checkouts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_checkouts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](_product_id,diff --git a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_voucher_is_still_active_when_payment_fails.py b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_voucher_is_still_active_when_payment_fails.pyindex be007d16e3..a24f3f4a83 100644--- a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_voucher_is_still_active_when_payment_fails.py+++ b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_voucher_is_still_active_when_payment_fails.py@@ -1,7 +1,7 @@import pytestfrom ....product.utils.preparing_product import prepare_product-from ....shop.utils.preparing_shop import prepare_shop+from ....shop.utils import prepare_default_shopfrom ....utils import assign_permissionsfrom ....vouchers.utils import (create_voucher,@@ -51,30 +51,25 @@ def prepare_voucher(def test_checkout_voucher_is_still_active_when_payment_fails_core_0919(e2e_not_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_checkouts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_checkouts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](_product_id,@@ -113,7 +108,6 @@ def test_checkout_voucher_is_still_active_when_payment_fails_core_0919()checkout_id = checkout["id"]checkout_lines = checkout["lines"][0]- shipping_method_id = checkout["shippingMethods"][0]["id"]unit_price = float(product_variant_price)total_gross_amount = checkout["totalPrice"]["gross"]["amount"]diff --git a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_fixed_voucher.py b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_fixed_voucher.pyindex c25aa69341..df200cf559 100644--- a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_fixed_voucher.py+++ b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_fixed_voucher.py@@ -1,7 +1,7 @@import pytestfrom ....product.utils.preparing_product import prepare_product-from ....shop.utils.preparing_shop import prepare_shop+from ....shop.utils import prepare_default_shopfrom ....utils import assign_permissionsfrom ....vouchers.utils import create_voucher, create_voucher_channel_listingfrom ...utils import (@@ -49,28 +49,23 @@ def prepare_fixed_voucher(def test_checkout_use_fixed_voucher_core_0901(e2e_not_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](_product_id,@@ -121,7 +116,6 @@ def test_checkout_use_fixed_voucher_core_0901(e2e_not_logged_api_client, checkout_id)assert len(checkout_data["shippingMethods"]) == 1- shipping_method_id = checkout_data["shippingMethods"][0]["id"]checkout_data = checkout_delivery_method_update(e2e_not_logged_api_client,diff --git a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_fixed_voucher_should_not_result_in_negative_variant_price.py b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_fixed_voucher_should_not_result_in_negative_variant_price.pyindex 4ba721cde4..f222307915 100644--- a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_fixed_voucher_should_not_result_in_negative_variant_price.py+++ b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_fixed_voucher_should_not_result_in_negative_variant_price.py@@ -1,7 +1,7 @@import pytestfrom ....product.utils.preparing_product import prepare_product-from ....shop.utils.preparing_shop import prepare_shop+from ....shop.utils import prepare_default_shopfrom ....utils import assign_permissionsfrom ....vouchers.utils import create_voucher, create_voucher_channel_listingfrom ...utils import (@@ -51,28 +51,23 @@ def prepare_fixed_voucher(def test_checkout_voucher_should_not_cause_negative_variant_price_CORE_0911(e2e_not_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](product_id,@@ -123,7 +118,6 @@ def test_checkout_voucher_should_not_cause_negative_variant_price_CORE_0911(e2e_not_logged_api_client, checkout_id)assert len(checkout_data["shippingMethods"]) == 1- shipping_method_id = checkout_data["shippingMethods"][0]["id"]checkout_data = checkout_delivery_method_update(e2e_not_logged_api_client,diff --git a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_free_shipping_voucher_with_min_quantity_of_items.py b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_free_shipping_voucher_with_min_quantity_of_items.pyindex ce0831d9a0..bd6173c27f 100644--- a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_free_shipping_voucher_with_min_quantity_of_items.py+++ b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_free_shipping_voucher_with_min_quantity_of_items.py@@ -1,7 +1,7 @@import pytestfrom ....product.utils.preparing_product import prepare_product-from ....shop.utils.preparing_shop import prepare_shop+from ....shop.utils import prepare_default_shopfrom ....utils import assign_permissionsfrom ....vouchers.utils import create_voucher, create_voucher_channel_listingfrom ...utils import (@@ -51,28 +51,23 @@ def prepare_free_shipping_voucher(def test_checkout_use_free_shipping_voucher_with_min_quantity_of_items_0906(e2e_not_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](_product_id,@@ -112,7 +107,6 @@ def test_checkout_use_free_shipping_voucher_with_min_quantity_of_items_0906()checkout_id = checkout_data["id"]checkout_lines = checkout_data["lines"][0]- shipping_method_id = checkout_data["shippingMethods"][0]["id"]assert checkout_data["isShippingRequired"] is Trueassert checkout_lines["unitPrice"]["gross"]["amount"] == float(diff --git a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_free_shipping_voucher_with_min_spent_amount.py b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_free_shipping_voucher_with_min_spent_amount.pyindex 6216ad9a27..af22e1dd5b 100644--- a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_free_shipping_voucher_with_min_spent_amount.py+++ b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_free_shipping_voucher_with_min_spent_amount.py@@ -1,7 +1,7 @@import pytestfrom ....product.utils.preparing_product import prepare_product-from ....shop.utils.preparing_shop import prepare_shop+from ....shop.utils import prepare_default_shopfrom ....utils import assign_permissionsfrom ....vouchers.utils import create_voucher, create_voucher_channel_listingfrom ...utils import (@@ -51,28 +51,23 @@ def prepare_free_shipping_voucher(def test_checkout_use_free_shipping_voucher_with_min_spent_amount_0903(e2e_not_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](_product_id,@@ -112,7 +107,6 @@ def test_checkout_use_free_shipping_voucher_with_min_spent_amount_0903()checkout_id = checkout_data["id"]checkout_lines = checkout_data["lines"][0]- shipping_method_id = checkout_data["shippingMethods"][0]["id"]assert checkout_data["isShippingRequired"] is Trueassert checkout_lines["unitPrice"]["gross"]["amount"] == float(diff --git a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_percentage_voucher.py b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_percentage_voucher.pyindex 93fe864a84..73b24b0253 100644--- a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_percentage_voucher.py+++ b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_percentage_voucher.py@@ -1,7 +1,7 @@import pytestfrom ....product.utils.preparing_product import prepare_product-from ....shop.utils.preparing_shop import prepare_shop+from ....shop.utils import prepare_default_shopfrom ....utils import assign_permissionsfrom ....vouchers.utils import create_voucher, create_voucher_channel_listingfrom ...utils import (@@ -48,28 +48,23 @@ def prepare_percentage_voucher(def test_checkout_use_percentage_voucher_core_0902(e2e_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](_product_id,@@ -108,7 +103,6 @@ def test_checkout_use_percentage_voucher_core_0902()checkout_id = checkout["id"]checkout_lines = checkout["lines"][0]- shipping_method_id = checkout["shippingMethods"][0]["id"]unit_price = float(product_variant_price)assert checkout["isShippingRequired"] is Trueassert checkout_lines["unitPrice"]["gross"]["amount"] == unit_pricediff --git a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_voucher_limit_per_customer.py b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_voucher_limit_per_customer.pyindex 7fdd51f5f0..ce50a76a4f 100644--- a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_voucher_limit_per_customer.py+++ b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_voucher_limit_per_customer.py@@ -1,7 +1,7 @@import pytestfrom ....product.utils.preparing_product import prepare_product-from ....shop.utils.preparing_shop import prepare_shop+from ....shop.utils import prepare_default_shopfrom ....utils import assign_permissionsfrom ....vouchers.utils import (create_voucher,@@ -58,30 +58,25 @@ def prepare_voucher(def test_checkout_with_voucher_limit_per_customer_CORE_0910(e2e_not_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_checkouts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_checkouts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](product_id,@@ -121,7 +116,6 @@ def test_checkout_with_voucher_limit_per_customer_CORE_0910()checkout_id = checkout["id"]checkout_lines = checkout["lines"][0]- shipping_method_id = checkout["shippingMethods"][0]["id"]unit_price = float(product_variant_price)total_gross_amount = checkout["totalPrice"]["gross"]["amount"]assert checkout["isShippingRequired"] is Truediff --git a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_voucher_with_min_item_quantity.py b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_voucher_with_min_item_quantity.pyindex aa818a8441..7f17b62f2c 100644--- a/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_voucher_with_min_item_quantity.py+++ b/saleor/tests/e2e/checkout/discounts/vouchers/test_checkout_with_voucher_with_min_item_quantity.py@@ -1,7 +1,7 @@import pytestfrom ....product.utils.preparing_product import prepare_product-from ....shop.utils.preparing_shop import prepare_shop+from ....shop.utils import prepare_default_shopfrom ....utils import assign_permissionsfrom ....vouchers.utils import (create_voucher,@@ -59,30 +59,25 @@ def prepare_voucher(def test_checkout_with_voucher_with_min_item_quantity_core_0908(e2e_not_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_checkouts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_checkouts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](product_id,@@ -122,7 +117,6 @@ def test_checkout_with_voucher_with_min_item_quantity_core_0908()checkout_id = checkout["id"]checkout_lines = checkout["lines"][0]- shipping_method_id = checkout["shippingMethods"][0]["id"]unit_price = float(product_variant_price)assert checkout["isShippingRequired"] is Trueassert checkout_lines["unitPrice"]["gross"]["amount"] == unit_pricediff --git a/saleor/tests/e2e/checkout/discounts/vouchers/test_only_one_voucher_per_checkout.py b/saleor/tests/e2e/checkout/discounts/vouchers/test_only_one_voucher_per_checkout.pyindex 2fa19a2178..dce871910f 100644--- a/saleor/tests/e2e/checkout/discounts/vouchers/test_only_one_voucher_per_checkout.py+++ b/saleor/tests/e2e/checkout/discounts/vouchers/test_only_one_voucher_per_checkout.py@@ -1,7 +1,7 @@import pytestfrom ....product.utils.preparing_product import prepare_product-from ....shop.utils.preparing_shop import prepare_shop+from ....shop.utils import prepare_default_shopfrom ....utils import assign_permissionsfrom ....vouchers.utils import (create_voucher,@@ -83,30 +83,25 @@ def prepare_fixed_voucher(def test_checkout_use_fixed_voucher_core_0901(e2e_not_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_checkouts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_checkouts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](_product_id,@@ -166,7 +161,6 @@ def test_checkout_use_fixed_voucher_core_0901(e2e_not_logged_api_client, checkout_id)assert len(checkout_data["shippingMethods"]) == 1- shipping_method_id = checkout_data["shippingMethods"][0]["id"]checkout_data = checkout_delivery_method_update(e2e_not_logged_api_client,diff --git a/saleor/tests/e2e/checkout/discounts/vouchers/test_should_be_able_to_remove_voucher_code_from_checkout.py b/saleor/tests/e2e/checkout/discounts/vouchers/test_should_be_able_to_remove_voucher_code_from_checkout.pyindex 1bbcb05e44..d582980714 100644--- a/saleor/tests/e2e/checkout/discounts/vouchers/test_should_be_able_to_remove_voucher_code_from_checkout.py+++ b/saleor/tests/e2e/checkout/discounts/vouchers/test_should_be_able_to_remove_voucher_code_from_checkout.py@@ -1,7 +1,7 @@import pytestfrom ....product.utils.preparing_product import prepare_product-from ....shop.utils.preparing_shop import prepare_shop+from ....shop.utils import prepare_default_shopfrom ....utils import assign_permissionsfrom ....vouchers.utils import (create_voucher,@@ -54,30 +54,25 @@ def prepare_fixed_voucher(def test_should_be_able_to_remove_voucher_code_from_checkout_CORE_0917(e2e_not_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_checkouts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_checkouts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](_product_id,@@ -128,7 +123,6 @@ def test_should_be_able_to_remove_voucher_code_from_checkout_CORE_0917(e2e_not_logged_api_client, checkout_id)assert len(checkout_data["shippingMethods"]) == 1- shipping_method_id = checkout_data["shippingMethods"][0]["id"]checkout_data = checkout_delivery_method_update(e2e_not_logged_api_client,diff --git a/saleor/tests/e2e/checkout/discounts/vouchers/test_staff_user_can_use_voucher_for_staff_only.py b/saleor/tests/e2e/checkout/discounts/vouchers/test_staff_user_can_use_voucher_for_staff_only.pyindex 423e3e5821..cc8a30b4f2 100644--- a/saleor/tests/e2e/checkout/discounts/vouchers/test_staff_user_can_use_voucher_for_staff_only.py+++ b/saleor/tests/e2e/checkout/discounts/vouchers/test_staff_user_can_use_voucher_for_staff_only.py@@ -1,7 +1,7 @@import pytestfrom ....product.utils.preparing_product import prepare_product-from ....shop.utils.preparing_shop import prepare_shop+from ....shop.utils import prepare_default_shopfrom ....utils import assign_permissionsfrom ....vouchers.utils import create_voucher, create_voucher_channel_listingfrom ...utils import (@@ -48,29 +48,23 @@ def prepare_voucher_for_staff_only(def test_staff_can_use_voucher_for_staff_only_in_checkout_core_0904(e2e_staff_api_client,e2e_no_permission_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,):# Before-permissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](_product_id,@@ -107,7 +101,6 @@ def test_staff_can_use_voucher_for_staff_only_in_checkout_core_0904(set_default_shipping_address=True,)checkout_id = checkout_data["id"]- shipping_method_id = checkout_data["shippingMethods"][0]["id"]checkout_lines = checkout_data["lines"][0]assert checkout_lines["unitPrice"]["gross"]["amount"] == float(product_variant_pricediff --git a/saleor/tests/e2e/checkout/taxes/test_checkout_calculate_simple_taxes_based_on_shipping_country.py b/saleor/tests/e2e/checkout/taxes/test_checkout_calculate_simple_taxes_based_on_shipping_country.pyindex fd8765bf47..f56fcbfd29 100644--- a/saleor/tests/e2e/checkout/taxes/test_checkout_calculate_simple_taxes_based_on_shipping_country.py+++ b/saleor/tests/e2e/checkout/taxes/test_checkout_calculate_simple_taxes_based_on_shipping_country.py@@ -1,19 +1,9 @@import pytest-from ...channel.utils import create_channelfrom ...product.utils.preparing_product import prepare_product-from ...shipping_zone.utils import (- create_shipping_method,- create_shipping_method_channel_listing,- create_shipping_zone,-)-from ...taxes.utils import (- get_tax_configurations,- update_country_tax_rates,- update_tax_configuration,-)+from ...shop.utils import prepare_shop+from ...taxes.utils import update_country_tax_ratesfrom ...utils import assign_permissions-from ...warehouse.utils import create_warehousefrom ..utils import (checkout_billing_address_update,checkout_complete,@@ -25,118 +15,86 @@ from ..utils import ()-def prepare_shop_with_few_shipping_zone_countries(- e2e_staff_api_client,- shipping_price,-):- 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,- countries=["CZ", "DE", "US"],- 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,- price=shipping_price,- )-- return (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- shipping_price,- )---def prepare_tax_configuration(- e2e_staff_api_client,- channel_slug,- shipping_country_code,- shipping_country_tax_rate,- billing_country_code,- billing_country_tax_rate,- prices_entered_with_tax,-):- tax_config_data = get_tax_configurations(e2e_staff_api_client)- channel_tax_config = tax_config_data[0]["node"]- assert channel_tax_config["channel"]["slug"] == channel_slug- tax_config_id = channel_tax_config["id"]-- tax_config_data = update_tax_configuration(- e2e_staff_api_client,- tax_config_id,- charge_taxes=True,- tax_calculation_strategy="FLAT_RATES",- display_gross_prices=True,- prices_entered_with_tax=prices_entered_with_tax,- )- update_country_tax_rates(- e2e_staff_api_client,- shipping_country_code,- [{"rate": shipping_country_tax_rate}],- )- update_country_tax_rates(- e2e_staff_api_client, billing_country_code, [{"rate": billing_country_tax_rate}]- )- return shipping_country_tax_rate--@pytest.mark.e2edef test_checkout_calculate_simple_tax_based_on_shipping_country_CORE_2001(e2e_staff_api_client,e2e_not_logged_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,- permission_manage_taxes,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_taxes,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- shipping_price,- ) = prepare_shop_with_few_shipping_zone_countries(e2e_staff_api_client, "6.66")+ tax_settings = {+ "charge_taxes": True,+ "tax_calculation_strategy": "FLAT_RATES",+ "display_gross_prices": False,+ "prices_entered_with_tax": True,+ }+ shipping_price = "6.66"- shipping_country_tax_rate = prepare_tax_configuration(+ shop_data, _tax_config = prepare_shop(e2e_staff_api_client,- channel_slug,- shipping_country_code="CZ",- shipping_country_tax_rate=21,- billing_country_code="DE",- billing_country_tax_rate=19,- prices_entered_with_tax=True,+ channels=[+ {+ "shipping_zones": [+ {+ "countries": ["US"],+ "shipping_methods": [+ {+ "name": "us shipping zone",+ "add_channels": {"price": "6.66"},+ }+ ],+ },+ {+ "countries": ["CZ"],+ "shipping_methods": [+ {+ "name": "cz shipping zone",+ "add_channels": {"price": "6.66"},+ }+ ],+ },+ {+ "countries": ["DE"],+ "shipping_methods": [+ {+ "name": "de shipping zone",+ "add_channels": {"price": shipping_price},+ }+ ],+ },+ ],+ "order_settings": {},+ }+ ],+ tax_settings=tax_settings,+ )+ channel_id = shop_data[0]["id"]+ channel_slug = shop_data[0]["slug"]+ warehouse_id = shop_data[0]["warehouse_id"]+ cz_shipping_method_id = shop_data[0]["shipping_zones"][1]["shipping_methods"][0][+ "id"+ ]+ shipping_country_tax_rate = 21+ shipping_country_code = "CZ"+ billing_country_tax_rate = 19+ billing_country_code = "DE"++ update_country_tax_rates(+ e2e_staff_api_client,+ shipping_country_code,+ [{"rate": shipping_country_tax_rate}],+ )+ update_country_tax_rates(+ e2e_staff_api_client,+ billing_country_code,+ [{"rate": billing_country_tax_rate}],)variant_price = "17.77"@@ -151,7 +109,7 @@ def test_checkout_calculate_simple_tax_based_on_shipping_country_CORE_2001(variant_price,)- # Step 1 - Create checkout.+ # Step 1 - Create checkoutlines = [{"variantId": product_variant_id,@@ -169,7 +127,7 @@ def test_checkout_calculate_simple_tax_based_on_shipping_country_CORE_2001(assert checkout_data["isShippingRequired"] is True- # Step 2 - Set shipping address for checkout.+ # Step 2 - Set shipping address for checkoutshipping_address = {"firstName": "John","lastName": "Muller",@@ -182,15 +140,16 @@ def test_checkout_calculate_simple_tax_based_on_shipping_country_CORE_2001("phone": "+420722274643","countryArea": "",}+checkout_data = checkout_shipping_address_update(e2e_not_logged_api_client,checkout_id,shipping_address,)+assert len(checkout_data["shippingMethods"]) == 1- shipping_method_id = checkout_data["shippingMethods"][0]["id"]- # Step 3 - Set billing address for checkout.+ # Step 3 - Set billing address for checkoutbilling_address = {"firstName": "John","lastName": "Muller",@@ -219,13 +178,14 @@ def test_checkout_calculate_simple_tax_based_on_shipping_country_CORE_2001(== float(variant_price) - calculated_tax)- # Step 5 - Set DeliveryMethod for checkout.+ # Step 5 - Set DeliveryMethod for checkoutcheckout_data = checkout_delivery_method_update(e2e_not_logged_api_client,checkout_id,- shipping_method_id,+ cz_shipping_method_id,)- assert checkout_data["deliveryMethod"]["id"] == shipping_method_id+ assert checkout_data["deliveryMethod"]["id"] == cz_shipping_method_id+assert checkout_data["shippingPrice"]["gross"]["amount"] == float(shipping_price)shipping_tax = round((float(shipping_price) * shipping_country_tax_rate)@@ -243,14 +203,14 @@ def test_checkout_calculate_simple_tax_based_on_shipping_country_CORE_2001(total_tax = calculated_tax + shipping_taxassert checkout_data["totalPrice"]["tax"]["amount"] == total_tax- # Step 6 - Create payment for checkout.+ # Step 6 - Create payment for checkoutcheckout_dummy_payment_create(e2e_not_logged_api_client,checkout_id,total_gross_amount,)- # Step 7 - Complete checkout.+ # Step 7 - Complete checkoutorder_data = checkout_complete(e2e_not_logged_api_client,checkout_id,diff --git a/saleor/tests/e2e/checkout/taxes/test_checkout_calculate_simple_taxes_based_on_shipping_tax_class.py b/saleor/tests/e2e/checkout/taxes/test_checkout_calculate_simple_taxes_based_on_shipping_tax_class.pyindex 10d0bb3e91..1167e50228 100644--- a/saleor/tests/e2e/checkout/taxes/test_checkout_calculate_simple_taxes_based_on_shipping_tax_class.py+++ b/saleor/tests/e2e/checkout/taxes/test_checkout_calculate_simple_taxes_based_on_shipping_tax_class.py@@ -3,12 +3,7 @@ import pytestfrom ...product.utils.preparing_product import prepare_productfrom ...shipping_zone.utils import update_shipping_pricefrom ...shop.utils import prepare_shop-from ...taxes.utils import (- create_tax_class,- get_tax_configurations,- update_country_tax_rates,- update_tax_configuration,-)+from ...taxes.utils import update_country_tax_ratesfrom ...utils import assign_permissionsfrom ..utils import (checkout_complete,@@ -18,78 +13,76 @@ from ..utils import ()-def prepare_tax_configuration(- e2e_staff_api_client,- channel_slug,- country_code,- country_tax_rate,- shipping_tax_rate,- prices_entered_with_tax,-):- tax_config_data = get_tax_configurations(e2e_staff_api_client)- channel_tax_config = tax_config_data[0]["node"]- assert channel_tax_config["channel"]["slug"] == channel_slug- tax_config_id = channel_tax_config["id"]-- tax_config_data = update_tax_configuration(- e2e_staff_api_client,- tax_config_id,- charge_taxes=True,- tax_calculation_strategy="FLAT_RATES",- display_gross_prices=True,- prices_entered_with_tax=prices_entered_with_tax,- )- update_country_tax_rates(- e2e_staff_api_client,- country_code,- [{"rate": country_tax_rate}],- )-- country_rates = [{"countryCode": country_code, "rate": shipping_tax_rate}]- tax_class_data = create_tax_class(- e2e_staff_api_client,- "Shipping tax class",- country_rates,- )- tax_class_id = tax_class_data["id"]-- return country_tax_rate, shipping_tax_rate, tax_class_id--@pytest.mark.e2edef test_checkout_calculate_simple_tax_based_on_shipping_tax_class_CORE_2009(e2e_staff_api_client,e2e_not_logged_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,- permission_manage_taxes,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_taxes,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shipping_country = "US"+ shipping_class_tax_rate = 8+ tax_settings = {+ "charge_taxes": True,+ "tax_calculation_strategy": "FLAT_RATES",+ "display_gross_prices": False,+ "prices_entered_with_tax": False,+ "tax_rates": [+ {+ "type": "shipping_country",+ "name": "Shipping Country Tax Rate",+ "country_code": shipping_country,+ "rate": shipping_class_tax_rate,+ },+ ],+ }++ shop_data, tax_config = prepare_shop(+ e2e_staff_api_client,+ channels=[+ {+ "shipping_zones": [+ {+ "shipping_methods": [+ {+ "add_channels": {},+ }+ ],+ },+ ],+ "order_settings": {},+ },+ ],+ tax_settings=tax_settings,+ )+ channel_id = shop_data[0]["id"]+ channel_slug = shop_data[0]["slug"]+ shipping_method_id = shop_data[0]["shipping_zones"][0]["shipping_methods"][0]["id"]++ shipping_price = 10.0+ warehouse_id = shop_data[0]["warehouse_id"]+ shipping_tax_class_id = tax_config[0]["shipping_country_tax_class_id"]+ shipping_class_tax_rate = tax_config[1]["shipping_country"]["rate"]+ billing_country_code = "US"+ billing_country_tax_rate = 10- country_tax_rate, shipping_tax_rate, tax_class_id = prepare_tax_configuration(+ update_country_tax_rates(e2e_staff_api_client,- channel_slug,- country_code="US",- country_tax_rate=10,- shipping_tax_rate=8,- prices_entered_with_tax=False,+ shipping_country,+ [{"rate": shipping_class_tax_rate}],+ )+ input_data = {"taxClass": shipping_tax_class_id}+ update_shipping_price(+ e2e_staff_api_client,+ shipping_method_id,+ input_data,)variant_price = "17.87"@@ -103,8 +96,6 @@ def test_checkout_calculate_simple_tax_based_on_shipping_tax_class_CORE_2009(channel_id,variant_price,)- shipping_tax_class = {"taxClass": tax_class_id}- update_shipping_price(e2e_staff_api_client, shipping_method_id, shipping_tax_class)# Step 1 - Create checkout and check priceslines = [@@ -124,13 +115,13 @@ def test_checkout_calculate_simple_tax_based_on_shipping_tax_class_CORE_2009()product_variant_price = float(product_variant_price)checkout_id = checkout_data["id"]- shipping_method_id = checkout_data["shippingMethods"][0]["id"]subtotal_net = round((product_variant_price * 2), 2)- subtotal_tax = round(subtotal_net * (country_tax_rate / 100), 2)+ subtotal_tax = round(subtotal_net * (shipping_class_tax_rate / 100), 2)subtotal_gross = subtotal_net + subtotal_taxassert checkout_data["isShippingRequired"] is True+ assert checkout_data["billingAddress"]["country"]["code"] == billing_country_codeassert checkout_data["totalPrice"]["gross"]["amount"] == subtotal_grossassert checkout_data["totalPrice"]["tax"]["amount"] == subtotal_taxassert checkout_data["totalPrice"]["net"]["amount"] == subtotal_net@@ -141,18 +132,20 @@ def test_checkout_calculate_simple_tax_based_on_shipping_tax_class_CORE_2009(checkout_id,shipping_method_id,)- shipping_net_price = checkout_data["deliveryMethod"]["price"]["amount"]-+ shipping_net_price = shipping_priceshipping_net = shipping_net_price- shipping_tax = round(shipping_net * (shipping_tax_rate / 100), 2)+ shipping_tax = round(shipping_net * (shipping_class_tax_rate / 100), 2)+ billing_tax = round(subtotal_net * (billing_country_tax_rate / 100), 2)shipping_gross = shipping_net + shipping_taxassert checkout_data["deliveryMethod"]["id"] == shipping_method_idassert checkout_data["shippingPrice"]["net"]["amount"] == shipping_netassert checkout_data["shippingPrice"]["tax"]["amount"] == shipping_tax+ assert checkout_data["shippingPrice"]["tax"]["amount"] != billing_tax+assert checkout_data["shippingPrice"]["gross"]["amount"] == shipping_gross- total_gross_amount = subtotal_gross + shipping_gross+ total_gross_amount = round((subtotal_gross + shipping_gross), 1)total_net_amount = subtotal_net + shipping_nettotal_tax_amount = subtotal_tax + shipping_taxdiff --git a/saleor/tests/e2e/checkout/taxes/test_checkout_calculate_simple_taxes_for_digital_product.py b/saleor/tests/e2e/checkout/taxes/test_checkout_calculate_simple_taxes_for_digital_product.pyindex a44c120d76..ccc1fef1bd 100644--- a/saleor/tests/e2e/checkout/taxes/test_checkout_calculate_simple_taxes_for_digital_product.py+++ b/saleor/tests/e2e/checkout/taxes/test_checkout_calculate_simple_taxes_for_digital_product.py@@ -1,19 +1,9 @@import pytest-from ...channel.utils import create_channelfrom ...product.utils.preparing_product import prepare_digital_product-from ...shipping_zone.utils import (- create_shipping_method,- create_shipping_method_channel_listing,- create_shipping_zone,-)-from ...taxes.utils import (- get_tax_configurations,- update_country_tax_rates,- update_tax_configuration,-)+from ...shop.utils.preparing_shop import prepare_shop+from ...taxes.utils import update_country_tax_ratesfrom ...utils import assign_permissions-from ...warehouse.utils import create_warehousefrom ..utils import (checkout_billing_address_update,checkout_complete,@@ -23,123 +13,69 @@ from ..utils import ()-def prepare_shop(- e2e_staff_api_client,- shipping_price,-):- warehouse_data = create_warehouse(e2e_staff_api_client)- warehouse_id = warehouse_data["id"]- channel_slug = "channel-cz"- warehouse_ids = [warehouse_id]- channel_data = create_channel(- e2e_staff_api_client,- slug=channel_slug,- warehouse_ids=warehouse_ids,- currency="CZK",- country="CZ",- )- channel_id = channel_data["id"]- channel_ids = [channel_id]- shipping_zone_data = create_shipping_zone(- e2e_staff_api_client,- countries=["CZ", "US"],- 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,- price=shipping_price,- )-- return (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- shipping_price,- )---def prepare_tax_configuration(- e2e_staff_api_client,- channel_slug,- shipping_country_code,- shipping_country_tax_rate,- billing_country_code,- billing_country_tax_rate,- prices_entered_with_tax,-):- tax_config_data = get_tax_configurations(e2e_staff_api_client)- channel_tax_config = tax_config_data[0]["node"]- assert channel_tax_config["channel"]["slug"] == channel_slug- tax_config_id = channel_tax_config["id"]-- tax_config_data = update_tax_configuration(- e2e_staff_api_client,- tax_config_id,- charge_taxes=True,- tax_calculation_strategy="FLAT_RATES",- display_gross_prices=True,- prices_entered_with_tax=prices_entered_with_tax,- )- update_country_tax_rates(- e2e_staff_api_client,- shipping_country_code,- [{"rate": shipping_country_tax_rate}],- )- update_country_tax_rates(- e2e_staff_api_client, billing_country_code, [{"rate": billing_country_tax_rate}]- )-- return billing_country_tax_rate--@pytest.mark.e2edef test_digital_checkout_calculate_simple_tax_based_on_billing_country_CORE_2007(e2e_staff_api_client,e2e_not_logged_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,- permission_manage_taxes,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_taxes,]assign_permissions(e2e_staff_api_client, permissions)- shipping_price = 15- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- shipping_price,- ) = prepare_shop(e2e_staff_api_client, shipping_price)+ tax_settings = {+ "charge_taxes": True,+ "tax_calculation_strategy": "FLAT_RATES",+ "display_gross_prices": False,+ "prices_entered_with_tax": False,+ }- billing_country_tax_rate = prepare_tax_configuration(+ shop_data, _tax_config = prepare_shop(e2e_staff_api_client,- channel_slug,- shipping_country_code="US",- shipping_country_tax_rate=9,- billing_country_code="CZ",- billing_country_tax_rate=21,- prices_entered_with_tax=False,+ channels=[+ {+ "shipping_zones": [+ {+ "countries": ["US"],+ "shipping_methods": [+ {+ "name": "us shipping zone",+ "add_channels": {},+ }+ ],+ },+ {+ "countries": ["CZ"],+ "shipping_methods": [+ {+ "name": "cz shipping zone",+ "add_channels": {},+ }+ ],+ },+ ],+ "order_settings": {},+ },+ ],+ tax_settings=tax_settings,)+ channel_id = shop_data[0]["id"]+ channel_slug = shop_data[0]["slug"]+ warehouse_id = shop_data[0]["warehouse_id"]+ billing_country_code = "CZ"+ billing_tax = 21+ shipping_tax = 9++ update_country_tax_rates(+ e2e_staff_api_client,+ billing_country_code,+ [{"rate": billing_tax}],+ )+variant_price = 88.89_product_id, product_variant_id, product_variant_price = prepare_digital_product(e2e_staff_api_client, channel_id, warehouse_id, variant_price@@ -180,15 +116,22 @@ def test_digital_checkout_calculate_simple_tax_based_on_billing_country_CORE_200# Step 3 - Get checkout and verify taxescheckout_data = get_checkout(e2e_not_logged_api_client, checkout_id)- calculated_tax = round(- (product_variant_price * (billing_country_tax_rate / 100)),+ billing_tax = round(+ (product_variant_price * (billing_tax / 100)),2,)+ shipping_tax = round(+ (product_variant_price * (shipping_tax / 100)),+ 2,+ )+total_gross_amount = checkout_data["totalPrice"]["gross"]["amount"]assert checkout_data["totalPrice"]["net"]["amount"] == product_variant_price- assert checkout_data["totalPrice"]["tax"]["amount"] == calculated_tax- assert total_gross_amount == product_variant_price + calculated_tax+ assert checkout_data["totalPrice"]["tax"]["amount"] == billing_tax+ assert checkout_data["totalPrice"]["tax"]["amount"] != shipping_tax++ assert total_gross_amount == product_variant_price + billing_tax# Step 4 - Create payment for checkout.checkout_dummy_payment_create(@@ -205,7 +148,5 @@ def test_digital_checkout_calculate_simple_tax_based_on_billing_country_CORE_200assert order_data["status"] == "UNFULFILLED"assert order_data["paymentStatus"] == "FULLY_CHARGED"assert order_data["total"]["net"]["amount"] == product_variant_price- assert order_data["total"]["tax"]["amount"] == calculated_tax- assert (- order_data["total"]["gross"]["amount"] == product_variant_price + calculated_tax- )+ assert order_data["total"]["tax"]["amount"] == billing_tax+ assert order_data["total"]["gross"]["amount"] == product_variant_price + billing_taxdiff --git a/saleor/tests/e2e/checkout/taxes/test_checkout_calculate_simple_taxes_product_tax_class.py b/saleor/tests/e2e/checkout/taxes/test_checkout_calculate_simple_taxes_product_tax_class.pyindex 027d133e11..c0216c97fc 100644--- a/saleor/tests/e2e/checkout/taxes/test_checkout_calculate_simple_taxes_product_tax_class.py+++ b/saleor/tests/e2e/checkout/taxes/test_checkout_calculate_simple_taxes_product_tax_class.py@@ -3,12 +3,7 @@ import pytestfrom ...product.utils import update_productfrom ...product.utils.preparing_product import prepare_productfrom ...shop.utils.preparing_shop import prepare_shop-from ...taxes.utils import (- create_tax_class,- get_tax_configurations,- update_country_tax_rates,- update_tax_configuration,-)+from ...taxes.utils import update_country_tax_ratesfrom ...utils import assign_permissionsfrom ..utils import (checkout_complete,@@ -18,88 +13,76 @@ from ..utils import ()-def prepare_tax_configuration(- e2e_staff_api_client,- channel_slug,- country_code,- country_tax_rate,- product_tax_rate,- prices_entered_with_tax,-):- tax_config_data = get_tax_configurations(e2e_staff_api_client)- channel_tax_config = tax_config_data[0]["node"]- assert channel_tax_config["channel"]["slug"] == channel_slug- tax_config_id = channel_tax_config["id"]-- tax_config_data = update_tax_configuration(- e2e_staff_api_client,- tax_config_id,- charge_taxes=True,- tax_calculation_strategy="FLAT_RATES",- display_gross_prices=True,- prices_entered_with_tax=prices_entered_with_tax,- )- update_country_tax_rates(- e2e_staff_api_client,- country_code,- [{"rate": country_tax_rate}],- )-- country_rates = [{"countryCode": country_code, "rate": product_tax_rate}]- tax_class_data = create_tax_class(- e2e_staff_api_client,- "Product tax class",- country_rates,- )- tax_class_id = tax_class_data["id"]-- return country_tax_rate, product_tax_rate, tax_class_id--@pytest.mark.e2edef test_checkout_calculate_simple_tax_based_on_product_tax_class_CORE_2005(e2e_staff_api_client,e2e_not_logged_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,- permission_manage_taxes,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_taxes,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ tax_settings = {+ "charge_taxes": True,+ "tax_calculation_strategy": "FLAT_RATES",+ "display_gross_prices": False,+ "prices_entered_with_tax": True,+ "tax_rates": [+ {+ "type": "product",+ "name": "Product Tax Rate",+ "country_code": "US",+ "rate": 5,+ },+ ],+ }+ shop_data, tax_config = prepare_shop(+ e2e_staff_api_client,+ channels=[+ {+ "shipping_zones": [+ {+ "shipping_methods": [+ {+ "add_channels": {},+ }+ ],+ },+ ],+ "order_settings": {},+ },+ ],+ tax_settings=tax_settings,+ )+ channel_id = shop_data[0]["id"]+ channel_slug = shop_data[0]["slug"]+ shipping_method_id = shop_data[0]["shipping_zones"][0]["shipping_methods"][0]["id"]+ shipping_price = 10.0+ warehouse_id = shop_data[0]["warehouse_id"]+ product_tax_class_id = tax_config[0]["product_tax_class_id"]+ product_tax_rate = tax_config[1]["product"]["rate"]+ country_tax_rate = 23+ country = "US"- country_tax_rate, product_tax_rate, tax_class_id = prepare_tax_configuration(+ update_country_tax_rates(e2e_staff_api_client,- channel_slug,- country_code="US",- country_tax_rate=23,- product_tax_rate=5,- prices_entered_with_tax=True,+ country,+ [{"rate": country_tax_rate}],)- variant_price = "25.55"+ variant_price = float("25.55")(product_id, product_variant_id, product_variant_price) = prepare_product(e2e_staff_api_client,warehouse_id,channel_id,variant_price,)- product_tax_class = {"taxClass": tax_class_id}+ product_tax_class = {"taxClass": product_tax_class_id}update_product(e2e_staff_api_client, product_id, input=product_tax_class)# Step 1 - Create checkout and check prices@@ -119,7 +102,6 @@ def test_checkout_calculate_simple_tax_based_on_product_tax_class_CORE_2005(set_default_shipping_address=True,)checkout_id = checkout_data["id"]-assert checkout_data["isShippingRequired"] is Trueproduct_variant_price = float(product_variant_price)assert checkout_data["totalPrice"]["gross"]["amount"] == product_variant_price@@ -128,10 +110,10 @@ def test_checkout_calculate_simple_tax_based_on_product_tax_class_CORE_2005(2,)assert checkout_data["totalPrice"]["tax"]["amount"] == calculated_tax+assert checkout_data["totalPrice"]["net"]["amount"] == round(product_variant_price - calculated_tax, 2)- shipping_method_id = checkout_data["shippingMethods"][0]["id"]# Step 2 - Set DeliveryMethod for checkout and check pricescheckout_data = checkout_delivery_method_update(@@ -139,6 +121,7 @@ def test_checkout_calculate_simple_tax_based_on_product_tax_class_CORE_2005(checkout_id,shipping_method_id,)+shipping_price = checkout_data["deliveryMethod"]["price"]["amount"]shipping_price = float(shipping_price)assert checkout_data["deliveryMethod"]["id"] == shipping_method_iddiff --git a/saleor/tests/e2e/checkout/taxes/test_checkout_calculate_simple_taxes_product_type_tax_class.py b/saleor/tests/e2e/checkout/taxes/test_checkout_calculate_simple_taxes_product_type_tax_class.pyindex 23ccf0db5b..892fcd5e45 100644--- a/saleor/tests/e2e/checkout/taxes/test_checkout_calculate_simple_taxes_product_type_tax_class.py+++ b/saleor/tests/e2e/checkout/taxes/test_checkout_calculate_simple_taxes_product_type_tax_class.py@@ -10,12 +10,7 @@ from ...product.utils import (update_product_type,)from ...shop.utils.preparing_shop import prepare_shop-from ...taxes.utils import (- create_tax_class,- get_tax_configurations,- update_country_tax_rates,- update_tax_configuration,-)+from ...taxes.utils import update_country_tax_ratesfrom ...utils import assign_permissionsfrom ..utils import (checkout_complete,@@ -25,44 +20,6 @@ from ..utils import ()-def prepare_tax_configuration(- e2e_staff_api_client,- channel_slug,- country_code,- country_tax_rate,- product_type_tax_rate,- prices_entered_with_tax,-):- tax_config_data = get_tax_configurations(e2e_staff_api_client)- channel_tax_config = tax_config_data[0]["node"]- assert channel_tax_config["channel"]["slug"] == channel_slug- tax_config_id = channel_tax_config["id"]-- tax_config_data = update_tax_configuration(- e2e_staff_api_client,- tax_config_id,- charge_taxes=True,- tax_calculation_strategy="FLAT_RATES",- display_gross_prices=True,- prices_entered_with_tax=prices_entered_with_tax,- )- update_country_tax_rates(- e2e_staff_api_client,- country_code,- [{"rate": country_tax_rate}],- )-- country_rates = [{"countryCode": country_code, "rate": product_type_tax_rate}]- tax_class_data = create_tax_class(- e2e_staff_api_client,- "Product type tax class",- country_rates,- )- tax_class_id = tax_class_data["id"]-- return country_tax_rate, product_type_tax_rate, tax_class_id--def prepare_product(e2e_staff_api_client,warehouse_id,@@ -120,46 +77,72 @@ def prepare_product(def test_checkout_calculate_simple_tax_based_on_product_type_tax_class_CORE_2003(e2e_staff_api_client,e2e_not_logged_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,- permission_manage_taxes,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_taxes,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ tax_settings = {+ "charge_taxes": True,+ "tax_calculation_strategy": "FLAT_RATES",+ "display_gross_prices": False,+ "prices_entered_with_tax": False,+ "tax_rates": [+ {+ "type": "product_type",+ "name": "Product Type Tax Rate",+ "country_code": "US",+ "rate": 8,+ },+ ],+ }+ shop_data, tax_config = prepare_shop(+ e2e_staff_api_client,+ channels=[+ {+ "shipping_zones": [+ {+ "shipping_methods": [+ {+ "add_channels": {},+ }+ ],+ },+ ],+ "order_settings": {},+ },+ ],+ tax_settings=tax_settings,+ )+ channel_id = shop_data[0]["id"]+ channel_slug = shop_data[0]["slug"]+ shipping_method_id = shop_data[0]["shipping_zones"][0]["shipping_methods"][0]["id"]+ shipping_price = 10.0+ warehouse_id = shop_data[0]["warehouse_id"]+ product_type_tax_class_id = tax_config[0]["product_type_tax_class_id"]+ product_type_tax_rate = tax_config[1]["product_type"]["rate"]+ country = "US"+ country_tax_rate = 10- country_tax_rate, product_type_tax_rate, tax_class_id = prepare_tax_configuration(+ update_country_tax_rates(e2e_staff_api_client,- channel_slug,- country_code="US",- country_tax_rate=10,- product_type_tax_rate=8,- prices_entered_with_tax=False,+ country,+ [{"rate": country_tax_rate}],)variant_price = "155.88"- (product_variant_id, product_variant_price, product_type_id) = prepare_product(+ (product_variant_id, _product_variant_price, product_type_id) = prepare_product(e2e_staff_api_client,warehouse_id,channel_id,variant_price,)- product_type_tax_class = {"taxClass": tax_class_id}+ product_type_tax_class = {"taxClass": product_type_tax_class_id}update_product_type(e2e_staff_api_client, product_type_id, product_type_tax_class)# Step 1 - Create checkout and check prices@@ -188,14 +171,13 @@ def test_checkout_calculate_simple_tax_based_on_product_type_tax_class_CORE_2003assert checkout_data["totalPrice"]["gross"]["amount"] == round(variant_price + calculated_tax, 2)- shipping_method_id = checkout_data["shippingMethods"][0]["id"]-# Step 2 - Set DeliveryMethod for checkout and check pricescheckout_data = checkout_delivery_method_update(e2e_not_logged_api_client,checkout_id,shipping_method_id,)+shipping_price = checkout_data["deliveryMethod"]["price"]["amount"]assert checkout_data["deliveryMethod"]["id"] == shipping_method_idassert checkout_data["shippingPrice"]["net"]["amount"] == float(shipping_price)diff --git a/saleor/tests/e2e/checkout/test_buy_gift_card_in_the_checkout.py b/saleor/tests/e2e/checkout/test_buy_gift_card_in_the_checkout.pyindex 5a27138091..25967eb4bc 100644--- a/saleor/tests/e2e/checkout/test_buy_gift_card_in_the_checkout.py+++ b/saleor/tests/e2e/checkout/test_buy_gift_card_in_the_checkout.py@@ -1,7 +1,6 @@import pytestfrom ..account.utils import get_own_data-from ..channel.utils.channel_update import update_channelfrom ..gift_cards.utils import get_gift_cardsfrom ..orders.utils import order_queryfrom ..product.utils import (@@ -12,7 +11,6 @@ from ..product.utils import (create_product_variant,create_product_variant_channel_listing,)-from ..shop.utils import update_shop_settingsfrom ..shop.utils.preparing_shop import prepare_shopfrom ..utils import assign_permissionsfrom .utils import (@@ -80,47 +78,47 @@ def test_buy_gift_card_in_the_checkout_CORE_1102(e2e_logged_api_client,e2e_staff_api_client,permission_manage_product_types_and_attributes,- permission_manage_channels,- permission_manage_products,- permission_manage_shipping,permission_manage_gift_card,permission_manage_orders,- permission_manage_settings,permission_manage_plugins,+ shop_permissions,):# Beforepermissions = [permission_manage_product_types_and_attributes,- permission_manage_channels,- permission_manage_products,- permission_manage_shipping,+ *shop_permissions,permission_manage_gift_card,permission_manage_orders,- permission_manage_settings,permission_manage_plugins,]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, _product_variant_price, product_id = prepare_product_gift_card(+ shop_data, _tax_config = prepare_shop(+ e2e_staff_api_client,+ channels=[+ {+ "shipping_zones": [+ {+ "shipping_methods": [{}],+ },+ ],+ "order_settings": {"automaticallyFulfillNonShippableGiftCard": True},+ }+ ],+ shop_settings={+ "fulfillmentAutoApprove": True,+ "fulfillmentAllowUnpaid": True,+ },+ )+ channel_id = shop_data[0]["id"]+ channel_slug = shop_data[0]["slug"]+ warehouse_id = shop_data[0]["warehouse_id"]++ product_variant_id, _product_variant_price, _product_id = prepare_product_gift_card(e2e_staff_api_client,warehouse_id,channel_id,)- channel_input = {- "orderSettings": {"automaticallyFulfillNonShippableGiftCard": True}- }- update_channel(e2e_staff_api_client, channel_id, channel_input)- shop_settings_input = {- "fulfillmentAutoApprove": True,- "fulfillmentAllowUnpaid": True,- }- update_shop_settings(e2e_staff_api_client, shop_settings_input)# Step 1 - Create checkout.lines = [diff --git a/saleor/tests/e2e/checkout/test_checkout_add_gift_card_before_email.py b/saleor/tests/e2e/checkout/test_checkout_add_gift_card_before_email.pyindex 70dda20d0c..53a3172c59 100644--- a/saleor/tests/e2e/checkout/test_checkout_add_gift_card_before_email.py+++ b/saleor/tests/e2e/checkout/test_checkout_add_gift_card_before_email.py@@ -2,7 +2,7 @@ import pytestfrom ..gift_cards.utils import create_gift_cardfrom ..product.utils.preparing_product import prepare_product-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import (checkout_add_promo_code,@@ -18,29 +18,23 @@ from .utils import (def test_add_gift_card_before_email_in_checkout_core_1104(e2e_not_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_gift_card,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_gift_card,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)-+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](_product_id,product_variant_id,@@ -72,7 +66,6 @@ def test_add_gift_card_before_email_in_checkout_core_1104(set_default_shipping_address=True,)checkout_id = checkout_data["id"]- shipping_method_id = checkout_data["shippingMethods"][0]["id"]calculated_subtotal = product_variant_price * 3assert checkout_data["isShippingRequired"] is Trueassert checkout_data["totalPrice"]["gross"]["amount"] == calculated_subtotaldiff --git a/saleor/tests/e2e/checkout/test_checkout_create_from_order.py b/saleor/tests/e2e/checkout/test_checkout_create_from_order.pyindex 4ff0719717..160b3e1c16 100644--- a/saleor/tests/e2e/checkout/test_checkout_create_from_order.py+++ b/saleor/tests/e2e/checkout/test_checkout_create_from_order.py@@ -2,7 +2,7 @@ import pytestfrom ..orders.utils import draft_order_create, order_lines_createfrom ..product.utils.preparing_product import prepare_product-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import checkout_create_from_order@@ -10,18 +10,14 @@ from .utils import checkout_create_from_order@pytest.mark.e2edef 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,+ shop_permissions,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_orders,permission_manage_checkouts,@@ -30,12 +26,9 @@ def test_checkout_create_from_order_core_0104(price = 10- (- warehouse_id,- channel_id,- _channel_slug,- _shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ warehouse_id = shop_data["warehouse"]["id"](_product_id,@@ -48,7 +41,7 @@ def test_checkout_create_from_order_core_0104(price,)- # Step 1 - Create checkout from order+ # Step 1 - Create orderchannel_id = {"channelId": channel_id}data = draft_order_create(e2e_staff_api_client,@@ -72,6 +65,7 @@ def test_checkout_create_from_order_core_0104(order_product_variant_id = order_data["order"]["lines"][0]["variant"]order_product_quantity = order_data["order"]["lines"][0]["quantity"]+ # Step 2 - Create checkout from ordercheckout_data = checkout_create_from_order(e2e_staff_api_client,order_id,diff --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 6e15d74f1e..55285f6ab2 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,8 @@import pytest-from ..channel.utils import create_channelfrom ..product.utils.preparing_product import prepare_product-from ..shipping_zone.utils import (- create_shipping_method,- create_shipping_method_channel_listing,- create_shipping_zone,-)+from ..shop.utils import prepare_shopfrom ..utils import assign_permissions-from ..warehouse.utils import create_warehousefrom .utils import (checkout_create,checkout_delivery_method_update,@@ -16,77 +10,46 @@ from .utils import ()-def create_shop_for_orders_without_payments(- e2e_staff_api_client,-):- channel_slug = "test-test"-- 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,- allow_unpaid_orders=True,- automatically_confirm_all_new_orders=True,- )- 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 (- channel_slug,- warehouse_id,- channel_id,- shipping_method_id,- )--@pytest.mark.e2edef test_should_be_able_to_create_order_with_no_payment_CORE_0111(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,+ shop_permissions,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_orders,permission_manage_checkouts,]assign_permissions(e2e_staff_api_client, permissions)- (- channel_slug,- warehouse_id,- channel_id,- shipping_method_id,- ) = create_shop_for_orders_without_payments(e2e_staff_api_client)++ shop_data, _tax_config = prepare_shop(+ e2e_staff_api_client,+ channels=[+ {+ "shipping_zones": [+ {+ "shipping_methods": [{}],+ },+ ],+ "order_settings": {+ "allowUnpaidOrders": True,+ },+ }+ ],+ shop_settings={+ "fulfillmentAutoApprove": True,+ "fulfillmentAllowUnpaid": True,+ },+ )+ channel_id = shop_data[0]["id"]+ channel_slug = shop_data[0]["slug"]+ warehouse_id = shop_data[0]["warehouse_id"]+ shipping_method_id = shop_data[0]["shipping_zones"][0]["shipping_methods"][0]["id"]variant_price = 10@@ -120,7 +83,6 @@ def test_should_be_able_to_create_order_with_no_payment_CORE_0111(assert checkout_data["isShippingRequired"] is Trueassert checkout_data["deliveryMethod"] is Noneassert checkout_data["shippingMethod"] is None- shipping_method_id = checkout_data["shippingMethods"][0]["id"]# Step 2 - Set shipping address and DeliveryMethod for checkoutcheckout_data = checkout_delivery_method_update(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 f2f4e4348e..3e48276192 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,15 +1,9 @@import pytest-from ..channel.utils import create_channelfrom ..product.utils.preparing_product import prepare_product-from ..shipping_zone.utils import (- create_shipping_method,- create_shipping_method_channel_listing,- create_shipping_zone,-)+from ..shop.utils import prepare_shopfrom ..transactions.utils import create_transactionfrom ..utils import assign_permissions-from ..warehouse.utils import create_warehousefrom .utils import (checkout_create,checkout_delivery_method_update,@@ -17,81 +11,51 @@ from .utils import ()-def create_shop_for_orders_without_payments(- e2e_staff_api_client,-):- channel_slug = "test-test"-- 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,- allow_unpaid_orders=True,- automatically_confirm_all_new_orders=True,- )- 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 (- channel_slug,- warehouse_id,- channel_id,- shipping_method_id,- )--@pytest.mark.e2edef test_should_be_able_to_create_partially_paid_order_core_0112(e2e_staff_api_client,e2e_not_logged_api_client,e2e_app_api_client,- permission_manage_products,- permission_manage_channels,permission_manage_product_types_and_attributes,- permission_manage_shipping,+ shop_permissions,permission_manage_orders,permission_manage_checkouts,permission_manage_payments,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_orders,permission_manage_checkouts,permission_manage_payments,]assign_permissions(e2e_staff_api_client, permissions)- (- channel_slug,- warehouse_id,- channel_id,- shipping_method_id,- ) = create_shop_for_orders_without_payments(e2e_staff_api_client)++ shop_data, _tax_config = prepare_shop(+ e2e_staff_api_client,+ channels=[+ {+ "shipping_zones": [+ {+ "shipping_methods": [{}],+ },+ ],+ "order_settings": {+ "allowUnpaidOrders": True,+ },+ }+ ],+ shop_settings={+ "fulfillmentAutoApprove": True,+ "fulfillmentAllowUnpaid": True,+ },+ )+ channel_id = shop_data[0]["id"]+ channel_slug = shop_data[0]["slug"]+ warehouse_id = shop_data[0]["warehouse_id"]+ shipping_method_id = shop_data[0]["shipping_zones"][0]["shipping_methods"][0]["id"]+app_permissions = [permission_manage_payments]assign_permissions(e2e_app_api_client, app_permissions)@@ -129,7 +93,6 @@ def test_should_be_able_to_create_partially_paid_order_core_0112(assert checkout_data["isShippingRequired"] is Trueassert checkout_data["deliveryMethod"] is Noneassert checkout_data["shippingMethod"] is None- shipping_method_id = checkout_data["shippingMethods"][0]["id"]# Step 2 - Set shipping address and DeliveryMethod for checkoutcheckout_data = checkout_delivery_method_update(diff --git a/saleor/tests/e2e/checkout/test_checkout_should_be_able_to_remove_shipping_method.py b/saleor/tests/e2e/checkout/test_checkout_should_be_able_to_remove_shipping_method.pyindex cc7e6fbb5b..411aad183c 100644--- a/saleor/tests/e2e/checkout/test_checkout_should_be_able_to_remove_shipping_method.py+++ b/saleor/tests/e2e/checkout/test_checkout_should_be_able_to_remove_shipping_method.py@@ -1,7 +1,7 @@import pytestfrom ..product.utils.preparing_product import prepare_product-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import checkout_create, checkout_delivery_method_update@@ -10,30 +10,25 @@ from .utils import checkout_create, checkout_delivery_method_updatedef test_checkout_should_be_able_to_remove_shipping_method_CORE_0115(e2e_staff_api_client,e2e_not_logged_api_client,- permission_manage_products,- permission_manage_channels,permission_manage_product_types_and_attributes,- permission_manage_shipping,+ shop_permissions,permission_manage_orders,permission_manage_checkouts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_orders,permission_manage_checkouts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"]variant_price = 10@@ -65,7 +60,6 @@ def test_checkout_should_be_able_to_remove_shipping_method_CORE_0115()checkout_id = checkout_data["id"]assert checkout_data["shippingMethods"] != []- shipping_method_id = checkout_data["shippingMethods"][0]["id"]assert checkout_data["isShippingRequired"] is Trueassert checkout_data["deliveryMethod"] is Nonetotal_gross_amount = checkout_data["totalPrice"]["gross"]["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.pyindex c36b2120c8..9af19106cb 100644--- 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.py@@ -1,7 +1,7 @@import pytestfrom ..product.utils.preparing_product import prepare_product-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import (checkout_create,@@ -14,26 +14,22 @@ from .utils import (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,+ shop_permissions,permission_manage_product_types_and_attributes,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,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)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"]+variant_price = 10(@@ -67,7 +63,6 @@ def test_should_not_be_able_to_make_purchase_with_no_payment_CORE_0113(assert checkout_data["isShippingRequired"] is Trueassert checkout_data["deliveryMethod"] is Noneassert checkout_data["shippingMethod"] is None- shipping_method_id = checkout_data["shippingMethods"][0]["id"]# Step 2 - Set shipping address and DeliveryMethod for checkoutdiff --git a/saleor/tests/e2e/checkout/test_checkout_use_multiple_gift_cards.py b/saleor/tests/e2e/checkout/test_checkout_use_multiple_gift_cards.pyindex 1cd780937f..3348bf22c1 100644--- a/saleor/tests/e2e/checkout/test_checkout_use_multiple_gift_cards.py+++ b/saleor/tests/e2e/checkout/test_checkout_use_multiple_gift_cards.py@@ -2,7 +2,7 @@ import pytestfrom ..gift_cards.utils import bulk_create_gift_cardfrom ..product.utils.preparing_product import prepare_product-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import (checkout_add_promo_code,@@ -40,28 +40,23 @@ def prepare_gift_cards(def test_use_multiple_gift_cards_in_checkout_core_1105(e2e_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_gift_card,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_gift_card,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](_product_id,@@ -98,7 +93,6 @@ def test_use_multiple_gift_cards_in_checkout_core_1105(set_default_shipping_address=True,)checkout_id = checkout_data["id"]- shipping_method_id = checkout_data["shippingMethods"][0]["id"]assert checkout_data["isShippingRequired"] is Truecalculated_subtotal = product_variant_price * 4assert checkout_data["totalPrice"]["gross"]["amount"] == calculated_subtotaldiff --git a/saleor/tests/e2e/checkout/test_checkout_with_shipping_method_with_min_order_value.py b/saleor/tests/e2e/checkout/test_checkout_with_shipping_method_with_min_order_value.pyindex 8edf1d8b56..c67919478e 100644--- a/saleor/tests/e2e/checkout/test_checkout_with_shipping_method_with_min_order_value.py+++ b/saleor/tests/e2e/checkout/test_checkout_with_shipping_method_with_min_order_value.py@@ -1,89 +1,51 @@-import base64-import pytest-from ..channel.utils import create_channelfrom ..product.utils import (create_product_variant,create_product_variant_channel_listing,)from ..product.utils.preparing_product import prepare_product-from ..shipping_zone.utils import (- create_shipping_method,- create_shipping_method_channel_listing,- create_shipping_zone,-)+from ..shop.utils import prepare_shopfrom ..utils import assign_permissions-from ..warehouse.utils import create_warehousefrom .utils import checkout_create, checkout_delivery_method_update-# Please note: decoding won't be necessary once-# https://github.com/saleor/saleor/issues/13675 is fixed-def decode_base64_and_get_last_3_chars(encoded_string):- base64_bytes = encoded_string.encode("ascii")- decoded_bytes = base64.b64decode(base64_bytes)- decoded_string = decoded_bytes.decode("ascii")- return decoded_string[-2:]---def prepare_shop_with_shipping_method_with_min_order_value(- 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"]-- return (- warehouse_id,- channel_id,- channel_slug,- shipping_zone_id,- )--@pytest.mark.e2edef test_checkout_with_shipping_method_with_min_order_value_CORE_0501(e2e_not_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,permission_manage_checkouts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,+ *shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,permission_manage_checkouts,]-assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_zone_id,- ) = prepare_shop_with_shipping_method_with_min_order_value(++ shop_data, _tax_config = prepare_shop(e2e_staff_api_client,+ channels=[+ {+ "shipping_zones": [+ {+ "shipping_methods": [+ {"add_channels": {"minimum_order_price": 20.0}}+ ],+ },+ ],+ "order_settings": {},+ }+ ],+ shop_settings={},)+ channel_id = shop_data[0]["id"]+ channel_slug = shop_data[0]["slug"]+ warehouse_id = shop_data[0]["warehouse_id"]+ shipping_method_id = shop_data[0]["shipping_zones"][0]["shipping_methods"][0]["id"]first_variant_price = 25@@ -118,25 +80,7 @@ def test_checkout_with_shipping_method_with_min_order_value_CORE_0501(second_variant_price,)- # Step 1 - Create shipping method with minimal order value- minimum_order_price = 20.0- shipping_method_data = create_shipping_method(- e2e_staff_api_client, shipping_zone_id- )- shipping_method_id = shipping_method_data["id"]- data = create_shipping_method_channel_listing(- e2e_staff_api_client,- shipping_method_id,- channel_id,- price="5.00",- minimumOrderPrice=minimum_order_price,- )- shipping_method_min_order_value = data["channelListings"][0]["minimumOrderPrice"][- "amount"- ]- assert shipping_method_min_order_value == minimum_order_price-- # Step 2 - Create checkout with the first product variant+ # Step 1 - Create checkout with the first product variantlines = [{"variantId": first_product_variant_id,@@ -155,11 +99,7 @@ def test_checkout_with_shipping_method_with_min_order_value_CORE_0501(assert checkout_data["isShippingRequired"] is Truecheckout_shipping_method = checkout_data["shippingMethods"][0]["id"]- decoded_checkout_shipping_method = decode_base64_and_get_last_3_chars(- checkout_shipping_method- )- decoded_shipping_method = decode_base64_and_get_last_3_chars(shipping_method_id)- assert decoded_checkout_shipping_method == decoded_shipping_method+ assert checkout_shipping_method == shipping_method_id# Step 2 - Set DeliveryMethod for the checkout with the first product variantcheckout_data = checkout_delivery_method_update(diff --git a/saleor/tests/e2e/checkout/test_guest_checkout_should_be_assigned_to_user_after_creating_the_account.py b/saleor/tests/e2e/checkout/test_guest_checkout_should_be_assigned_to_user_after_creating_the_account.pyindex f77f1135c1..1aaab5b3c1 100644--- a/saleor/tests/e2e/checkout/test_guest_checkout_should_be_assigned_to_user_after_creating_the_account.py+++ b/saleor/tests/e2e/checkout/test_guest_checkout_should_be_assigned_to_user_after_creating_the_account.py@@ -2,7 +2,6 @@ import pytestfrom ..account.utils import account_registerfrom ..product.utils.preparing_product import prepare_product-from ..shop.utils import update_shop_settingsfrom ..shop.utils.preparing_shop import prepare_shopfrom ..users.utils import customer_update, get_userfrom ..utils import assign_permissions@@ -19,26 +18,20 @@ def test_guest_checkout_should_be_assigned_to_user_after_creating_the_account_COe2e_staff_api_client,app_api_client,e2e_not_logged_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,permission_manage_product_types_and_attributes,permission_manage_orders,permission_manage_checkouts,permission_manage_users,- permission_manage_settings,permission_manage_payments,+ shop_permissions,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_orders,permission_manage_checkouts,permission_manage_users,- permission_manage_settings,permission_manage_payments,]assign_permissions(@@ -51,17 +44,26 @@ def test_guest_checkout_should_be_assigned_to_user_after_creating_the_account_CO)assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)-- input_data = {- "enableAccountConfirmationByEmail": False,- }- update_shop_settings(e2e_staff_api_client, input_data)+ shop_data, _tax_config = prepare_shop(+ e2e_staff_api_client,+ channels=[+ {+ "shipping_zones": [+ {+ "shipping_methods": [{}],+ },+ ],+ "order_settings": {},+ }+ ],+ shop_settings={+ "enableAccountConfirmationByEmail": False,+ },+ )+ channel_id = shop_data[0]["id"]+ channel_slug = shop_data[0]["slug"]+ warehouse_id = shop_data[0]["warehouse_id"]+ shipping_method_id = shop_data[0]["shipping_zones"][0]["shipping_methods"][0]["id"]variant_price = 10@@ -95,7 +97,6 @@ def test_guest_checkout_should_be_assigned_to_user_after_creating_the_account_COcheckout_id = checkout_data["id"]assert checkout_data["isShippingRequired"] is True- shipping_method_id = checkout_data["shippingMethods"][0]["id"]assert checkout_data["deliveryMethod"] is None# Step 2 - Set DeliveryMethod for checkoutdiff --git a/saleor/tests/e2e/checkout/test_guest_checkout_should_be_associated_with_user_account.py b/saleor/tests/e2e/checkout/test_guest_checkout_should_be_associated_with_user_account.pyindex da1be0ffef..2fd64d7f4f 100644--- a/saleor/tests/e2e/checkout/test_guest_checkout_should_be_associated_with_user_account.py+++ b/saleor/tests/e2e/checkout/test_guest_checkout_should_be_associated_with_user_account.py@@ -1,7 +1,7 @@import pytestfrom ..product.utils.preparing_product import prepare_product-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..users.utils import create_customer, get_userfrom ..utils import assign_permissionsfrom .utils import (@@ -31,34 +31,27 @@ def create_active_customer(def test_guest_checkout_should_be_associated_with_user_account_CORE_1517(e2e_staff_api_client,e2e_not_logged_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,permission_manage_product_types_and_attributes,permission_manage_orders,permission_manage_checkouts,permission_manage_users,- permission_manage_settings,+ shop_permissions,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,permission_manage_product_types_and_attributes,permission_manage_orders,permission_manage_checkouts,permission_manage_users,- permission_manage_settings,+ *shop_permissions,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"]variant_price = 10@@ -93,7 +86,6 @@ def test_guest_checkout_should_be_associated_with_user_account_CORE_1517(checkout_id = checkout_data["id"]assert checkout_data["isShippingRequired"] is True- shipping_method_id = checkout_data["shippingMethods"][0]["id"]assert checkout_data["deliveryMethod"] is None# Step 2 - Set DeliveryMethod for checkoutdiff --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 879d0ff8f8..c285e9dadb 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@@ -8,18 +8,16 @@ from ..product.utils import (create_product_variant,create_product_variant_channel_listing,)-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import checkout_create, checkout_lines_updatedef prepare_product_with_limit(e2e_staff_api_client):- (- warehouse_id,- channel_id,- channel_slug,- _shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]product_type_data = create_product_type(e2e_staff_api_client,@@ -79,16 +77,12 @@ def prepare_product_with_limit(e2e_staff_api_client):def test_checkout_with_product_quantity_exceeding_the_limit_per_customer_core_0110(e2e_staff_api_client,e2e_logged_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,]assign_permissions(e2e_staff_api_client, permissions)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 bf88608a48..9c8832637f 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,7 +1,7 @@import pytestfrom ..product.utils.preparing_product import prepare_product-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import (checkout_complete,@@ -15,30 +15,26 @@ from .utils import (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_product_types_and_attributes,- permission_manage_shipping,permission_manage_orders,permission_manage_checkouts,+ shop_permissions,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_orders,permission_manage_checkouts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)++ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"]variant_price = 10@@ -72,7 +68,6 @@ def test_process_checkout_with_physical_product_CORE_0103(assert checkout_data["user"]["email"] == expected_emailassert checkout_data["isShippingRequired"] is Trueassert checkout_data["shippingMethods"] != []- shipping_method_id = checkout_data["shippingMethods"][0]["id"]# Step 3 - Set DeliveryMethod for checkout.checkout_data = checkout_delivery_method_update(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 9cb6b2df8e..33554cdf31 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@@ -8,7 +8,7 @@ from ..product.utils import (create_product_variant_channel_listing,raw_create_product_channel_listing,)-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import raw_checkout_create@@ -16,12 +16,10 @@ from .utils import raw_checkout_createdef prepare_unavailable_product(e2e_staff_api_client,):- (- warehouse_id,- channel_id,- channel_slug,- _shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]product_type_data = create_product_type(e2e_staff_api_client,@@ -79,17 +77,13 @@ def prepare_unavailable_product(def test_should_not_be_able_to_buy_unavailable_product_core_0108(e2e_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,permission_manage_product_types_and_attributes,- permission_manage_shipping,+ shop_permissions,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,+ *shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,]assign_permissions(e2e_staff_api_client, permissions)diff --git a/saleor/tests/e2e/checkout/test_pay_for_part_of_checkout_with_gift_card.py b/saleor/tests/e2e/checkout/test_pay_for_part_of_checkout_with_gift_card.pyindex e838ce57cd..750d024347 100644--- a/saleor/tests/e2e/checkout/test_pay_for_part_of_checkout_with_gift_card.py+++ b/saleor/tests/e2e/checkout/test_pay_for_part_of_checkout_with_gift_card.py@@ -2,7 +2,7 @@ import pytestfrom ..gift_cards.utils import create_gift_cardfrom ..product.utils.preparing_product import prepare_product-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import (checkout_add_promo_code,@@ -17,28 +17,23 @@ from .utils import (def test_gift_card_partial_payment_for_checkout_core_1103(e2e_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_gift_card,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_gift_card,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](_product_id,@@ -73,7 +68,6 @@ def test_gift_card_partial_payment_for_checkout_core_1103(set_default_shipping_address=True,)checkout_id = checkout_data["id"]- shipping_method_id = checkout_data["shippingMethods"][0]["id"]assert checkout_data["isShippingRequired"] is Truecalculated_subtotal = float(product_variant_price * 4)assert checkout_data["totalPrice"]["gross"]["amount"] == calculated_subtotaldiff --git a/saleor/tests/e2e/checkout/test_pay_for_total_checkout_with_gift_card.py b/saleor/tests/e2e/checkout/test_pay_for_total_checkout_with_gift_card.pyindex 3dce4702fb..0475aa0703 100644--- a/saleor/tests/e2e/checkout/test_pay_for_total_checkout_with_gift_card.py+++ b/saleor/tests/e2e/checkout/test_pay_for_total_checkout_with_gift_card.py@@ -2,7 +2,7 @@ import pytestfrom ..gift_cards.utils import create_gift_cardfrom ..product.utils.preparing_product import prepare_product-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import (checkout_add_promo_code,@@ -17,28 +17,23 @@ from .utils import (def test_gift_card_total_payment_for_checkout_core_1101(e2e_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_gift_card,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_gift_card,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](_product_id,@@ -70,7 +65,6 @@ def test_gift_card_total_payment_for_checkout_core_1101(set_default_shipping_address=True,)checkout_id = checkout_data["id"]- shipping_method_id = checkout_data["shippingMethods"][0]["id"]assert checkout_data["isShippingRequired"] is Trueassert checkout_data["totalPrice"]["gross"]["amount"] == float(product_variant_price * 3diff --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 0d0496d461..64d2a9390d 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@@ -8,7 +8,7 @@ from ..product.utils import (create_product_variant_channel_listing,raw_create_product_channel_listing,)-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import raw_checkout_create@@ -16,12 +16,10 @@ from .utils import raw_checkout_createdef prepare_unpublished_product(e2e_staff_api_client,):- (- warehouse_id,- channel_id,- channel_slug,- _shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]product_type_data = create_product_type(e2e_staff_api_client,@@ -73,17 +71,13 @@ def prepare_unpublished_product(def test_unlogged_customer_is_unable_to_buy_unpublished_product_core_0109(e2e_staff_api_client,e2e_not_logged_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,+ *shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,]assign_permissions(e2e_staff_api_client, permissions)(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 c46b81d9c1..4ffc59377e 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,9 +1,9 @@import pytest-from ..channel.utils import create_channelfrom ..product.utils.preparing_product import prepare_product+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissions-from ..warehouse.utils import create_warehouse, update_warehouse+from ..warehouse.utils import update_warehousefrom .utils import (checkout_complete,checkout_create,@@ -12,51 +12,31 @@ from .utils import ()-def prepare_shop_click_and_collect(- e2e_staff_api_client,-):- warehouse_data = create_warehouse(e2e_staff_api_client)- warehouse_id = warehouse_data["id"]- update_warehouse(- e2e_staff_api_client,- warehouse_data["id"],- is_private=False,- click_and_collect_option="LOCAL",- )- channel_data = create_channel(- e2e_staff_api_client,- warehouse_data["id"],- )- channel_id = channel_data["id"]- channel_slug = channel_data["slug"]-- return channel_id, channel_slug, warehouse_id--@pytest.mark.e2edef test_unlogged_customer_buy_by_click_and_collect_CORE_0105(e2e_not_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,permission_manage_product_types_and_attributes,+ shop_permissions,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,permission_manage_product_types_and_attributes,+ *shop_permissions,]assign_permissions(e2e_staff_api_client, permissions)- (- channel_id,- channel_slug,- warehouse_id,- ) = prepare_shop_click_and_collect(++ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ update_warehouse(e2e_staff_api_client,+ warehouse_id,+ is_private=False,+ click_and_collect_option="LOCAL",)-variant_price = 10(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 04eff3cc26..7c57623e31 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@@ -9,7 +9,7 @@ from ..product.utils import (create_product_variant,create_product_variant_channel_listing,)-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import (checkout_billing_address_update,@@ -22,12 +22,10 @@ from .utils import (def prepare_product(e2e_staff_api_client,):- (- warehouse_id,- channel_id,- channel_slug,- _shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]product_type_data = create_product_type(e2e_staff_api_client,@@ -78,16 +76,12 @@ 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,+ shop_permissions,):# Beforepermissions = [permission_manage_product_types_and_attributes,- permission_manage_channels,- permission_manage_products,- permission_manage_shipping,+ *shop_permissions,]assign_permissions(e2e_staff_api_client, permissions)product_variant_id, channel_slug = prepare_product(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 b3404a445c..cc6b53fb1d 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,7 +1,7 @@import pytestfrom ..product.utils.preparing_product import prepare_product-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import (checkout_complete,@@ -16,30 +16,26 @@ from .utils import (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_product_types_and_attributes,- permission_manage_shipping,permission_manage_orders,permission_manage_checkouts,+ shop_permissions,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,permission_manage_product_types_and_attributes,permission_manage_orders,permission_manage_checkouts,+ *shop_permissions,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)++ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"]variant_price = 10@@ -81,7 +77,6 @@ def test_process_checkout_with_physical_product_CORE_0102(checkout_id,)assert len(checkout_data["shippingMethods"]) == 1- shipping_method_id = checkout_data["shippingMethods"][0]["id"]# Step 3 - Set DeliveryMethod for checkout.checkout_data = checkout_delivery_method_update(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 43fab3ba6f..fb74b12f23 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,68 +1,43 @@import pytest-from ..channel.utils import create_channelfrom ..product.utils.preparing_product import prepare_product-from ..shipping_zone.utils import create_shipping_zone+from ..shop.utils import prepare_shopfrom ..utils import assign_permissions-from ..warehouse.utils import create_warehouse, update_warehousefrom .utils import checkout_create, raw_checkout_dummy_payment_create-def prepare_shop_with_no_shipping_method(- e2e_staff_api_client,-):- warehouse_data = create_warehouse(e2e_staff_api_client)- warehouse_id = warehouse_data["id"]- warehouse_ids = [warehouse_id]-- update_warehouse(- e2e_staff_api_client,- warehouse_data["id"],- )-- channel_data = create_channel(- e2e_staff_api_client,- slug="test___0e00",- warehouse_ids=warehouse_ids,- )- channel_id = channel_data["id"]- channel_ids = [channel_id]- channel_slug = channel_data["slug"]-- create_shipping_zone(- e2e_staff_api_client,- warehouse_ids=warehouse_ids,- channel_ids=channel_ids,- )-- return channel_id, channel_slug, warehouse_id--@pytest.mark.e2edef test_unlogged_customer_unable_to_buy_product_without_shipping_option_CORE_0106(e2e_not_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,permission_manage_product_types_and_attributes,- permission_manage_shipping,+ shop_permissions,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,permission_manage_product_types_and_attributes,- permission_manage_shipping,+ *shop_permissions,]assign_permissions(e2e_staff_api_client, permissions)- (- channel_id,- channel_slug,- warehouse_id,- ) = prepare_shop_with_no_shipping_method(+ shop_data, _tax_config = prepare_shop(e2e_staff_api_client,+ channels=[+ {+ "shipping_zones": [+ {+ "shipping_methods": [],+ },+ ],+ "order_settings": {},+ }+ ],+ shop_settings={},)+ channel_id = shop_data[0]["id"]+ channel_slug = shop_data[0]["slug"]+ warehouse_id = shop_data[0]["warehouse_id"]+variant_price = 10(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 e2f9b6673e..b1db84b0aa 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@@ -8,7 +8,7 @@ from ..product.utils import (create_product_variant_channel_listing,raw_create_product_variant,)-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import raw_checkout_create@@ -16,12 +16,11 @@ from .utils import raw_checkout_createdef prepare_product(e2e_staff_api_client,):- (- warehouse_id,- channel_id,- channel_slug,- _shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)++ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]product_type_data = create_product_type(e2e_staff_api_client,@@ -82,17 +81,13 @@ def prepare_product(def test_unlogged_customer_cannot_buy_product_in_quantity_grater_than_stock_core_0107(e2e_not_logged_api_client,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,permission_manage_product_types_and_attributes,- permission_manage_shipping,+ shop_permissions,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,permission_manage_product_types_and_attributes,- permission_manage_shipping,+ *shop_permissions,]assign_permissions(e2e_staff_api_client, permissions)(diff --git a/saleor/tests/e2e/checkout/utils/checkout_create.py b/saleor/tests/e2e/checkout/utils/checkout_create.pyindex cacc715104..a586184a6c 100644--- a/saleor/tests/e2e/checkout/utils/checkout_create.py+++ b/saleor/tests/e2e/checkout/utils/checkout_create.py@@ -19,7 +19,6 @@ mutation CreateCheckout($input: CheckoutCreateInput!) {channel {slug}- isShippingRequiredtotalPrice {gross {amount@@ -33,6 +32,16 @@ mutation CreateCheckout($input: CheckoutCreateInput!) {}createdisShippingRequired+ billingAddress {+ country {+ code+ }+ }+ shippingAddress {+ country {+ code+ }+ }shippingMethods {id}@@ -72,6 +81,9 @@ mutation CreateCheckout($input: CheckoutCreateInput!) {gross {amount}+ tax {+ amount+ }}undiscountedUnitPrice {amountdiff --git a/saleor/tests/e2e/checkout/utils/checkout_delivery_method_update.py b/saleor/tests/e2e/checkout/utils/checkout_delivery_method_update.pyindex 1d6aaff5bf..06907207e1 100644--- a/saleor/tests/e2e/checkout/utils/checkout_delivery_method_update.py+++ b/saleor/tests/e2e/checkout/utils/checkout_delivery_method_update.py@@ -28,10 +28,8 @@ mutation checkoutDeliveryMethodUpdate($checkoutId: ID!, $deliveryMethodId: ID) {gross {amount}- }- shippingPrice{- gross {- amount+ tax {+ amount}}shippingMethods {diff --git a/saleor/tests/e2e/checkout/utils/query_checkout.py b/saleor/tests/e2e/checkout/utils/query_checkout.pyindex 282ae0f4dc..60810bbd7b 100644--- a/saleor/tests/e2e/checkout/utils/query_checkout.py+++ b/saleor/tests/e2e/checkout/utils/query_checkout.py@@ -30,6 +30,17 @@ query Checkout($checkoutId: ID!){amount}}+ shippingPrice {+ tax {+ amount+ }+ net {+ amount+ }+ gross {+ amount+ }+ }}}"""diff --git a/saleor/tests/e2e/orders/discounts/test_apply_better_promotion_to_product.py b/saleor/tests/e2e/orders/discounts/test_apply_better_promotion_to_product.pyindex 2180f4dbfd..eea8f5133f 100644--- a/saleor/tests/e2e/orders/discounts/test_apply_better_promotion_to_product.py+++ b/saleor/tests/e2e/orders/discounts/test_apply_better_promotion_to_product.py@@ -4,7 +4,7 @@ from ... import DEFAULT_ADDRESSfrom ...product.utils import get_productfrom ...product.utils.preparing_product import prepare_productfrom ...promotions.utils import create_promotion, create_promotion_rule-from ...shop.utils.preparing_shop import prepare_shop+from ...shop.utils.preparing_shop import prepare_default_shopfrom ...utils import assign_permissionsfrom ..utils import draft_order_create, order_lines_create@@ -61,34 +61,29 @@ def test_apply_best_promotion_to_product_core_2105(second_discount_value,expected_discount,e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_orders,- permission_manage_shipping,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_orders,- permission_manage_shipping,]assign_permissions(e2e_staff_api_client, permissions)- (- result_warehouse_id,- result_channel_id,- result_channel_slug,- _,- ) = prepare_shop(e2e_staff_api_client)++ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]product_id, product_variant_id, product_variant_price = prepare_product(e2e_staff_api_client,- result_warehouse_id,- result_channel_id,+ warehouse_id,+ channel_id,variant_price,)@@ -102,7 +97,7 @@ def test_apply_best_promotion_to_product_core_2105(first_discount_type,first_discount_value,first_rule_name,- result_channel_id,+ channel_id,product_id,)@@ -116,12 +111,12 @@ def test_apply_best_promotion_to_product_core_2105(second_discount_type,second_discount_value,second_rule_name,- result_channel_id,+ channel_id,product_id,)# Step 1 - Get product and check if it is on promotion- product_data = get_product(e2e_staff_api_client, product_id, result_channel_slug)+ product_data = get_product(e2e_staff_api_client, product_id, channel_slug)assert product_data["pricing"]["onSale"] is True@@ -136,7 +131,7 @@ def test_apply_best_promotion_to_product_core_2105(# Step 2 - Create draft orderinput = {- "channelId": result_channel_id,+ "channelId": channel_id,"billingAddress": DEFAULT_ADDRESS,"shippingAddress": DEFAULT_ADDRESS,}diff --git a/saleor/tests/e2e/orders/discounts/test_order_product_with_percentage_promotion.py b/saleor/tests/e2e/orders/discounts/test_order_product_with_percentage_promotion.pyindex 879e00ca45..adf879ad57 100644--- a/saleor/tests/e2e/orders/discounts/test_order_product_with_percentage_promotion.py+++ b/saleor/tests/e2e/orders/discounts/test_order_product_with_percentage_promotion.py@@ -3,7 +3,7 @@ import pytestfrom ... import DEFAULT_ADDRESSfrom ...product.utils.preparing_product import prepare_productfrom ...promotions.utils import create_promotion, create_promotion_rule-from ...shop.utils.preparing_shop import prepare_shop+from ...shop.utils.preparing_shop import prepare_default_shopfrom ...utils import assign_permissionsfrom ..utils import (draft_order_complete,@@ -16,36 +16,30 @@ from ..utils import (@pytest.mark.e2edef test_order_products_on_percentage_promotion_CORE_2103(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_orders,):permissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_orders,]assign_permissions(e2e_staff_api_client, permissions)- (- result_warehouse_id,- result_channel_id,- _,- result_shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](product_id,product_variant_id,product_variant_price,) = prepare_product(- e2e_staff_api_client, result_warehouse_id, result_channel_id, variant_price=20+ e2e_staff_api_client, warehouse_id, channel_id, variant_price=20)promotion_name = "Promotion Fixed"@@ -65,18 +59,18 @@ def test_order_products_on_percentage_promotion_CORE_2103(discount_type,discount_value,promotion_rule_name,- result_channel_id,+ channel_id,)product_predicate = promotion_rule["cataloguePredicate"]["productPredicate"]["ids"]- assert promotion_rule["channels"][0]["id"] == result_channel_id+ assert promotion_rule["channels"][0]["id"] == channel_idassert product_predicate[0] == product_id# Step 1 - Create a draft order for a product with fixed promotioninput = {- "channelId": result_channel_id,+ "channelId": channel_id,"billingAddress": DEFAULT_ADDRESS,"shippingAddress": DEFAULT_ADDRESS,- "shippingMethod": result_shipping_method_id,+ "shippingMethod": shipping_method_id,}data = draft_order_create(e2e_staff_api_client, input)order_id = data["order"]["id"]@@ -103,7 +97,7 @@ def test_order_products_on_percentage_promotion_CORE_2103(assert promotion_reason == f"Promotion: {promotion_id}"# Step 3 - Add a shipping method to the order- input = {"shippingMethod": result_shipping_method_id}+ input = {"shippingMethod": shipping_method_id}draft_update = draft_order_update(e2e_staff_api_client, order_id, input)order_shipping_id = draft_update["order"]["deliveryMethod"]["id"]shipping_price = draft_update["order"]["shippingPrice"]["gross"]["amount"]diff --git a/saleor/tests/e2e/orders/discounts/test_order_products_from_the_same_category_on_fixed_promotion.py b/saleor/tests/e2e/orders/discounts/test_order_products_from_the_same_category_on_fixed_promotion.pyindex daa65cbbb2..ff33bd3413 100644--- a/saleor/tests/e2e/orders/discounts/test_order_products_from_the_same_category_on_fixed_promotion.py+++ b/saleor/tests/e2e/orders/discounts/test_order_products_from_the_same_category_on_fixed_promotion.py@@ -1,7 +1,6 @@import pytestfrom ... import DEFAULT_ADDRESS-from ...channel.utils import create_channelfrom ...product.utils import (create_category,create_product,@@ -11,13 +10,8 @@ from ...product.utils import (create_product_variant_channel_listing,)from ...promotions.utils import create_promotion, create_promotion_rule-from ...shipping_zone.utils import (- create_shipping_method,- create_shipping_method_channel_listing,- create_shipping_zone,-)+from ...shop.utils.preparing_shop import prepare_default_shopfrom ...utils import assign_permissions-from ...warehouse.utils import create_warehouse, update_warehousefrom ..utils import (draft_order_complete,draft_order_create,@@ -28,13 +22,9 @@ from ..utils import (def prepare_product(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,- permission_manage_product_types_and_attributes,- permission_manage_discounts,- permission_manage_orders,- channel_slug,+ warehouse_id,+ channel_id,+ shipping_method_id,variant_price_1,variant_price_2,promotion_name,@@ -42,39 +32,6 @@ def prepare_product(discount_type,promotion_rule_name,):- warehouse_data = create_warehouse(e2e_staff_api_client)- warehouse_id = warehouse_data["id"]- update_warehouse(- e2e_staff_api_client,- warehouse_data["id"],- is_private=False,- )- warehouse_ids = [warehouse_id]-- channel_data = create_channel(- e2e_staff_api_client,- warehouse_ids,- slug=channel_slug,- )- 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,)@@ -96,7 +53,7 @@ def prepare_product(stocks = [{- "warehouse": warehouse_data["id"],+ "warehouse": warehouse_id,"quantity": 5,}]@@ -121,7 +78,7 @@ def prepare_product(stocks = [{- "warehouse": warehouse_data["id"],+ "warehouse": warehouse_id,"quantity": 5,}]@@ -171,25 +128,25 @@ def prepare_product(@pytest.mark.e2edef test_order_products_from_category_on_fixed_promotion_CORE_2106(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_orders,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_orders,]assign_permissions(e2e_staff_api_client, permissions)- channel_slug = "test-channel"+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"]+variant_price_1 = "20"variant_price_2 = "10"promotion_name = "Promotion Fixed"@@ -204,13 +161,9 @@ def test_order_products_from_category_on_fixed_promotion_CORE_2106(promotion_id,) = prepare_product(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,- permission_manage_product_types_and_attributes,- permission_manage_discounts,- permission_manage_orders,- channel_slug,+ warehouse_id,+ channel_id,+ shipping_method_id,variant_price_1,variant_price_2,promotion_name,diff --git a/saleor/tests/e2e/orders/discounts/test_order_products_on_fixed_promotion.py b/saleor/tests/e2e/orders/discounts/test_order_products_on_fixed_promotion.pyindex 6355a74006..922ac04ae4 100644--- a/saleor/tests/e2e/orders/discounts/test_order_products_on_fixed_promotion.py+++ b/saleor/tests/e2e/orders/discounts/test_order_products_on_fixed_promotion.py@@ -3,7 +3,7 @@ import pytestfrom ... import DEFAULT_ADDRESSfrom ...product.utils.preparing_product import prepare_productfrom ...promotions.utils import create_promotion, create_promotion_rule-from ...shop.utils.preparing_shop import prepare_shop+from ...shop.utils.preparing_shop import prepare_default_shopfrom ...utils import assign_permissionsfrom ..utils import (draft_order_complete,@@ -16,9 +16,7 @@ from ..utils import (@pytest.mark.e2edef test_order_products_on_fixed_promotion_CORE_2101(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_orders,@@ -30,28 +28,24 @@ def test_order_products_on_fixed_promotion_CORE_2101(promotion_rule_name = "rule for product"permissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_orders,]assign_permissions(e2e_staff_api_client, permissions)- (- result_warehouse_id,- result_channel_id,- _,- result_shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](product_id,product_variant_id,product_variant_price,) = prepare_product(- e2e_staff_api_client, result_warehouse_id, result_channel_id, variant_price=20+ e2e_staff_api_client, warehouse_id, channel_id, variant_price=20)promotion_data = create_promotion(e2e_staff_api_client, promotion_name)@@ -66,18 +60,18 @@ def test_order_products_on_fixed_promotion_CORE_2101(discount_type,discount_value,promotion_rule_name,- result_channel_id,+ channel_id,)product_predicate = promotion_rule["cataloguePredicate"]["productPredicate"]["ids"]- assert promotion_rule["channels"][0]["id"] == result_channel_id+ assert promotion_rule["channels"][0]["id"] == channel_idassert product_predicate[0] == product_id# Step 1 - Create a draft order for a product with fixed promotioninput = {- "channelId": result_channel_id,+ "channelId": channel_id,"billingAddress": DEFAULT_ADDRESS,"shippingAddress": DEFAULT_ADDRESS,- "shippingMethod": result_shipping_method_id,+ "shippingMethod": shipping_method_id,}data = draft_order_create(e2e_staff_api_client, input)order_id = data["order"]["id"]@@ -102,7 +96,7 @@ def test_order_products_on_fixed_promotion_CORE_2101(assert promotion_reason == f"Promotion: {promotion_id}"# Step 3 - Add a shipping method to the order- input = {"shippingMethod": result_shipping_method_id}+ input = {"shippingMethod": shipping_method_id}draft_update = draft_order_update(e2e_staff_api_client, order_id, input)order_shipping_id = draft_update["order"]["deliveryMethod"]["id"]shipping_price = draft_update["order"]["shippingPrice"]["gross"]["amount"]diff --git a/saleor/tests/e2e/orders/discounts/test_order_products_on_fixed_sale.py b/saleor/tests/e2e/orders/discounts/test_order_products_on_fixed_sale.pyindex 5558214108..d3822fc4b3 100644--- a/saleor/tests/e2e/orders/discounts/test_order_products_on_fixed_sale.py+++ b/saleor/tests/e2e/orders/discounts/test_order_products_on_fixed_sale.py@@ -3,7 +3,7 @@ import pytestfrom ... import DEFAULT_ADDRESSfrom ...product.utils.preparing_product import prepare_productfrom ...sales.utils import create_sale, create_sale_channel_listing, sale_catalogues_add-from ...shop.utils.preparing_shop import prepare_shop+from ...shop.utils.preparing_shop import prepare_default_shopfrom ...utils import assign_permissionsfrom ..utils import (draft_order_complete,@@ -51,30 +51,24 @@ def prepare_sale_for_product(@pytest.mark.e2edef test_order_products_on_fixed_sale_CORE_1001(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_orders,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_orders,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- _channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](product_id,diff --git a/saleor/tests/e2e/orders/discounts/test_order_products_on_percentage_sale.py b/saleor/tests/e2e/orders/discounts/test_order_products_on_percentage_sale.pyindex bb96125ec1..8192f76bb4 100644--- a/saleor/tests/e2e/orders/discounts/test_order_products_on_percentage_sale.py+++ b/saleor/tests/e2e/orders/discounts/test_order_products_on_percentage_sale.py@@ -3,7 +3,7 @@ import pytestfrom ... import DEFAULT_ADDRESSfrom ...product.utils.preparing_product import prepare_productfrom ...sales.utils import create_sale, create_sale_channel_listing, sale_catalogues_add-from ...shop.utils.preparing_shop import prepare_shop+from ...shop.utils.preparing_shop import prepare_default_shopfrom ...utils import assign_permissionsfrom ..utils import (draft_order_complete,@@ -51,30 +51,24 @@ def prepare_sale_for_product(@pytest.mark.e2edef test_order_products_on_percentage_sale_CORE_1003(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_orders,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_orders,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- _channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](product_id,diff --git a/saleor/tests/e2e/orders/discounts/test_order_products_on_promotion_and_manual_order_discount.py b/saleor/tests/e2e/orders/discounts/test_order_products_on_promotion_and_manual_order_discount.pyindex 1c40e8844f..547a5f6f7e 100644--- a/saleor/tests/e2e/orders/discounts/test_order_products_on_promotion_and_manual_order_discount.py+++ b/saleor/tests/e2e/orders/discounts/test_order_products_on_promotion_and_manual_order_discount.py@@ -6,7 +6,7 @@ from .....core.prices import quantize_pricefrom ... import DEFAULT_ADDRESSfrom ...product.utils.preparing_product import prepare_productfrom ...promotions.utils import create_promotion, create_promotion_rule-from ...shop.utils.preparing_shop import prepare_shop+from ...shop.utils.preparing_shop import prepare_default_shopfrom ...utils import assign_permissionsfrom ..utils import (draft_order_complete,@@ -20,38 +20,32 @@ from ..utils import (@pytest.mark.e2edef test_order_products_on_promotion_and_manual_order_discount_CORE_2108(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_orders,):permissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_orders,]assign_permissions(e2e_staff_api_client, permissions)- (- result_warehouse_id,- result_channel_id,- _,- result_shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)-+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"]+ base_shipping_price = 10(product_id,product_variant_id,product_variant_price,) = prepare_product(e2e_staff_api_client,- result_warehouse_id,- result_channel_id,+ warehouse_id,+ channel_id,variant_price=20,)@@ -72,19 +66,19 @@ def test_order_products_on_promotion_and_manual_order_discount_CORE_2108(discount_type,promotion_discount_value,promotion_rule_name,- result_channel_id,+ channel_id,)product_predicate = promotion_rule["cataloguePredicate"]["productPredicate"]["ids"]- assert promotion_rule["channels"][0]["id"] == result_channel_id+ assert promotion_rule["channels"][0]["id"] == channel_idassert product_predicate[0] == product_idcurrency = "USD"# Step 1 - Create a draft order for a product with fixed promotioninput = {- "channelId": result_channel_id,+ "channelId": channel_id,"billingAddress": DEFAULT_ADDRESS,"shippingAddress": DEFAULT_ADDRESS,- "shippingMethod": result_shipping_method_id,+ "shippingMethod": shipping_method_id,}data = draft_order_create(e2e_staff_api_client, input)order_id = data["order"]["id"]@@ -132,8 +126,7 @@ def test_order_products_on_promotion_and_manual_order_discount_CORE_2108(assert discount["value"] == manual_discount_value# Step 4 - Add a shipping method to the order- base_shipping_price = 10- input = {"shippingMethod": result_shipping_method_id}+ input = {"shippingMethod": shipping_method_id}draft_update = draft_order_update(e2e_staff_api_client, order_id, input)order_shipping_id = draft_update["order"]["deliveryMethod"]["id"]shipping_price = draft_update["order"]["shippingPrice"]["gross"]["amount"]diff --git a/saleor/tests/e2e/orders/discounts/test_order_promotion_not_applied_when_not_within_time_range.py b/saleor/tests/e2e/orders/discounts/test_order_promotion_not_applied_when_not_within_time_range.pyindex 58ad2c35b2..5d10f97138 100644--- a/saleor/tests/e2e/orders/discounts/test_order_promotion_not_applied_when_not_within_time_range.py+++ b/saleor/tests/e2e/orders/discounts/test_order_promotion_not_applied_when_not_within_time_range.py@@ -8,7 +8,7 @@ from ... import DEFAULT_ADDRESSfrom ...product.utils import get_productfrom ...product.utils.preparing_product import prepare_productfrom ...promotions.utils import create_promotion, create_promotion_rule-from ...shop.utils.preparing_shop import prepare_shop+from ...shop.utils.preparing_shop import prepare_default_shopfrom ...utils import assign_permissionsfrom ..utils import draft_order_create@@ -17,18 +17,14 @@ from ..utils import draft_order_create@pytest.mark.e2edef test_order_promotion_not_applied_when_not_within_time_range_CORE_2110(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_orders,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_orders,@@ -43,12 +39,11 @@ def test_order_promotion_not_applied_when_not_within_time_range_CORE_2110(tomorrow = today + timedelta(days=1)month_after = today + timedelta(days=30)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](product_id,diff --git a/saleor/tests/e2e/orders/discounts/test_order_promotion_still_applied_to_the_order_when_promotion_is_removed.py b/saleor/tests/e2e/orders/discounts/test_order_promotion_still_applied_to_the_order_when_promotion_is_removed.pyindex 47fad337c8..ddd97505fd 100644--- a/saleor/tests/e2e/orders/discounts/test_order_promotion_still_applied_to_the_order_when_promotion_is_removed.py+++ b/saleor/tests/e2e/orders/discounts/test_order_promotion_still_applied_to_the_order_when_promotion_is_removed.py@@ -9,7 +9,7 @@ from ...promotions.utils import (delete_promotion,promotion_query,)-from ...shop.utils.preparing_shop import prepare_shop+from ...shop.utils.preparing_shop import prepare_default_shopfrom ...utils import assign_permissionsfrom ..utils import (draft_order_complete,@@ -22,9 +22,7 @@ from ..utils import (@pytest.mark.e2edef test_order_promotion_still_applied_to_the_order_when_promotion_is_removed_CORE_2115(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_orders,@@ -36,21 +34,18 @@ def test_order_promotion_still_applied_to_the_order_when_promotion_is_removed_COpromotion_rule_name = "rule for product"permissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_orders,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](product_id,diff --git a/saleor/tests/e2e/orders/taxes/test_order_calculate_simple_tax_based_on_shipping_address_tax_class.py b/saleor/tests/e2e/orders/taxes/test_order_calculate_simple_taxes_based_on_shipping_address.pysimilarity index 58%rename from saleor/tests/e2e/orders/taxes/test_order_calculate_simple_tax_based_on_shipping_address_tax_class.pyrename to saleor/tests/e2e/orders/taxes/test_order_calculate_simple_taxes_based_on_shipping_address.pyindex b6f8ba7162..83079986b2 100644--- a/saleor/tests/e2e/orders/taxes/test_order_calculate_simple_tax_based_on_shipping_address_tax_class.py+++ b/saleor/tests/e2e/orders/taxes/test_order_calculate_simple_taxes_based_on_shipping_address.py@@ -1,19 +1,9 @@import pytest-from ...channel.utils import create_channelfrom ...product.utils.preparing_product import prepare_product-from ...shipping_zone.utils import (- create_shipping_method,- create_shipping_method_channel_listing,- create_shipping_zone,-)-from ...taxes.utils import (- get_tax_configurations,- update_country_tax_rates,- update_tax_configuration,-)+from ...shop.utils.preparing_shop import prepare_shop+from ...taxes.utils import update_country_tax_ratesfrom ...utils import assign_permissions-from ...warehouse.utils import create_warehousefrom ..utils import (draft_order_complete,draft_order_create,@@ -22,121 +12,83 @@ from ..utils import ()-def prepare_shop_with_few_shipping_zone_countries(- e2e_staff_api_client,- shipping_price,-):- 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,- countries=["CZ", "DE", "US"],- 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,- price=shipping_price,- )-- return (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- shipping_price,- )---def prepare_tax_configuration(- e2e_staff_api_client,- channel_slug,- shipping_country_code,- shipping_country_tax_rate,- billing_country_code,- billing_country_tax_rate,-):- tax_config_data = get_tax_configurations(e2e_staff_api_client)- channel_tax_config = tax_config_data[0]["node"]- assert channel_tax_config["channel"]["slug"] == channel_slug- tax_config_id = channel_tax_config["id"]-- tax_config_data = update_tax_configuration(- e2e_staff_api_client,- tax_config_id,- charge_taxes=True,- tax_calculation_strategy="FLAT_RATES",- display_gross_prices=True,- prices_entered_with_tax=False,- )- update_country_tax_rates(- e2e_staff_api_client,- shipping_country_code,- [{"rate": shipping_country_tax_rate}],- )- update_country_tax_rates(- e2e_staff_api_client,- billing_country_code,- [{"rate": billing_country_tax_rate}],- )- return shipping_country_tax_rate--@pytest.mark.e2e-def test_order_calculate_simple_tax_based_on_shipping_address_tax_class_CORE_2002(+def test_order_calculate_simple_tax_based_on_shipping_address_CORE_2002(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,- permission_manage_taxes,permission_manage_orders,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_taxes,permission_manage_orders,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- shipping_price,- ) = prepare_shop_with_few_shipping_zone_countries(e2e_staff_api_client, "6.66")+ tax_settings = {+ "charge_taxes": True,+ "tax_calculation_strategy": "FLAT_RATES",+ "display_gross_prices": False,+ "prices_entered_with_tax": False,+ }+ shop_data, _tax_config = prepare_shop(+ e2e_staff_api_client,+ channels=[+ {+ "shipping_zones": [+ {+ "countries": ["US"],+ "shipping_methods": [+ {+ "name": "us shipping zone",+ "add_channels": {},+ }+ ],+ },+ {+ "countries": ["CZ"],+ "shipping_methods": [+ {+ "name": "cz shipping zone",+ "add_channels": {},+ }+ ],+ },+ {+ "countries": ["DE"],+ "shipping_methods": [+ {+ "name": "de shipping zone",+ "add_channels": {},+ }+ ],+ },+ ],+ "order_settings": {},+ }+ ],+ tax_settings=tax_settings,+ )+ channel_id = shop_data[0]["id"]+ warehouse_id = shop_data[0]["warehouse_id"]+ shipping_method_id = shop_data[0]["shipping_zones"][2]["shipping_methods"][0]["id"]+ billing_country_tax_rate = 21+ billing_country_code = "CZ"+ shipping_country_code = "DE"+ shipping_country_tax_rate = 19- shipping_country_tax_rate = prepare_tax_configuration(+ update_country_tax_rates(+ e2e_staff_api_client,+ shipping_country_code,+ [{"rate": shipping_country_tax_rate}],+ )+ update_country_tax_rates(e2e_staff_api_client,- channel_slug,- shipping_country_code="DE",- shipping_country_tax_rate=19,- billing_country_code="CZ",- billing_country_tax_rate=21,+ billing_country_code,+ [{"rate": billing_country_tax_rate}],)-variant_price = "155.88"(_product_id, product_variant_id, product_variant_price) = prepare_product(e2e_staff_api_client,@@ -205,7 +157,7 @@ def test_order_calculate_simple_tax_based_on_shipping_address_tax_class_CORE_200assert draft_order["order"]["shippingAddress"] is not Noneassert draft_order["order"]["billingAddress"] is not None- # Step 3 - Add a shipping method+ # Step 4 - Add a shipping methodinput = {"shippingMethod": shipping_method_id}order_data = draft_order_update(e2e_staff_api_client,@@ -228,7 +180,7 @@ def test_order_calculate_simple_tax_based_on_shipping_address_tax_class_CORE_200assert order_data["total"]["net"]["amount"] == calculated_totalassert order_data["total"]["gross"]["amount"] == total_tax + calculated_total- # Step 4 - Complete the draft order+ # Step 5 - Complete the draft orderorder = draft_order_complete(e2e_staff_api_client,order_id,diff --git a/saleor/tests/e2e/orders/taxes/test_order_calculate_simple_taxes_based_on_shipping_tax_class.py b/saleor/tests/e2e/orders/taxes/test_order_calculate_simple_taxes_based_on_shipping_tax_class.pyindex 9792d9fb7c..4f27ba790f 100644--- a/saleor/tests/e2e/orders/taxes/test_order_calculate_simple_taxes_based_on_shipping_tax_class.py+++ b/saleor/tests/e2e/orders/taxes/test_order_calculate_simple_taxes_based_on_shipping_tax_class.py@@ -4,12 +4,7 @@ from ... import DEFAULT_ADDRESSfrom ...product.utils.preparing_product import prepare_productfrom ...shipping_zone.utils import update_shipping_pricefrom ...shop.utils import prepare_shop-from ...taxes.utils import (- create_tax_class,- get_tax_configurations,- update_country_tax_rates,- update_tax_configuration,-)+from ...taxes.utils import update_country_tax_ratesfrom ...utils import assign_permissionsfrom ..utils import (draft_order_complete,@@ -19,79 +14,74 @@ from ..utils import ()-def prepare_tax_configuration(- e2e_staff_api_client,- channel_slug,- country_code,- country_tax_rate,- shipping_tax_rate,- prices_entered_with_tax,-):- tax_config_data = get_tax_configurations(e2e_staff_api_client)- channel_tax_config = tax_config_data[0]["node"]- assert channel_tax_config["channel"]["slug"] == channel_slug- tax_config_id = channel_tax_config["id"]-- tax_config_data = update_tax_configuration(- e2e_staff_api_client,- tax_config_id,- charge_taxes=True,- tax_calculation_strategy="FLAT_RATES",- display_gross_prices=True,- prices_entered_with_tax=prices_entered_with_tax,- )- update_country_tax_rates(- e2e_staff_api_client,- country_code,- [{"rate": country_tax_rate}],- )-- country_rates = [{"countryCode": country_code, "rate": shipping_tax_rate}]- tax_class_data = create_tax_class(- e2e_staff_api_client,- "Shipping tax class",- country_rates,- )- tax_class_id = tax_class_data["id"]-- return country_tax_rate, shipping_tax_rate, tax_class_id--@pytest.mark.e2edef test_order_calculate_simple_tax_based_on_shipping_tax_class_CORE_2010(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,- permission_manage_taxes,permission_manage_orders,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_taxes,permission_manage_orders,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ country_code = "US"+ shipping_tax_rate = 8+ tax_settings = {+ "charge_taxes": True,+ "tax_calculation_strategy": "FLAT_RATES",+ "display_gross_prices": False,+ "prices_entered_with_tax": True,+ "tax_rates": [+ {+ "type": "shipping_country",+ "name": "Shipping Country Tax Rate",+ "country_code": country_code,+ "rate": shipping_tax_rate,+ },+ ],+ }+ shop_data, tax_config = prepare_shop(+ e2e_staff_api_client,+ channels=[+ {+ "shipping_zones": [+ {+ "shipping_methods": [+ {+ "add_channels": {},+ }+ ],+ },+ ],+ "order_settings": {},+ },+ ],+ tax_settings=tax_settings,+ )- country_tax_rate, shipping_tax_rate, tax_class_id = prepare_tax_configuration(+ channel_id = shop_data[0]["id"]+ shipping_method_id = shop_data[0]["shipping_zones"][0]["shipping_methods"][0]["id"]+ warehouse_id = shop_data[0]["warehouse_id"]+ shipping_tax_class_id = tax_config[0]["shipping_country_tax_class_id"]+ shipping_tax_rate = tax_config[1]["shipping_country"]["rate"]+ country_tax_rate = 10+ shipping_price = 10.0++ update_country_tax_rates(+ e2e_staff_api_client,+ country_code,+ [{"rate": country_tax_rate}],+ )+ input_data = {"taxClass": shipping_tax_class_id}+ update_shipping_price(e2e_staff_api_client,- channel_slug,- country_code="US",- country_tax_rate=10,- shipping_tax_rate=8,- prices_entered_with_tax=True,+ shipping_method_id,+ input_data,)variant_price = "33.33"@@ -105,8 +95,6 @@ def test_order_calculate_simple_tax_based_on_shipping_tax_class_CORE_2010(channel_id,variant_price,)- shipping_tax_class = {"taxClass": tax_class_id}- update_shipping_price(e2e_staff_api_client, shipping_method_id, shipping_tax_class)# Step 1 - Create a draft orderinput = {@@ -139,7 +127,6 @@ def test_order_calculate_simple_tax_based_on_shipping_tax_class_CORE_2010(2,)subtotal_net = round(subtotal_gross - subtotal_tax, 2)-assert order_data["isShippingRequired"] is Trueassert order_data["total"]["gross"]["amount"] == subtotal_grossassert order_data["total"]["tax"]["amount"] == subtotal_taxdiff --git a/saleor/tests/e2e/orders/taxes/test_order_calculate_simple_taxes_for_digital_product.py b/saleor/tests/e2e/orders/taxes/test_order_calculate_simple_taxes_for_digital_product.pyindex 67bd26ef3c..c503538e2a 100644--- a/saleor/tests/e2e/orders/taxes/test_order_calculate_simple_taxes_for_digital_product.py+++ b/saleor/tests/e2e/orders/taxes/test_order_calculate_simple_taxes_for_digital_product.py@@ -1,142 +1,78 @@import pytest-from ...channel.utils import create_channelfrom ...product.utils.preparing_product import prepare_digital_product-from ...shipping_zone.utils import (- create_shipping_method,- create_shipping_method_channel_listing,- create_shipping_zone,-)-from ...taxes.utils import (- get_tax_configurations,- update_country_tax_rates,- update_tax_configuration,-)+from ...shop.utils.preparing_shop import prepare_shop+from ...taxes.utils import update_country_tax_ratesfrom ...utils import assign_permissions-from ...warehouse.utils import create_warehousefrom ..utils import draft_order_complete, draft_order_create, order_lines_create-def prepare_shop(- e2e_staff_api_client,- shipping_price,-):- warehouse_data = create_warehouse(e2e_staff_api_client)- warehouse_id = warehouse_data["id"]- channel_slug = "channel-de"- warehouse_ids = [warehouse_id]- channel_data = create_channel(- e2e_staff_api_client,- slug=channel_slug,- warehouse_ids=warehouse_ids,- currency="EUR",- country="DE",- )- channel_id = channel_data["id"]- channel_ids = [channel_id]- shipping_zone_data = create_shipping_zone(- e2e_staff_api_client,- countries=["DE", "US"],- 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,- price=shipping_price,- )-- return (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- shipping_price,- )---def prepare_tax_configuration(- e2e_staff_api_client,- channel_slug,- shipping_country_code,- shipping_country_tax_rate,- billing_country_code,- billing_country_tax_rate,- prices_entered_with_tax,-):- tax_config_data = get_tax_configurations(e2e_staff_api_client)- channel_tax_config = tax_config_data[0]["node"]- assert channel_tax_config["channel"]["slug"] == channel_slug- tax_config_id = channel_tax_config["id"]-- tax_config_data = update_tax_configuration(- e2e_staff_api_client,- tax_config_id,- charge_taxes=True,- tax_calculation_strategy="FLAT_RATES",- display_gross_prices=True,- prices_entered_with_tax=prices_entered_with_tax,- )- update_country_tax_rates(- e2e_staff_api_client,- shipping_country_code,- [{"rate": shipping_country_tax_rate}],- )- update_country_tax_rates(- e2e_staff_api_client, billing_country_code, [{"rate": billing_country_tax_rate}]- )-- return billing_country_tax_rate--@pytest.mark.e2edef test_digital_order_calculate_simple_tax_based_on_billing_country_CORE_2008(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,- permission_manage_taxes,permission_manage_orders,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_taxes,permission_manage_orders,]assign_permissions(e2e_staff_api_client, permissions)- shipping_price = 10- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- shipping_price,- ) = prepare_shop(e2e_staff_api_client, shipping_price)+ tax_settings = {+ "charge_taxes": True,+ "tax_calculation_strategy": "FLAT_RATES",+ "display_gross_prices": False,+ "prices_entered_with_tax": True,+ }++ shop_data, _tax_config = prepare_shop(+ e2e_staff_api_client,+ channels=[+ {+ "shipping_zones": [+ {+ "countries": ["US"],+ "shipping_methods": [+ {+ "name": "us shipping zone",+ "add_channels": {},+ }+ ],+ },+ {+ "countries": ["DE"],+ "shipping_methods": [+ {+ "name": "de shipping zone",+ "add_channels": {},+ }+ ],+ },+ ],+ "order_settings": {},+ }+ ],+ tax_settings=tax_settings,+ )- billing_country_tax_rate = prepare_tax_configuration(+ channel_id = shop_data[0]["id"]+ warehouse_id = shop_data[0]["warehouse_id"]+ billing_country_tax_rate = 19+ billing_country_code = "DE"+ shipping_country_tax_rate = 5++ update_country_tax_rates(e2e_staff_api_client,- channel_slug,- shipping_country_code="US",- shipping_country_tax_rate=5,- billing_country_code="DE",- billing_country_tax_rate=19,- prices_entered_with_tax=True,+ billing_country_code,+ [{"rate": billing_country_tax_rate}],)+variant_price = 100- product_id, product_variant_id, product_variant_price = prepare_digital_product(+ _product_id, product_variant_id, product_variant_price = prepare_digital_product(e2e_staff_api_client, channel_id, warehouse_id, variant_price)@@ -175,14 +111,20 @@ def test_digital_order_calculate_simple_tax_based_on_billing_country_CORE_2008(order_data = order_data["order"]product_variant_price = float(product_variant_price)assert order_data["total"]["gross"]["amount"] == product_variant_price- calculated_tax = round(+ billing_tax = round((product_variant_price * billing_country_tax_rate)/ (100 + billing_country_tax_rate),2,)- assert order_data["total"]["tax"]["amount"] == calculated_tax+ shipping_tax = round(+ (product_variant_price * (shipping_country_tax_rate / 100)),+ 2,+ )+ assert order_data["total"]["tax"]["amount"] == billing_tax+ assert order_data["total"]["tax"]["amount"] != shipping_tax+assert order_data["total"]["net"]["amount"] == round(- product_variant_price - calculated_tax, 2+ product_variant_price - billing_tax, 2)# Step 3 - Complete the draft order@@ -192,4 +134,4 @@ def test_digital_order_calculate_simple_tax_based_on_billing_country_CORE_2008()assert order["order"]["status"] == "UNFULFILLED"assert order["order"]["paymentStatus"] == "NOT_CHARGED"- assert order["order"]["total"]["tax"]["amount"] == calculated_tax+ assert order["order"]["total"]["tax"]["amount"] == billing_taxdiff --git a/saleor/tests/e2e/orders/taxes/test_order_calculate_simple_taxes_product_tax_class.py b/saleor/tests/e2e/orders/taxes/test_order_calculate_simple_taxes_product_tax_class.pyindex 0496b61e6b..261fd0f3d1 100644--- a/saleor/tests/e2e/orders/taxes/test_order_calculate_simple_taxes_product_tax_class.py+++ b/saleor/tests/e2e/orders/taxes/test_order_calculate_simple_taxes_product_tax_class.py@@ -4,12 +4,7 @@ from ... import DEFAULT_ADDRESSfrom ...product.utils import update_productfrom ...product.utils.preparing_product import prepare_productfrom ...shop.utils.preparing_shop import prepare_shop-from ...taxes.utils import (- create_tax_class,- get_tax_configurations,- update_country_tax_rates,- update_tax_configuration,-)+from ...taxes.utils import update_country_tax_ratesfrom ...utils import assign_permissionsfrom ..utils import (draft_order_complete,@@ -19,81 +14,68 @@ from ..utils import ()-def prepare_tax_configuration(- e2e_staff_api_client,- channel_slug,- country_code,- country_tax_rate,- product_tax_rate,- prices_entered_with_tax,-):- tax_config_data = get_tax_configurations(e2e_staff_api_client)- channel_tax_config = tax_config_data[0]["node"]- assert channel_tax_config["channel"]["slug"] == channel_slug- tax_config_id = channel_tax_config["id"]-- tax_config_data = update_tax_configuration(- e2e_staff_api_client,- tax_config_id,- charge_taxes=True,- tax_calculation_strategy="FLAT_RATES",- display_gross_prices=True,- prices_entered_with_tax=prices_entered_with_tax,- )- update_country_tax_rates(- e2e_staff_api_client,- country_code,- [{"rate": country_tax_rate}],- )-- country_rates = [{"countryCode": country_code, "rate": product_tax_rate}]- tax_class_data = create_tax_class(- e2e_staff_api_client,- "Product tax class",- country_rates,- )- tax_class_id = tax_class_data["id"]-- return country_tax_rate, product_tax_rate, tax_class_id--@pytest.mark.e2edef test_order_calculate_simple_tax_based_on_product_tax_class_CORE_2006(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,- permission_manage_taxes,permission_manage_orders,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_taxes,permission_manage_orders,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ tax_settings = {+ "charge_taxes": True,+ "tax_calculation_strategy": "FLAT_RATES",+ "display_gross_prices": False,+ "prices_entered_with_tax": False,+ "tax_rates": [+ {+ "type": "product",+ "name": "Product Tax Rate",+ "country_code": "US",+ "rate": 13,+ },+ ],+ }- country_tax_rate, product_tax_rate, tax_class_id = prepare_tax_configuration(+ shop_data, tax_config = prepare_shop(e2e_staff_api_client,- channel_slug,- country_code="US",- country_tax_rate=20,- product_tax_rate=13,- prices_entered_with_tax=False,+ channels=[+ {+ "shipping_zones": [+ {+ "shipping_methods": [+ {+ "add_channels": {},+ }+ ],+ },+ ],+ "order_settings": {},+ },+ ],+ tax_settings=tax_settings,)+ channel_id = shop_data[0]["id"]+ shipping_method_id = shop_data[0]["shipping_zones"][0]["shipping_methods"][0]["id"]+ shipping_price = 10.0+ warehouse_id = shop_data[0]["warehouse_id"]+ product_tax_class_id = tax_config[0]["product_tax_class_id"]+ product_tax_rate = tax_config[1]["product"]["rate"]+ country_tax_rate = 20+ country = "US"+ update_country_tax_rates(+ e2e_staff_api_client,+ country,+ [{"rate": country_tax_rate}],+ )variant_price = "1234"(product_id, product_variant_id, product_variant_price) = prepare_product(e2e_staff_api_client,@@ -101,7 +83,7 @@ def test_order_calculate_simple_tax_based_on_product_tax_class_CORE_2006(channel_id,variant_price,)- product_tax_class = {"taxClass": tax_class_id}+ product_tax_class = {"taxClass": product_tax_class_id}update_product(e2e_staff_api_client, product_id, input=product_tax_class)# Step 1 - Create a draft order@@ -136,7 +118,6 @@ def test_order_calculate_simple_tax_based_on_product_tax_class_CORE_2006(assert order_data["total"]["gross"]["amount"] == round(product_variant_price + calculated_tax, 2)- shipping_method_id = order_data["shippingMethods"][0]["id"]shipping_price = order_data["shippingMethods"][0]["price"]["amount"]# Step 3 - Add a shipping method to the order and check pricesdiff --git a/saleor/tests/e2e/orders/taxes/test_order_calculate_simple_taxes_product_type_tax_class.py b/saleor/tests/e2e/orders/taxes/test_order_calculate_simple_taxes_product_type_tax_class.pyindex d32a19126a..b4dcebe44b 100644--- a/saleor/tests/e2e/orders/taxes/test_order_calculate_simple_taxes_product_type_tax_class.py+++ b/saleor/tests/e2e/orders/taxes/test_order_calculate_simple_taxes_product_type_tax_class.py@@ -11,12 +11,7 @@ from ...product.utils import (update_product_type,)from ...shop.utils.preparing_shop import prepare_shop-from ...taxes.utils import (- create_tax_class,- get_tax_configurations,- update_country_tax_rates,- update_tax_configuration,-)+from ...taxes.utils import update_country_tax_ratesfrom ...utils import assign_permissionsfrom ..utils import (draft_order_complete,@@ -26,44 +21,6 @@ from ..utils import ()-def prepare_tax_configuration(- e2e_staff_api_client,- channel_slug,- country_code,- country_tax_rate,- product_type_tax_rate,- prices_entered_with_tax,-):- tax_config_data = get_tax_configurations(e2e_staff_api_client)- channel_tax_config = tax_config_data[0]["node"]- assert channel_tax_config["channel"]["slug"] == channel_slug- tax_config_id = channel_tax_config["id"]-- tax_config_data = update_tax_configuration(- e2e_staff_api_client,- tax_config_id,- charge_taxes=True,- tax_calculation_strategy="FLAT_RATES",- display_gross_prices=True,- prices_entered_with_tax=True,- )- update_country_tax_rates(- e2e_staff_api_client,- country_code,- [{"rate": country_tax_rate}],- )-- country_rates = [{"countryCode": country_code, "rate": product_type_tax_rate}]- tax_class_data = create_tax_class(- e2e_staff_api_client,- "Product type tax class",- country_rates,- )- tax_class_id = tax_class_data["id"]-- return country_tax_rate, product_type_tax_rate, tax_class_id--def prepare_product(e2e_staff_api_client,warehouse_id,@@ -120,40 +77,64 @@ def prepare_product(@pytest.mark.e2edef test_order_calculate_simple_tax_based_on_product_type_tax_class_CORE_2004(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,- permission_manage_taxes,permission_manage_orders,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_taxes,permission_manage_orders,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ tax_settings = {+ "charge_taxes": True,+ "tax_calculation_strategy": "FLAT_RATES",+ "display_gross_prices": False,+ "prices_entered_with_tax": True,+ "tax_rates": [+ {+ "type": "product_type",+ "name": "Product Type Tax Rate",+ "country_code": "US",+ "rate": 11,+ },+ ],+ }+ shop_data, tax_config = prepare_shop(+ e2e_staff_api_client,+ channels=[+ {+ "shipping_zones": [+ {+ "shipping_methods": [+ {+ "add_channels": {},+ }+ ],+ },+ ],+ "order_settings": {},+ },+ ],+ tax_settings=tax_settings,+ )+ channel_id = shop_data[0]["id"]+ shipping_method_id = shop_data[0]["shipping_zones"][0]["shipping_methods"][0]["id"]+ shipping_price = 10.0+ warehouse_id = shop_data[0]["warehouse_id"]+ product_type_tax_class_id = tax_config[0]["product_type_tax_class_id"]+ product_type_tax_rate = tax_config[1]["product_type"]["rate"]+ shipping_country_tax_rate = 21+ country = "US"- country_tax_rate, product_type_tax_rate, tax_class_id = prepare_tax_configuration(+ update_country_tax_rates(e2e_staff_api_client,- channel_slug,- country_code="US",- country_tax_rate=21,- product_type_tax_rate=11,- prices_entered_with_tax=True,+ country,+ [{"rate": shipping_country_tax_rate}],)-variant_price = "4.22"(product_variant_id, product_variant_price, product_type_id) = prepare_product(e2e_staff_api_client,@@ -161,18 +142,18 @@ def test_order_calculate_simple_tax_based_on_product_type_tax_class_CORE_2004(channel_id,variant_price,)- product_type_tax_class = {"taxClass": tax_class_id}+ product_type_tax_class = {"taxClass": product_type_tax_class_id}update_product_type(e2e_staff_api_client, product_type_id, product_type_tax_class)# Step 1 - Create a draft order- input = {+ input_data = {"channelId": channel_id,"billingAddress": DEFAULT_ADDRESS,"shippingAddress": DEFAULT_ADDRESS,}data = draft_order_create(e2e_staff_api_client,- input,+ input_data,)order_id = data["order"]["id"]assert data["order"]["billingAddress"] is not None@@ -196,7 +177,6 @@ def test_order_calculate_simple_tax_based_on_product_type_tax_class_CORE_2004(assert order_data["total"]["net"]["amount"] == round(product_variant_price - calculated_tax, 2)- shipping_method_id = order_data["shippingMethods"][0]["id"]# Step 3 - Add a shipping method to the order and check pricesinput = {"shippingMethod": shipping_method_id}@@ -208,7 +188,12 @@ def test_order_calculate_simple_tax_based_on_product_type_tax_class_CORE_2004(order_data = order_data["order"]shipping_price = order_data["shippingPrice"]["gross"]["amount"]shipping_tax = round(- (shipping_price * country_tax_rate / (100 + country_tax_rate)), 2+ (+ shipping_price+ * shipping_country_tax_rate+ / (100 + shipping_country_tax_rate)+ ),+ 2,)assert order_data["shippingPrice"]["tax"]["amount"] == shipping_taxassert order_data["shippingPrice"]["net"]["amount"] == shipping_price - shipping_taxdiff --git a/saleor/tests/e2e/orders/test_app_can_create_order_from_checkout.py b/saleor/tests/e2e/orders/test_app_can_create_order_from_checkout.pyindex 5e8d3a84ae..e20e2b2e7d 100644--- a/saleor/tests/e2e/orders/test_app_can_create_order_from_checkout.py+++ b/saleor/tests/e2e/orders/test_app_can_create_order_from_checkout.py@@ -2,7 +2,7 @@ import pytestfrom ..checkout.utils import checkout_create, checkout_delivery_method_updatefrom ..product.utils.preparing_product import prepare_product-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import order_create_from_checkout@@ -11,19 +11,15 @@ from .utils import order_create_from_checkoutdef test_app_can_create_order_from_checkout_CORE_0215(e2e_staff_api_client,e2e_app_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,permission_manage_orders,permission_manage_payments,permission_handle_checkouts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_orders,]@@ -32,18 +28,17 @@ def test_app_can_create_order_from_checkout_CORE_0215(permission_manage_payments,permission_handle_checkouts,permission_manage_orders,- permission_manage_channels,+ *shop_permissions,]assign_permissions(e2e_app_api_client, app_permissions)price = 10- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](_product_id,@@ -75,7 +70,6 @@ def test_app_can_create_order_from_checkout_CORE_0215(assert checkout_id is not Noneassert checkout_data["isShippingRequired"] is Trueassert len(checkout_data["shippingMethods"]) == 1- shipping_method_id = checkout_data["shippingMethods"][0]["id"]# Step 2 - Assign shipping methodcheckout_data = checkout_delivery_method_update(diff --git a/saleor/tests/e2e/orders/test_cancel_fully_paid_order.py b/saleor/tests/e2e/orders/test_cancel_fully_paid_order.pyindex edd9e1d872..2a6ab12026 100644--- a/saleor/tests/e2e/orders/test_cancel_fully_paid_order.py+++ b/saleor/tests/e2e/orders/test_cancel_fully_paid_order.py@@ -2,7 +2,7 @@ import pytestfrom .. import DEFAULT_ADDRESSfrom ..product.utils.preparing_product import prepare_product-from ..shop.utils import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..transactions.utils import create_transactionfrom ..utils import assign_permissionsfrom .utils import (@@ -19,18 +19,14 @@ from .utils import (def test_cancel_fully_paid_order_CORE_0206(e2e_staff_api_client,e2e_app_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,permission_manage_orders,permission_manage_payments,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_orders,permission_manage_payments,@@ -41,12 +37,10 @@ def test_cancel_fully_paid_order_CORE_0206(price = 10- (- warehouse_id,- channel_id,- _channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](_product_id,diff --git a/saleor/tests/e2e/orders/test_cancel_partially_paid_order.py b/saleor/tests/e2e/orders/test_cancel_partially_paid_order.pyindex 87d926743d..ece588b354 100644--- a/saleor/tests/e2e/orders/test_cancel_partially_paid_order.py+++ b/saleor/tests/e2e/orders/test_cancel_partially_paid_order.py@@ -2,7 +2,7 @@ import pytestfrom .. import DEFAULT_ADDRESSfrom ..product.utils.preparing_product import prepare_product-from ..shop.utils import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..transactions.utils import create_transactionfrom ..utils import assign_permissionsfrom .utils import (@@ -19,18 +19,14 @@ from .utils import (def test_cancel_partially_paid_order_CORE_0207(e2e_staff_api_client,e2e_app_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,permission_manage_orders,permission_manage_payments,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_orders,permission_manage_payments,@@ -41,12 +37,10 @@ def test_cancel_partially_paid_order_CORE_0207(price = 10- (- warehouse_id,- channel_id,- _channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](_product_id,diff --git a/saleor/tests/e2e/orders/test_cancel_unpaid_order.py b/saleor/tests/e2e/orders/test_cancel_unpaid_order.pyindex 21c3c17763..3bdf1aaf75 100644--- a/saleor/tests/e2e/orders/test_cancel_unpaid_order.py+++ b/saleor/tests/e2e/orders/test_cancel_unpaid_order.py@@ -2,7 +2,7 @@ import pytestfrom .. import DEFAULT_ADDRESSfrom ..product.utils.preparing_product import prepare_product-from ..shop.utils import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import (draft_order_complete,@@ -16,17 +16,13 @@ from .utils import (@pytest.mark.e2edef test_cancel_unpaid_order_CORE_0204(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,permission_manage_orders,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_orders,]@@ -34,12 +30,10 @@ def test_cancel_unpaid_order_CORE_0204(price = 10- (- warehouse_id,- channel_id,- _channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](_product_id,diff --git a/saleor/tests/e2e/orders/test_cannot_fullfill_order_with_invalid_shipping_method.py b/saleor/tests/e2e/orders/test_cannot_fullfill_order_with_invalid_shipping_method.pyindex b6a7c4e265..31f084bd9b 100644--- a/saleor/tests/e2e/orders/test_cannot_fullfill_order_with_invalid_shipping_method.py+++ b/saleor/tests/e2e/orders/test_cannot_fullfill_order_with_invalid_shipping_method.py@@ -1,133 +1,68 @@-import base64-import pytestfrom .. import DEFAULT_ADDRESS-from ..channel.utils import create_channelfrom ..product.utils.preparing_product import prepare_product-from ..shipping_zone.utils import (- create_shipping_method,- create_shipping_method_channel_listing,- create_shipping_zone,-)+from ..shop.utils import prepare_shopfrom ..utils import assign_permissions-from ..warehouse.utils import create_warehousefrom .utils.draft_order_complete import raw_draft_order_completefrom .utils.draft_order_create import draft_order_createfrom .utils.draft_order_update import draft_order_updatefrom .utils.order_lines_create import order_lines_createfrom .utils.order_query import order_query-# Please note: decoding won't be necessary once-# https://github.com/saleor/saleor/issues/13675 is fixed---def decode_base64_and_get_last_2_chars(encoded_string):- base64_bytes = encoded_string.encode("ascii")- decoded_bytes = base64.b64decode(base64_bytes)- decoded_string = decoded_bytes.decode("ascii")- return decoded_string[-2:]---first_address = DEFAULT_ADDRESS---def prepare_shipping_methods(- e2e_staff_api_client,-):- warehouse_data = create_warehouse(- e2e_staff_api_client,- name="Warehouse 1",- slug="warehouse-1",- address=first_address,- )- warehouse_id = warehouse_data["id"]-- channel_data = create_channel(- e2e_staff_api_client,- warehouse_ids=[warehouse_id],- )- channel_id = channel_data["id"]-- first_shipping_zone_data = create_shipping_zone(- e2e_staff_api_client,- warehouse_ids=[warehouse_id],- channel_ids=[channel_id],- )- first_shipping_zone_id = first_shipping_zone_data["id"]-- first_shipping_method_data = create_shipping_method(- e2e_staff_api_client,- first_shipping_zone_id,- name="First shipping method",- type="PRICE",- )- first_shipping_method_id = first_shipping_method_data["id"]-- create_shipping_method_channel_listing(- e2e_staff_api_client,- first_shipping_method_id,- channel_id,- )-- second_shipping_zone_data = create_shipping_zone(- e2e_staff_api_client,- name="second shipping zone",- countries="PL",- warehouse_ids=[warehouse_id],- channel_ids=[channel_id],- )- second_shipping_zone_id = second_shipping_zone_data["id"]-- second_shipping_method_data = create_shipping_method(- e2e_staff_api_client,- second_shipping_zone_id,- name="Second shipping method",- type="PRICE",- )- second_shipping_method_id = second_shipping_method_data["id"]-- create_shipping_method_channel_listing(- e2e_staff_api_client,- second_shipping_method_id,- channel_id,- )-- return (- warehouse_id,- channel_id,- first_shipping_method_id,- second_shipping_method_id,- )-@pytest.mark.e2edef test_cannot_fullfill_order_with_invalid_shipping_method_core_0203(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,permission_manage_orders,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_orders,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- first_shipping_method_id,- second_shipping_method_id,- ) = prepare_shipping_methods(e2e_staff_api_client)+ channels, _tax_config = prepare_shop(+ e2e_staff_api_client,+ channels=[+ {+ "shipping_zones": [+ {+ "countries": ["US"],+ "shipping_methods": [+ {"name": "us shipping zone", "add_channels": {}}+ ],+ },+ {+ "countries": ["PL"],+ "shipping_methods": [+ {"name": "pl shipping zone", "add_channels": {}}+ ],+ },+ ],+ "order_settings": {},+ }+ ],+ shop_settings={},+ )++ us_shipping_method_id = channels[0]["shipping_zones"][0]["shipping_methods"][0][+ "id"+ ]+ second_shipping_method_id = channels[0]["shipping_zones"][1]["shipping_methods"][0][+ "id"+ ]++ warehouse_id = channels[0]["warehouse_id"]++ channel_id = channels[0]["id"]price = 2+(_product_id,product_variant_id,@@ -160,51 +95,46 @@ def test_cannot_fullfill_order_with_invalid_shipping_method_core_0203(assert order_product_variant_id == product_variant_id# Step 2 - Update order's shipping method- input = {- "shippingMethod": first_shipping_method_id,- "shippingAddress": first_address,- "billingAddress": first_address,- }draft_order = draft_order_update(e2e_staff_api_client,order_id,- input,+ {+ "shippingMethod": us_shipping_method_id,+ "shippingAddress": DEFAULT_ADDRESS,+ "billingAddress": DEFAULT_ADDRESS,+ },)- order_shipping_id = draft_order["order"]["deliveryMethod"]["id"]- first_shipping_id_number = decode_base64_and_get_last_2_chars(- first_shipping_method_id- )- shipping_id_number = decode_base64_and_get_last_2_chars(order_shipping_id)- assert shipping_id_number == first_shipping_id_number+ assert draft_order["order"]["deliveryMethod"]["id"] == us_shipping_method_id# Step 3 - Update order's shipping address for country PL- second_address = {- "firstName": "Jan",- "lastName": "Kowalski",- "phone": "+48123456787",- "companyName": "Saleor PL",- "country": "PL",- "countryArea": "",- "city": "WROCLAW",- "postalCode": "53-346",- "streetAddress1": "Smolna",- "streetAddress2": "13/1",- }- update_input = {"shippingAddress": second_address}draft_update = draft_order_update(e2e_staff_api_client,order_id,- update_input,- )- draft_order_shipping_id = draft_update["order"]["deliveryMethod"]["id"]- assert draft_order_shipping_id == order_shipping_id+ {+ "shippingAddress": {+ "firstName": "Jan",+ "lastName": "Kowalski",+ "phone": "+48123456787",+ "companyName": "Saleor PL",+ "country": "PL",+ "countryArea": "",+ "city": "WROCLAW",+ "postalCode": "53-346",+ "streetAddress1": "Smolna",+ "streetAddress2": "13/1",+ }+ },+ )++ assert draft_update["order"]["deliveryMethod"]["id"] == us_shipping_method_id# Step 4 - Complete the order and check that 2nd shipping method is now availableorder_complete = raw_draft_order_complete(e2e_staff_api_client,order_id,)+assert (order_complete["errors"][0]["message"]== "Shipping method is not valid for chosen shipping address"@@ -213,11 +143,7 @@ def test_cannot_fullfill_order_with_invalid_shipping_method_core_0203(e2e_staff_api_client,order_id,)- order_shipping_method = order_details["availableShippingMethods"][0]["id"]- second_shipping_id_number = decode_base64_and_get_last_2_chars(- second_shipping_method_id- )- order_shipping_method_number = decode_base64_and_get_last_2_chars(- order_shipping_method++ assert (+ order_details["availableShippingMethods"][0]["id"] == second_shipping_method_id)- assert order_shipping_method_number == second_shipping_id_numberdiff --git a/saleor/tests/e2e/orders/test_delete_draft_order.py b/saleor/tests/e2e/orders/test_delete_draft_order.pyindex de5bdadd10..a014e3224e 100644--- a/saleor/tests/e2e/orders/test_delete_draft_order.py+++ b/saleor/tests/e2e/orders/test_delete_draft_order.py@@ -2,7 +2,7 @@ import pytestfrom .. import DEFAULT_ADDRESSfrom ..product.utils.preparing_product import prepare_product-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import (draft_order_create,@@ -16,17 +16,13 @@ from .utils import (@pytest.mark.e2edef test_delete_draft_order_CORE_0205(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,permission_manage_orders,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_orders,]@@ -34,12 +30,10 @@ def test_delete_draft_order_CORE_0205(price = 10- (- warehouse_id,- channel_id,- _channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](_product_id,diff --git a/saleor/tests/e2e/orders/test_expired_order_is_deleted_after_specified_time.py b/saleor/tests/e2e/orders/test_expired_order_is_deleted_after_specified_time.pyindex df9c7027dc..c5177dae00 100644--- a/saleor/tests/e2e/orders/test_expired_order_is_deleted_after_specified_time.py+++ b/saleor/tests/e2e/orders/test_expired_order_is_deleted_after_specified_time.py@@ -5,7 +5,6 @@ from django.utils import timezonefrom freezegun import freeze_timefrom ....order.tasks import delete_expired_orders_task, expire_orders_task-from ..channel.utils import update_channelfrom ..checkout.utils import checkout_create, checkout_delivery_method_updatefrom ..product.utils.preparing_product import prepare_productfrom ..shop.utils.preparing_shop import prepare_shop@@ -17,58 +16,54 @@ from .utils import order_create_from_checkout, order_querydef test_expired_order_is_deleted_after_specified_time_CORE_0216(e2e_staff_api_client,e2e_app_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,permission_manage_orders,permission_manage_payments,permission_handle_checkouts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,- permission_manage_product_types_and_attributes,+ *shop_permissions,permission_manage_orders,+ permission_manage_product_types_and_attributes,]assign_permissions(e2e_staff_api_client, permissions)app_permissions = [permission_manage_payments,permission_handle_checkouts,permission_manage_orders,- permission_manage_channels,+ *shop_permissions,]assign_permissions(e2e_app_api_client, app_permissions)price = 10- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)-- expire_order_after_in_minutes = 1- delete_expired_order_after_in_days = "1"- channel_update_input = {- "orderSettings": {- "allowUnpaidOrders": True,- "automaticallyFulfillNonShippableGiftCard": True,- "automaticallyConfirmAllNewOrders": True,- "expireOrdersAfter": expire_order_after_in_minutes,- "deleteExpiredOrdersAfter": delete_expired_order_after_in_days,- }- }-- update_channel(+ shop_data, _tax_config = prepare_shop(e2e_staff_api_client,- channel_id,- channel_update_input,+ channels=[+ {+ "shipping_zones": [+ {+ "shipping_methods": [{}],+ },+ ],+ "order_settings": {+ "expireOrdersAfter": 1,+ "deleteExpiredOrdersAfter": "1",+ },+ }+ ],+ shop_settings={},)-+ channel_id = shop_data[0]["id"]+ channel_slug = shop_data[0]["slug"]+ warehouse_id = shop_data[0]["warehouse_id"]+ shipping_method_id = shop_data[0]["shipping_zones"][0]["shipping_methods"][0]["id"]+ expire_order_after_in_minutes = shop_data[0]["order_settings"]["expireOrdersAfter"]+ delete_expired_order_after_in_days = shop_data[0]["order_settings"][+ "deleteExpiredOrdersAfter"+ ](_product_id,product_variant_id,@@ -99,7 +94,6 @@ def test_expired_order_is_deleted_after_specified_time_CORE_0216(assert checkout_id is not Noneassert checkout_data["isShippingRequired"] is Trueassert len(checkout_data["shippingMethods"]) == 1- shipping_method_id = checkout_data["shippingMethods"][0]["id"]# Step 2 - Assign shipping methodcheckout_data = checkout_delivery_method_update(diff --git a/saleor/tests/e2e/orders/test_order_cancel_fulfillment.py b/saleor/tests/e2e/orders/test_order_cancel_fulfillment.pyindex 3343c3b3e4..ddd602be97 100644--- a/saleor/tests/e2e/orders/test_order_cancel_fulfillment.py+++ b/saleor/tests/e2e/orders/test_order_cancel_fulfillment.py@@ -2,7 +2,7 @@ import pytestfrom .. import DEFAULT_ADDRESSfrom ..product.utils.preparing_product import prepare_product-from ..shop.utils import prepare_shop, update_shop_settings+from ..shop.utils import prepare_shopfrom ..utils import assign_permissionsfrom .utils import (draft_order_complete,@@ -18,15 +18,27 @@ from .utils import (def prepare_order(e2e_staff_api_client):price = 10- (- warehouse_id,- channel_id,- _channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)- data = {"fulfillmentAutoApprove": True, "fulfillmentAllowUnpaid": False}- update_shop_settings(e2e_staff_api_client, data)+ shop_data, _tax_config = prepare_shop(+ e2e_staff_api_client,+ channels=[+ {+ "shipping_zones": [+ {+ "shipping_methods": [{}],+ },+ ],+ "order_settings": {},+ }+ ],+ shop_settings={+ "fulfillmentAutoApprove": True,+ "fulfillmentAllowUnpaid": False,+ },+ )+ channel_id = shop_data[0]["id"]+ warehouse_id = shop_data[0]["warehouse_id"]+ shipping_method_id = shop_data[0]["shipping_zones"][0]["shipping_methods"][0]["id"]_product_id, product_variant_id, _product_variant_price = prepare_product(e2e_staff_api_client,@@ -78,30 +90,25 @@ def prepare_order(e2e_staff_api_client):@pytest.mark.e2edef test_order_cancel_fulfillment_CORE_0220(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,permission_manage_orders,- permission_manage_settings,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_orders,- permission_manage_settings,]assign_permissions(e2e_staff_api_client, permissions)-(order_id,product_variant_id,warehouse_id,order_line_id,- ) = prepare_order(e2e_staff_api_client)+ ) = prepare_order(+ e2e_staff_api_client,+ )# Step 1 - Complete the orderorder = draft_order_complete(diff --git a/saleor/tests/e2e/orders/test_order_create_invoice_with_metadata.py b/saleor/tests/e2e/orders/test_order_create_invoice_with_metadata.pyindex c5541484a1..ecba681cc7 100644--- a/saleor/tests/e2e/orders/test_order_create_invoice_with_metadata.py+++ b/saleor/tests/e2e/orders/test_order_create_invoice_with_metadata.py@@ -2,7 +2,7 @@ import pytestfrom .. import DEFAULT_ADDRESSfrom ..product.utils.preparing_product import prepare_product-from ..shop.utils import prepare_shop, update_shop_settings+from ..shop.utils import prepare_shopfrom ..utils import assign_permissionsfrom .utils import (draft_order_complete,@@ -18,15 +18,26 @@ from .utils import (def prepare_fulfilled_order(e2e_staff_api_client):price = 10- (- warehouse_id,- channel_id,- _channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)- data = {"fulfillmentAutoApprove": True, "fulfillmentAllowUnpaid": False}- update_shop_settings(e2e_staff_api_client, data)+ shop_data, _tax_config = prepare_shop(+ e2e_staff_api_client,+ channels=[+ {+ "shipping_zones": [+ {+ "shipping_methods": [{}],+ },+ ],+ "order_settings": {},+ }+ ],+ shop_settings={+ "fulfillmentAutoApprove": True,+ },+ )+ channel_id = shop_data[0]["id"]+ warehouse_id = shop_data[0]["warehouse_id"]+ shipping_method_id = shop_data[0]["shipping_zones"][0]["shipping_methods"][0]["id"]_product_id, product_variant_id, _product_variant_price = prepare_product(e2e_staff_api_client,@@ -99,21 +110,15 @@ def prepare_fulfilled_order(e2e_staff_api_client):@pytest.mark.e2edef test_order_create_invoice_with_metadata_CORE_0212(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,permission_manage_orders,- permission_manage_settings,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_orders,- permission_manage_settings,]assign_permissions(e2e_staff_api_client, permissions)diff --git a/saleor/tests/e2e/orders/test_order_created_by_staff_member.py b/saleor/tests/e2e/orders/test_order_created_by_staff_member.pyindex 98642eca90..8334e392f7 100644--- a/saleor/tests/e2e/orders/test_order_created_by_staff_member.py+++ b/saleor/tests/e2e/orders/test_order_created_by_staff_member.py@@ -6,24 +6,20 @@ from ..orders.utils.draft_order_create import draft_order_createfrom ..orders.utils.draft_order_update import draft_order_updatefrom ..orders.utils.order_lines_create import order_lines_createfrom ..product.utils.preparing_product import prepare_product-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissions@pytest.mark.e2edef test_order_created_by_staff_member_CORE_0201(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,permission_manage_orders,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_orders,]@@ -31,12 +27,10 @@ def test_order_created_by_staff_member_CORE_0201(price = 10- (- warehouse_id,- channel_id,- _channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](_product_id,diff --git a/saleor/tests/e2e/orders/test_order_fulfill_and_add_tracking.py b/saleor/tests/e2e/orders/test_order_fulfill_and_add_tracking.pyindex f906756570..3f29a692dd 100644--- a/saleor/tests/e2e/orders/test_order_fulfill_and_add_tracking.py+++ b/saleor/tests/e2e/orders/test_order_fulfill_and_add_tracking.py@@ -2,7 +2,7 @@ import pytestfrom .. import DEFAULT_ADDRESSfrom ..product.utils.preparing_product import prepare_product-from ..shop.utils import prepare_shop, update_shop_settings+from ..shop.utils import prepare_shopfrom ..utils import assign_permissionsfrom .utils import (draft_order_complete,@@ -18,15 +18,27 @@ from .utils import (def prepare_order(e2e_staff_api_client):price = 10- (- warehouse_id,- channel_id,- _channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)- data = {"fulfillmentAutoApprove": True, "fulfillmentAllowUnpaid": False}- update_shop_settings(e2e_staff_api_client, data)+ shop_data, _tax_config = prepare_shop(+ e2e_staff_api_client,+ channels=[+ {+ "shipping_zones": [+ {+ "shipping_methods": [{}],+ },+ ],+ "order_settings": {},+ }+ ],+ shop_settings={+ "fulfillmentAutoApprove": True,+ "fulfillmentAllowUnpaid": False,+ },+ )+ channel_id = shop_data[0]["id"]+ warehouse_id = shop_data[0]["warehouse_id"]+ shipping_method_id = shop_data[0]["shipping_zones"][0]["shipping_methods"][0]["id"]_product_id, product_variant_id, _product_variant_price = prepare_product(e2e_staff_api_client,@@ -78,21 +90,15 @@ def prepare_order(e2e_staff_api_client):@pytest.mark.e2edef test_order_fulfill_and_add_tracking_CORE_0219(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,permission_manage_orders,- permission_manage_settings,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_orders,- permission_manage_settings,]assign_permissions(e2e_staff_api_client, permissions)diff --git a/saleor/tests/e2e/orders/test_order_in_channel_with_transaction_flow_as_mark_as_paid_strategy.py b/saleor/tests/e2e/orders/test_order_in_channel_with_transaction_flow_as_mark_as_paid_strategy.pyindex 398ddac704..8813751601 100644--- a/saleor/tests/e2e/orders/test_order_in_channel_with_transaction_flow_as_mark_as_paid_strategy.py+++ b/saleor/tests/e2e/orders/test_order_in_channel_with_transaction_flow_as_mark_as_paid_strategy.py@@ -1,15 +1,9 @@import pytestfrom .. import DEFAULT_ADDRESS-from ..channel.utils import create_channelfrom ..product.utils.preparing_product import prepare_product-from ..shipping_zone.utils import (- create_shipping_method,- create_shipping_method_channel_listing,- create_shipping_zone,-)+from ..shop.utils import prepare_shopfrom ..utils import assign_permissions-from ..warehouse.utils import create_warehousefrom .utils import (draft_order_complete,draft_order_create,@@ -20,63 +14,18 @@ from .utils import ()-def prepare_shop_in_channel_with_transaction_flow_as_mark_as_paid_strategy(- e2e_staff_api_client,-):- 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,- warehouse_ids=[warehouse_ids],- mark_as_paid_strategy="TRANSACTION_FLOW",- )- channel_id = channel_data["id"]-- shipping_zone_data = create_shipping_zone(- e2e_staff_api_client,- warehouse_ids=[warehouse_id],- channel_ids=[channel_id],- )- shipping_zone_id = shipping_zone_data["id"]-- shipping_method_data = create_shipping_method(- e2e_staff_api_client,- shipping_zone_id,- type="PRICE",- )- 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,- shipping_method_id,- )--@pytest.mark.e2edef test_order_in_channel_with_transaction_flow_as_mark_as_paid_strategy_CORE_0209(e2e_staff_api_client,e2e_app_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,permission_manage_orders,permission_manage_payments,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_orders,permission_manage_payments,@@ -85,13 +34,25 @@ def test_order_in_channel_with_transaction_flow_as_mark_as_paid_strategy_CORE_02app_permissions = [permission_manage_payments]assign_permissions(e2e_app_api_client, app_permissions)- (- warehouse_id,- channel_id,- shipping_method_id,- ) = prepare_shop_in_channel_with_transaction_flow_as_mark_as_paid_strategy(- e2e_staff_api_client+ shop_data, _tax_config = prepare_shop(+ e2e_staff_api_client,+ channels=[+ {+ "shipping_zones": [+ {+ "shipping_methods": [{}],+ },+ ],+ "order_settings": {"markAsPaidStrategy": "TRANSACTION_FLOW"},+ }+ ],+ shop_settings={+ "fulfillmentAutoApprove": True,+ },)+ channel_id = shop_data[0]["id"]+ warehouse_id = shop_data[0]["warehouse_id"]+ shipping_method_id = shop_data[0]["shipping_zones"][0]["shipping_methods"][0]["id"]price = 2(diff --git a/saleor/tests/e2e/orders/test_order_is_expired_after_specific_time.py b/saleor/tests/e2e/orders/test_order_is_expired_after_specific_time.pyindex 77265e4353..2bc0ac72db 100644--- a/saleor/tests/e2e/orders/test_order_is_expired_after_specific_time.py+++ b/saleor/tests/e2e/orders/test_order_is_expired_after_specific_time.py@@ -5,7 +5,6 @@ from django.utils import timezonefrom freezegun import freeze_timefrom ....order.tasks import expire_orders_task-from ..channel.utils import update_channelfrom ..checkout.utils import checkout_create, checkout_delivery_method_updatefrom ..product.utils.preparing_product import prepare_productfrom ..shop.utils.preparing_shop import prepare_shop@@ -17,19 +16,16 @@ from .utils import order_create_from_checkout, order_querydef test_order_is_expired_after_specific_time_CORE_0214(e2e_staff_api_client,e2e_app_api_client,- permission_manage_products,permission_manage_channels,permission_manage_product_types_and_attributes,- permission_manage_shipping,permission_manage_orders,permission_manage_payments,permission_handle_checkouts,+ shop_permissions,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_orders,]@@ -44,28 +40,27 @@ def test_order_is_expired_after_specific_time_CORE_0214(price = 10- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)-- expire_order_after_in_minutes = 1- channel_update_input = {- "orderSettings": {- "allowUnpaidOrders": True,- "automaticallyFulfillNonShippableGiftCard": True,- "automaticallyConfirmAllNewOrders": True,- "expireOrdersAfter": expire_order_after_in_minutes,- }- }-- update_channel(+ shop_data, _tax_config = prepare_shop(e2e_staff_api_client,- channel_id,- channel_update_input,+ channels=[+ {+ "shipping_zones": [+ {+ "shipping_methods": [{}],+ },+ ],+ "order_settings": {+ "expireOrdersAfter": 1,+ },+ }+ ],+ shop_settings={},)+ channel_id = shop_data[0]["id"]+ channel_slug = shop_data[0]["slug"]+ warehouse_id = shop_data[0]["warehouse_id"]+ shipping_method_id = shop_data[0]["shipping_zones"][0]["shipping_methods"][0]["id"]+ expire_order_after_in_minutes = shop_data[0]["order_settings"]["expireOrdersAfter"](_product_id,@@ -97,7 +92,6 @@ def test_order_is_expired_after_specific_time_CORE_0214(assert checkout_id is not Noneassert checkout_data["isShippingRequired"] is Trueassert len(checkout_data["shippingMethods"]) == 1- shipping_method_id = checkout_data["shippingMethods"][0]["id"]# Step 2 - Assign shipping methodcheckout_data = checkout_delivery_method_update(diff --git a/saleor/tests/e2e/orders/test_order_mark_as_paid.py b/saleor/tests/e2e/orders/test_order_mark_as_paid.pyindex a5db14cfd6..7c4d428190 100644--- a/saleor/tests/e2e/orders/test_order_mark_as_paid.py+++ b/saleor/tests/e2e/orders/test_order_mark_as_paid.py@@ -2,7 +2,7 @@ import pytestfrom .. import DEFAULT_ADDRESSfrom ..product.utils.preparing_product import prepare_product-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import (draft_order_complete,@@ -16,17 +16,13 @@ from .utils import (@pytest.mark.e2edef test_order_mark_as_paid_CORE_0208(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,permission_manage_orders,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_orders,]@@ -34,12 +30,10 @@ def test_order_mark_as_paid_CORE_0208(price = 10- (- warehouse_id,- channel_id,- _channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"]_product_id, product_variant_id, _product_variant_price = prepare_product(e2e_staff_api_client,diff --git a/saleor/tests/e2e/orders/test_order_staff_can_create_order_with_the_same_variant_in_multiple_lines_and_overwrite_prices.py b/saleor/tests/e2e/orders/test_order_staff_can_create_order_with_the_same_variant_in_multiple_lines_and_overwrite_prices.pyindex 0a4c598972..efbff79061 100644--- a/saleor/tests/e2e/orders/test_order_staff_can_create_order_with_the_same_variant_in_multiple_lines_and_overwrite_prices.py+++ b/saleor/tests/e2e/orders/test_order_staff_can_create_order_with_the_same_variant_in_multiple_lines_and_overwrite_prices.py@@ -2,7 +2,7 @@ import pytestfrom .. import DEFAULT_ADDRESSfrom ..product.utils.preparing_product import prepare_product-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import (draft_order_complete,@@ -15,28 +15,22 @@ from .utils import (@pytest.mark.e2edef test_order_with_the_same_variant_in_multiple_lines_and_overwrite_prices_core_0213(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,permission_manage_orders,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_orders,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- _channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](_product_id,diff --git a/saleor/tests/e2e/orders/test_order_staff_can_overwrite_prices.py b/saleor/tests/e2e/orders/test_order_staff_can_overwrite_prices.pyindex 78536f796a..ec692d14e7 100644--- a/saleor/tests/e2e/orders/test_order_staff_can_overwrite_prices.py+++ b/saleor/tests/e2e/orders/test_order_staff_can_overwrite_prices.py@@ -2,7 +2,7 @@ import pytestfrom .. import DEFAULT_ADDRESSfrom ..product.utils.preparing_product import prepare_product-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils.draft_order_complete import draft_order_completefrom .utils.draft_order_create import draft_order_create@@ -13,17 +13,13 @@ from .utils.order_lines_create import order_lines_create@pytest.mark.e2edef test_order_staff_can_overwrite_prices_CORE_0202(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,permission_manage_orders,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_orders,]@@ -31,12 +27,10 @@ def test_order_staff_can_overwrite_prices_CORE_0202(regular_variant_price = 10- (- warehouse_id,- channel_id,- _channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](_product_id,diff --git a/saleor/tests/e2e/orders/test_order_void_once_voided_payment.py b/saleor/tests/e2e/orders/test_order_void_once_voided_payment.pyindex 037750685a..0c6044b62a 100644--- a/saleor/tests/e2e/orders/test_order_void_once_voided_payment.py+++ b/saleor/tests/e2e/orders/test_order_void_once_voided_payment.py@@ -7,23 +7,19 @@ from ..checkout.utils import (raw_checkout_dummy_payment_create,)from ..product.utils.preparing_product import prepare_product-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import order_query, order_void, raw_order_void-def prepare_checkout_with_voided_payment(- e2e_staff_api_client,- e2e_app_api_client,-):+def prepare_checkout_with_voided_payment(e2e_staff_api_client):price = 10- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](_product_id,@@ -51,7 +47,6 @@ def prepare_checkout_with_voided_payment(set_default_shipping_address=True,)checkout_id = checkout_data["id"]- shipping_method_id = checkout_data["shippingMethods"][0]["id"]checkout_data = checkout_delivery_method_update(e2e_staff_api_client,@@ -85,19 +80,16 @@ def prepare_checkout_with_voided_payment(def test_checkout_void_once_voided_payment_CORE_0218(e2e_staff_api_client,e2e_app_api_client,- permission_manage_products,+ shop_permissions,permission_manage_channels,permission_manage_product_types_and_attributes,- permission_manage_shipping,permission_manage_orders,permission_manage_payments,permission_handle_checkouts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_orders,]@@ -112,7 +104,6 @@ def test_checkout_void_once_voided_payment_CORE_0218(order_id = prepare_checkout_with_voided_payment(e2e_staff_api_client,- e2e_app_api_client,)# Step 1 - Check the order's payment is voideddiff --git a/saleor/tests/e2e/orders/test_order_void_payment.py b/saleor/tests/e2e/orders/test_order_void_payment.pyindex 812d1f007f..e927992120 100644--- a/saleor/tests/e2e/orders/test_order_void_payment.py+++ b/saleor/tests/e2e/orders/test_order_void_payment.py@@ -7,7 +7,7 @@ from ..checkout.utils import (raw_checkout_dummy_payment_create,)from ..product.utils.preparing_product import prepare_product-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import order_void@@ -16,19 +16,15 @@ from .utils import order_voiddef test_checkout_void_payment_CORE_0217(e2e_staff_api_client,e2e_app_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,permission_manage_orders,permission_manage_payments,permission_handle_checkouts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_orders,]@@ -37,18 +33,17 @@ def test_checkout_void_payment_CORE_0217(permission_manage_payments,permission_handle_checkouts,permission_manage_orders,- permission_manage_channels,+ *shop_permissions,]assign_permissions(e2e_app_api_client, app_permissions)price = 10- (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](_product_id,@@ -81,7 +76,6 @@ def test_checkout_void_payment_CORE_0217(assert checkout_id is not Noneassert checkout_data["isShippingRequired"] is Trueassert len(checkout_data["shippingMethods"]) == 1- shipping_method_id = checkout_data["shippingMethods"][0]["id"]# Step 2 - Assign shipping methodcheckout_data = checkout_delivery_method_update(diff --git a/saleor/tests/e2e/orders/test_unable_to_void_order_marked_as_paid.py b/saleor/tests/e2e/orders/test_unable_to_void_order_marked_as_paid.pyindex 9ac360ad2d..5e13a0d64f 100644--- a/saleor/tests/e2e/orders/test_unable_to_void_order_marked_as_paid.py+++ b/saleor/tests/e2e/orders/test_unable_to_void_order_marked_as_paid.py@@ -2,7 +2,7 @@ import pytestfrom .. import DEFAULT_ADDRESSfrom ..product.utils.preparing_product import prepare_product-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import (draft_order_complete,@@ -18,12 +18,10 @@ from .utils import (def prepare_order_marked_as_paid(e2e_staff_api_client):price = 10- (- warehouse_id,- channel_id,- _channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"]_product_id, product_variant_id, _product_variant_price = prepare_product(e2e_staff_api_client,@@ -80,17 +78,13 @@ def prepare_order_marked_as_paid(e2e_staff_api_client):@pytest.mark.e2edef test_unable_to_void_order_marked_as_paid_CORE_0211(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,permission_manage_orders,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_orders,]diff --git a/saleor/tests/e2e/orders/test_unable_to_void_order_without_payment.py b/saleor/tests/e2e/orders/test_unable_to_void_order_without_payment.pyindex d126dd54bf..45f70f5fb0 100644--- a/saleor/tests/e2e/orders/test_unable_to_void_order_without_payment.py+++ b/saleor/tests/e2e/orders/test_unable_to_void_order_without_payment.py@@ -2,7 +2,7 @@ import pytestfrom .. import DEFAULT_ADDRESSfrom ..product.utils.preparing_product import prepare_product-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import (draft_order_complete,@@ -16,17 +16,13 @@ from .utils import (@pytest.mark.e2edef test_unable_to_void_order_without_payment_CORE_0210(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,permission_manage_orders,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_orders,]@@ -34,12 +30,10 @@ def test_unable_to_void_order_without_payment_CORE_0210(price = 10- (- warehouse_id,- channel_id,- _channel_slug,- shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ warehouse_id = shop_data["warehouse"]["id"]+ shipping_method_id = shop_data["shipping_method"]["id"](_product_id,diff --git a/saleor/tests/e2e/orders/utils/draft_order_update.py b/saleor/tests/e2e/orders/utils/draft_order_update.pyindex 6f1cecb36e..a4a2e33286 100644--- a/saleor/tests/e2e/orders/utils/draft_order_update.py+++ b/saleor/tests/e2e/orders/utils/draft_order_update.py@@ -15,6 +15,9 @@ mutation DraftOrderUpdate($input: DraftOrderInput!, $id: ID!) {gross {amount}+ tax {+ amount+ }}unitPrice {gross {diff --git a/saleor/tests/e2e/pages/test_create_page_with_all_attributes_types.py b/saleor/tests/e2e/pages/test_create_page_with_all_attributes_types.pyindex 3f3fa78d86..e2a27b33d0 100644--- a/saleor/tests/e2e/pages/test_create_page_with_all_attributes_types.py+++ b/saleor/tests/e2e/pages/test_create_page_with_all_attributes_types.py@@ -9,7 +9,7 @@ from ....tests.utils import dummy_editorjsfrom ..attributes.utils import prepare_all_attributesfrom ..pages.utils import create_page, create_page_typefrom ..product.utils.preparing_product import prepare_product-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissions@@ -18,9 +18,7 @@ def test_create_page_with_each_of_attribute_types_core_0701(e2e_staff_api_client,permission_manage_page_types_and_attributes,permission_manage_pages,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,site_settings,):@@ -28,19 +26,14 @@ def test_create_page_with_each_of_attribute_types_core_0701(permissions = [permission_manage_page_types_and_attributes,permission_manage_pages,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,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)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ warehouse_id = shop_data["warehouse"]["id"](product_id,diff --git a/saleor/tests/e2e/product/test_create_simple_product.py b/saleor/tests/e2e/product/test_create_simple_product.pyindex d05aecdfe0..51bd8bba06 100644--- a/saleor/tests/e2e/product/test_create_simple_product.py+++ b/saleor/tests/e2e/product/test_create_simple_product.py@@ -1,7 +1,7 @@import pytestfrom ..attributes.utils import attribute_create-from ..shop.utils import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import (create_category,@@ -39,25 +39,19 @@ def prepare_attributes_and_product_type(e2e_staff_api_client):def test_should_create_simple_product_core_0302(e2e_staff_api_client,permission_manage_product_types_and_attributes,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,):# Beforepermissions = [permission_manage_product_types_and_attributes,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- _shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"](attribute_product_id,diff --git a/saleor/tests/e2e/product/test_product_no_longer_on_promotion_when_promotion_is_removed.py b/saleor/tests/e2e/product/test_product_no_longer_on_promotion_when_promotion_is_removed.pyindex ee83bff3b1..b3f25be241 100644--- a/saleor/tests/e2e/product/test_product_no_longer_on_promotion_when_promotion_is_removed.py+++ b/saleor/tests/e2e/product/test_product_no_longer_on_promotion_when_promotion_is_removed.py@@ -6,7 +6,7 @@ from ..promotions.utils import (delete_promotion,promotion_query,)-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils.preparing_product import prepare_productfrom .utils.product_query import get_product@@ -15,37 +15,31 @@ from .utils.product_query import get_product@pytest.mark.e2edef test_product_no_longer_on_promotion_when_promotion_is_removed_CORE_2114(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_orders,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_orders,]assign_permissions(e2e_staff_api_client, permissions)- (- result_warehouse_id,- result_channel_id,- result_channel_slug,- _,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"](product_id,product_variant_id,- product_variant_price,+ _product_variant_price,) = prepare_product(- e2e_staff_api_client, result_warehouse_id, result_channel_id, variant_price=20+ e2e_staff_api_client, warehouse_id, channel_id, variant_price=20)promotion_name = "Promotion Fixed"discount_value = 5@@ -63,14 +57,14 @@ def test_product_no_longer_on_promotion_when_promotion_is_removed_CORE_2114(discount_type,discount_value,promotion_rule_name,- result_channel_id,+ channel_id,)product_predicate = promotion_rule["cataloguePredicate"]["productPredicate"]["ids"]- assert promotion_rule["channels"][0]["id"] == result_channel_id+ assert promotion_rule["channels"][0]["id"] == channel_idassert product_predicate[0] == product_id# Step 1 - Check product is on promotion- product_data = get_product(e2e_staff_api_client, product_id, result_channel_slug)+ product_data = get_product(e2e_staff_api_client, product_id, channel_slug)assert product_data["id"] == product_idassert product_data["pricing"]["onSale"] is Truevariant_data = product_data["variants"][0]@@ -84,7 +78,7 @@ def test_product_no_longer_on_promotion_when_promotion_is_removed_CORE_2114(assert data["promotion"] is None# Step 3 - Check product in no longer on promotion- product_data = get_product(e2e_staff_api_client, product_id, result_channel_slug)+ product_data = get_product(e2e_staff_api_client, product_id, channel_slug)assert product_data["id"] == product_idassert product_data["pricing"]["onSale"] is Falsevariant_data = product_data["variants"][0]diff --git a/saleor/tests/e2e/product/test_should_create_variants_in_bulk.py b/saleor/tests/e2e/product/test_should_create_variants_in_bulk.pyindex 0dcfd5e158..d88856b753 100644--- a/saleor/tests/e2e/product/test_should_create_variants_in_bulk.py+++ b/saleor/tests/e2e/product/test_should_create_variants_in_bulk.py@@ -1,7 +1,7 @@import pytestfrom ..attributes.utils import attribute_create-from ..shop.utils import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import (create_category,@@ -63,25 +63,19 @@ def prepare_attributes_and_product_type(e2e_staff_api_client):def test_should_create_product_with_few_variants_core_0301(e2e_staff_api_client,permission_manage_product_types_and_attributes,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,):# Beforepermissions = [permission_manage_product_types_and_attributes,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- channel_slug,- _shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"](attribute_product_id,diff --git a/saleor/tests/e2e/promotions/test_sale_updated_by_promotion_can_not_be_handled_by_sales.py b/saleor/tests/e2e/promotions/test_sale_updated_by_promotion_can_not_be_handled_by_sales.pyindex 1017a2d497..f1628d6fbd 100644--- a/saleor/tests/e2e/promotions/test_sale_updated_by_promotion_can_not_be_handled_by_sales.py+++ b/saleor/tests/e2e/promotions/test_sale_updated_by_promotion_can_not_be_handled_by_sales.py@@ -8,7 +8,7 @@ from ..sales.utils import (raw_create_sale_channel_listing,sale_catalogues_add,)-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissions@@ -50,28 +50,21 @@ def prepare_sale_for_product(@pytest.mark.e2edef test_sale_updated_by_promotion_can_not_be_handled_by_sales_core_2116(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,]assign_permissions(e2e_staff_api_client, permissions)- (- warehouse_id,- channel_id,- _channel_slug,- _shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ warehouse_id = shop_data["warehouse"]["id"](product_id,diff --git a/saleor/tests/e2e/promotions/test_staff_can_change_catalog_predicate.py b/saleor/tests/e2e/promotions/test_staff_can_change_catalog_predicate.pyindex e622770652..14287a1db3 100644--- a/saleor/tests/e2e/promotions/test_staff_can_change_catalog_predicate.py+++ b/saleor/tests/e2e/promotions/test_staff_can_change_catalog_predicate.py@@ -14,7 +14,7 @@ from ..promotions.utils import (create_promotion_rule,update_promotion_rule,)-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissions@@ -49,23 +49,22 @@ def prepare_promotion(@pytest.mark.e2edef test_staff_can_change_catalogue_predicate_core_2112(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,- permission_manage_shipping,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,- permission_manage_shipping,]assign_permissions(e2e_staff_api_client, permissions)- warehouse_id, channel_id, channel_slug, _ = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]product_id, product_variant_id, _ = prepare_product(e2e_staff_api_client, warehouse_id, channel_id, "7.99"diff --git a/saleor/tests/e2e/promotions/test_staff_can_change_channel_in_promotion_rule.py b/saleor/tests/e2e/promotions/test_staff_can_change_channel_in_promotion_rule.pyindex f030e6afc4..58e4559baa 100644--- a/saleor/tests/e2e/promotions/test_staff_can_change_channel_in_promotion_rule.py+++ b/saleor/tests/e2e/promotions/test_staff_can_change_channel_in_promotion_rule.py@@ -1,6 +1,5 @@import pytest-from ..channel.utils import create_channelfrom ..product.utils import (get_product,raw_create_product_channel_listing,@@ -43,64 +42,94 @@ def prepare_promotion(return promotion_rule_id-def prepare_second_channel_and_listing(- e2e_staff_api_client, warehouse_id, product_id, product_variant_id-):- second_channel_slug = "channel_pln"- channel_data = create_channel(+def prepare_channels_with_product(e2e_staff_api_client):+ shop_data, _tax_config = prepare_shop(e2e_staff_api_client,- warehouse_ids=[warehouse_id],- slug=second_channel_slug,+ channels=[+ {+ "shipping_zones": [+ {+ "countries": ["US"],+ "name": "us shipping zone",+ "shipping_methods": [{}],+ },+ ],+ "order_settings": {},+ },+ {+ "shipping_zones": [+ {+ "countries": ["PL"],+ "name": "pl shipping zone",+ "shipping_methods": [{}],+ },+ ],+ "order_settings": {},+ },+ ],+ shop_settings={},+ )+ us_channel_id = shop_data[0]["id"]+ us_channel_slug = shop_data[0]["slug"]+ pl_channel_id = shop_data[1]["id"]+ pl_channel_slug = shop_data[1]["slug"]+ warehouse_id = shop_data[0]["warehouse_id"]++ product_id, product_variant_id, _ = prepare_product(+ e2e_staff_api_client, warehouse_id, us_channel_id, "7.99")- second_channel_id = channel_data["id"]product_listing_data = raw_create_product_channel_listing(e2e_staff_api_client,product_id,- second_channel_id,+ pl_channel_id,is_published=True,visible_in_listings=True,is_available_for_purchase=True,)assert (product_listing_data["product"]["channelListings"][1]["channel"]["id"]- == second_channel_id+ == pl_channel_id)variant_listing_data = raw_create_product_variant_channel_listing(- e2e_staff_api_client, product_variant_id, second_channel_id, price="99"+ e2e_staff_api_client, product_variant_id, pl_channel_id, price="99")assert (variant_listing_data["variant"]["channelListings"][1]["channel"]["id"]- == second_channel_id+ == pl_channel_id+ )+ return (+ us_channel_id,+ us_channel_slug,+ pl_channel_id,+ pl_channel_slug,+ product_id,)- return second_channel_id, second_channel_slug@pytest.mark.e2edef test_staff_can_change_promotion_rule_channel_core_2113(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,- permission_manage_shipping,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,- permission_manage_shipping,]assign_permissions(e2e_staff_api_client, permissions)- warehouse_id, channel_id, channel_slug, _ = prepare_shop(e2e_staff_api_client)-- product_id, product_variant_id, _ = prepare_product(- e2e_staff_api_client, warehouse_id, channel_id, "7.99"- )+ (+ us_channel_id,+ us_channel_slug,+ pl_channel_id,+ pl_channel_slug,+ product_id,+ ) = prepare_channels_with_product(e2e_staff_api_client)predicate_input = {"productPredicate": {"ids": [product_id]}}promotion_rule_id = prepare_promotion(@@ -108,30 +137,30 @@ def test_staff_can_change_promotion_rule_channel_core_2113(50,"PERCENTAGE",predicate_input,- channel_id=[channel_id],- )- second_channel_id, second_channel_slug = prepare_second_channel_and_listing(- e2e_staff_api_client, warehouse_id, product_id, product_variant_id+ channel_id=[us_channel_id],)+# Step 1 Update promotion rule: switch channelsupdate_promotion_rule(e2e_staff_api_client,promotion_rule_id,input={- "addChannels": [second_channel_id],- "removeChannels": [channel_id],+ "addChannels": [pl_channel_id],+ "removeChannels": [us_channel_id],"cataloguePredicate": predicate_input,},)# Step 2 Check if promotion is applied for product on second channelproduct_data_channel_2 = get_product(- e2e_staff_api_client, product_id, second_channel_slug+ e2e_staff_api_client, product_id, pl_channel_slug)assert product_data_channel_2["pricing"]["onSale"] is Truevariant = product_data_channel_2["variants"][0]assert variant["pricing"]["discount"]["gross"]["amount"] == 49.5# Step 3 Check if promotion is not applied for product on first channel- product_data_channel_1 = get_product(e2e_staff_api_client, product_id, channel_slug)+ product_data_channel_1 = get_product(+ e2e_staff_api_client, product_id, us_channel_slug+ )assert product_data_channel_1["pricing"]["onSale"] is Falsediff --git a/saleor/tests/e2e/promotions/test_staff_can_change_reward_value_type_in_promotion_rule.py b/saleor/tests/e2e/promotions/test_staff_can_change_reward_value_type_in_promotion_rule.pyindex 949a69096b..f049ad152f 100644--- a/saleor/tests/e2e/promotions/test_staff_can_change_reward_value_type_in_promotion_rule.py+++ b/saleor/tests/e2e/promotions/test_staff_can_change_reward_value_type_in_promotion_rule.py@@ -2,7 +2,7 @@ import pytestfrom ..product.utils import get_productfrom ..product.utils.preparing_product import prepare_product-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import create_promotion, create_promotion_rule, update_promotion_rule@@ -38,25 +38,22 @@ def prepare_promotion(@pytest.mark.e2edef test_staff_can_change_reward_value_type_in_promotion_rule_core_2117(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,- permission_manage_shipping,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,- permission_manage_shipping,]assign_permissions(e2e_staff_api_client, permissions)- warehouse_id, channel_id, channel_slug, _shipping_method_id = prepare_shop(- e2e_staff_api_client- )+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"]product_id, product_variant_id, product_variant_price = prepare_product(e2e_staff_api_client, warehouse_id, channel_id, "14.99"diff --git a/saleor/tests/e2e/promotions/test_staff_can_create_promotion_for_collections.py b/saleor/tests/e2e/promotions/test_staff_can_create_promotion_for_collections.pyindex 8a62d7eec5..22f16ecfd5 100644--- a/saleor/tests/e2e/promotions/test_staff_can_create_promotion_for_collections.py+++ b/saleor/tests/e2e/promotions/test_staff_can_create_promotion_for_collections.py@@ -1,6 +1,5 @@import pytest-from ..channel.utils import create_channelfrom ..product.utils import (create_category,create_collection,@@ -13,31 +12,17 @@ from ..product.utils import (get_product,)from ..promotions.utils import create_promotion, create_promotion_rule+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsdef prepare_product(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,- permission_manage_product_types_and_attributes,- permission_manage_discounts,- channel_slug,variant_price,):- permissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_product_types_and_attributes,- permission_manage_discounts,- ]- assign_permissions(e2e_staff_api_client, permissions)-- channel_data = create_channel(- e2e_staff_api_client,- slug=channel_slug,- )- channel_id = channel_data["id"]+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]product_type_data = create_product_type(e2e_staff_api_client,@@ -76,27 +61,31 @@ def prepare_product(variant_price,)- return product_id, channel_id, collection_id+ return product_id, channel_id, channel_slug, collection_id@pytest.mark.e2edef test_create_promotion_for_collection_core_2109(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,):# Before- channel_slug = "promotion_collections_channel"- variant_price = "9.99"- product_id, channel_id, collection_id = prepare_product(- e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,+ permissions = [+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,+ ]+ assign_permissions(e2e_staff_api_client, permissions)+ variant_price = "9.99"+ (+ product_id,+ channel_id,channel_slug,+ collection_id,+ ) = prepare_product(+ e2e_staff_api_client,variant_price,)diff --git a/saleor/tests/e2e/promotions/test_staff_can_translate_promotions.py b/saleor/tests/e2e/promotions/test_staff_can_translate_promotions.pyindex 917fda890c..939c12609e 100644--- a/saleor/tests/e2e/promotions/test_staff_can_translate_promotions.py+++ b/saleor/tests/e2e/promotions/test_staff_can_translate_promotions.py@@ -9,7 +9,7 @@ from ..promotions.utils import (translate_promotion,translate_promotion_rule,)-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..translations.utils import get_translationsfrom ..utils import assign_permissions@@ -56,24 +56,23 @@ def prepare_promotion(@pytest.mark.e2edef test_staff_translate_promotions_core_2119(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,- permission_manage_shipping,permission_manage_translations,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,- permission_manage_shipping,permission_manage_translations,]assign_permissions(e2e_staff_api_client, permissions)- warehouse_id, channel_id, _channel_slug, _ = prepare_shop(e2e_staff_api_client)++ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ warehouse_id = shop_data["warehouse"]["id"]product_id, _product_variant_id, _ = prepare_product(e2e_staff_api_client, warehouse_id, channel_id, "37.99"diff --git a/saleor/tests/e2e/promotions/test_unable_to_query_nor_mutate_sale_updated_by_promotion_translations.py b/saleor/tests/e2e/promotions/test_unable_to_query_nor_mutate_sale_updated_by_promotion_translations.pyindex 5db3d8ae33..8b8047211c 100644--- a/saleor/tests/e2e/promotions/test_unable_to_query_nor_mutate_sale_updated_by_promotion_translations.py+++ b/saleor/tests/e2e/promotions/test_unable_to_query_nor_mutate_sale_updated_by_promotion_translations.py@@ -8,7 +8,7 @@ from ..sales.utils import (raw_create_sale_channel_listing,sale_catalogues_add,)-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import promotions_query, translate_promotion@@ -16,16 +16,14 @@ from .utils import promotions_query, translate_promotiondef prepare_sale(e2e_staff_api_client):price = 10- (- warehouse_id,- channel_id,- _channel_slug,- _shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]+ channel_slug = shop_data["channel"]["slug"]+ warehouse_id = shop_data["warehouse"]["id"](product_id,- product_variant_id,+ _product_variant_id,_product_variant_price,) = prepare_product(e2e_staff_api_client,@@ -62,6 +60,7 @@ def prepare_sale(e2e_staff_api_client):return (channel_id,+ channel_slug,sale_name,sale_id,)@@ -70,18 +69,14 @@ def prepare_sale(e2e_staff_api_client):@pytest.mark.e2edef test_unable_to_query_nor_mutate_sale_updated_by_promotion_translations_CORE_2120(e2e_staff_api_client,- permission_manage_products,- permission_manage_channels,+ shop_permissions,permission_manage_product_types_and_attributes,- permission_manage_shipping,permission_manage_discounts,permission_manage_translations,):# Beforepermissions = [- permission_manage_products,- permission_manage_channels,- permission_manage_shipping,+ *shop_permissions,permission_manage_product_types_and_attributes,permission_manage_discounts,permission_manage_translations,@@ -90,6 +85,7 @@ def test_unable_to_query_nor_mutate_sale_updated_by_promotion_translations_CORE_(channel_id,+ channel_slug,sale_name,sale_id,) = prepare_sale(e2e_staff_api_client)diff --git a/saleor/tests/e2e/shipping_zone/utils/shipping_method.py b/saleor/tests/e2e/shipping_zone/utils/shipping_method.pyindex 89a936f598..72b2dd0c83 100644--- a/saleor/tests/e2e/shipping_zone/utils/shipping_method.py+++ b/saleor/tests/e2e/shipping_zone/utils/shipping_method.py@@ -1,3 +1,5 @@+import base64+from ...utils import get_graphql_contentSHIPPING_PRICE_CREATE_MUTATION = """@@ -13,18 +15,54 @@ mutation CreateShippingRate($input: ShippingPriceInput!) {}shippingMethod {id+ channelListings {+ maximumOrderPrice {+ amount+ }+ minimumOrderPrice {+ amount+ }+ price {+ amount+ }+ channel {+ id+ }+ }}}}"""+def decode_and_modify_base64_descriptor(encoded_string, new_descriptor=None):+ base64_bytes = encoded_string.encode("ascii")+ decoded_bytes = base64.b64decode(base64_bytes)+ decoded_string = decoded_bytes.decode("ascii")++ modified_string = decoded_string+ if new_descriptor:+ parts = decoded_string.split(":")+ if len(parts) >= 2:+ modified_string = f"{new_descriptor}:{parts[1]}"++ modified_base64 = base64.b64encode(modified_string.encode("ascii")).decode("ascii")++ padding = "=" * ((4 - len(modified_base64) % 4) % 4)+ modified_base64_padded = modified_base64 + padding++ return modified_base64_padded++def create_shipping_method(staff_api_client,shipping_zone_id,- name="Test shipping method",+ name=None,type="PRICE",):+ if name is None:+ name = "Test shipping method"+variables = {"input": {"shippingZone": shipping_zone_id,@@ -41,4 +79,6 @@ def create_shipping_method(data = content["data"]["shippingPriceCreate"]["shippingMethod"]assert data["id"] is not None+ data["id"] = decode_and_modify_base64_descriptor(data["id"], "ShippingMethod")+return datadiff --git a/saleor/tests/e2e/shipping_zone/utils/shipping_method_channel_listing.py b/saleor/tests/e2e/shipping_zone/utils/shipping_method_channel_listing.pyindex 47cc1f680d..3dcb7c6006 100644--- a/saleor/tests/e2e/shipping_zone/utils/shipping_method_channel_listing.py+++ b/saleor/tests/e2e/shipping_zone/utils/shipping_method_channel_listing.py@@ -15,7 +15,16 @@ mutation ShippingMethodChannelListingUpdate(channelListings {minimumOrderPrice {amount- }+ }+ maximumOrderPrice {+ amount+ }+ price {+ amount+ }+ channel {+ id+ }}}}@@ -24,22 +33,19 @@ mutation ShippingMethodChannelListingUpdate(def create_shipping_method_channel_listing(- staff_api_client,- shipping_method_id,- channel_id,- price="10.00",- minimumOrderPrice=None,- maximumOrderPrice=None,+ staff_api_client, shipping_method_id, channel_id, add_channels):+ if add_channels is None:+ add_channels = {}variables = {"id": shipping_method_id,"input": {"addChannels": [{"channelId": channel_id,- "price": price,- "maximumOrderPrice": maximumOrderPrice,- "minimumOrderPrice": minimumOrderPrice,+ "price": add_channels.get("price", "10.00"),+ "maximumOrderPrice": add_channels.get("maximum_order_price", None),+ "minimumOrderPrice": add_channels.get("minimum_order_price", None),}]},diff --git a/saleor/tests/e2e/shipping_zone/utils/shipping_zone.py b/saleor/tests/e2e/shipping_zone/utils/shipping_zone.pyindex 9b76575143..b21fae8779 100644--- a/saleor/tests/e2e/shipping_zone/utils/shipping_zone.py+++ b/saleor/tests/e2e/shipping_zone/utils/shipping_zone.py@@ -14,9 +14,31 @@ mutation createShipping($input: ShippingZoneCreateInput!) {descriptionwarehouses {name+ id+ shippingZones(first: 10) {+ edges {+ node {+ id+ countries {+ code+ }+ }+ }+ }+ slug}channels {id+ countries {+ code+ }+ }+ countries {+ code+ country+ }+ shippingMethods {+ id}}}@@ -27,10 +49,13 @@ mutation createShipping($input: ShippingZoneCreateInput!) {def create_shipping_zone(staff_api_client,name="Test shipping zone",- countries=["US"],+ countries=None,warehouse_ids=None,channel_ids=None,):+ if countries is None:+ countries = ["US"]+if not warehouse_ids:warehouse_ids = []if not channel_ids:diff --git a/saleor/tests/e2e/shop/utils/__init__.py b/saleor/tests/e2e/shop/utils/__init__.pyindex b8b18a8ac9..8b98ded36f 100644--- a/saleor/tests/e2e/shop/utils/__init__.py+++ b/saleor/tests/e2e/shop/utils/__init__.py@@ -1,7 +1,8 @@-from .preparing_shop import prepare_shop+from .preparing_shop import prepare_default_shop, prepare_shopfrom .shop_update_settings import update_shop_settings__all__ = ["prepare_shop",+ "prepare_default_shop","update_shop_settings",]diff --git a/saleor/tests/e2e/shop/utils/preparing_shop.py b/saleor/tests/e2e/shop/utils/preparing_shop.pyindex d903814ccc..51c6b171f5 100644--- a/saleor/tests/e2e/shop/utils/preparing_shop.py+++ b/saleor/tests/e2e/shop/utils/preparing_shop.py@@ -1,44 +1,170 @@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 (+from ...shipping_zone.utils import (+ create_shipping_method,create_shipping_method_channel_listing,+ create_shipping_zone,+)+from ...taxes.utils import (+ create_tax_class,+ get_tax_configurations,+ update_tax_class,+ update_tax_configuration,)-from ...shipping_zone.utils.shipping_zone import create_shipping_zonefrom ...warehouse.utils import create_warehouse+from ..utils.shop_update_settings import update_shop_settings+++def create_and_update_tax_classes(e2e_staff_api_client, tax_rates):+ created_tax_classes = {rate["type"]: {} for rate in tax_rates}++ for tax_rate_info in tax_rates:+ tax_class_data = create_tax_class(+ e2e_staff_api_client,+ tax_rate_info["name"],+ [+ {+ "countryCode": tax_rate_info["country_code"],+ "rate": tax_rate_info["rate"],+ }+ ],+ )+ created_tax_classes[tax_rate_info["type"]] = {+ "id": tax_class_data["id"],+ "rate": tax_rate_info["rate"],+ }++ tax_class_update_input = {+ "updateCountryRates": [+ {+ "countryCode": tax_rate_info["country_code"],+ "rate": tax_rate_info["rate"],+ }+ ]+ }+ update_tax_class(+ e2e_staff_api_client, tax_class_data["id"], tax_class_update_input+ )++ return created_tax_classes+++def prepare_shop(+ e2e_staff_api_client,+ channels=None,+ shop_settings=None,+ tax_settings=None,+):+ if shop_settings is not None:+ update_shop_settings(e2e_staff_api_client, input_data=shop_settings)++ warehouse_id = create_warehouse(e2e_staff_api_client)["id"]++ created_channels = []+ for channel_index, channel in enumerate(channels):+ if channel is None:+ channel = []+ created_channel = create_channel(+ e2e_staff_api_client,+ order_settings=channel["order_settings"],+ warehouse_ids=[warehouse_id],+ )+ channel_id = created_channel["id"]+ created_channels.append(+ {+ "id": channel_id,+ "warehouse_id": warehouse_id,+ "slug": created_channel["slug"],+ "shipping_zones": [],+ "order_settings": created_channel["orderSettings"],+ }+ )++ for shipping_zone_index, shipping_zone in enumerate(channel["shipping_zones"]):+ created_shipping_zone = create_shipping_zone(+ e2e_staff_api_client,+ warehouse_ids=[warehouse_id],+ channel_ids=[channel_id],+ countries=shipping_zone.get("countries"),+ )+ created_channels[channel_index]["shipping_zones"].append(+ {+ "id": created_shipping_zone["id"],+ "shipping_methods": [],+ }+ )-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(+ for shipping_zone in shipping_zone["shipping_methods"]:+ created_shipping_method = create_shipping_method(+ e2e_staff_api_client,+ shipping_zone_id=created_shipping_zone["id"],+ name=shipping_zone.get("name"),+ )++ created_channels[channel_index]["shipping_zones"][shipping_zone_index][+ "shipping_methods"+ ].append({"id": created_shipping_method["id"]})++ create_shipping_method_channel_listing(+ e2e_staff_api_client,+ shipping_method_id=created_shipping_method["id"],+ channel_id=created_channel["id"],+ add_channels=shipping_zone.get("add_channels", None),+ )+ created_tax_classes = {}+ tax_rates = {}+ if tax_settings:+ tax_rates_list = tax_settings.pop("tax_rates", [])+ tax_rates = {rate["type"]: rate for rate in tax_rates_list}++ tax_config_data = get_tax_configurations(e2e_staff_api_client)+ channel_tax_config = tax_config_data[0]["node"]+ tax_config_id = channel_tax_config["id"]+ update_tax_configuration(e2e_staff_api_client, tax_config_id, **tax_settings)++ if tax_rates:+ tax_classes_result = create_and_update_tax_classes(+ e2e_staff_api_client, tax_rates.values()+ )+ for tax_type, tax_rate in tax_rates.items():+ tax_class_id = tax_classes_result.get(tax_type, {}).get("id")+ if tax_class_id:+ created_tax_classes[f"{tax_type}_tax_class_id"] = tax_class_id+ tax_config = [created_tax_classes, tax_rates]+ return created_channels, tax_config+++def prepare_default_shop(+ e2e_staff_api_client,+):+ created_warehouse = create_warehouse(e2e_staff_api_client)++ created_channel = create_channel(e2e_staff_api_client,- slug=channel_slug,- warehouse_ids=warehouse_ids,+ warehouse_ids=[created_warehouse["id"]],)- channel_id = channel_data["id"]- channel_ids = [channel_id]- shipping_zone_data = create_shipping_zone(++ created_shipping_zone = create_shipping_zone(e2e_staff_api_client,- warehouse_ids=warehouse_ids,- channel_ids=channel_ids,+ warehouse_ids=[created_warehouse["id"]],+ channel_ids=[created_channel["id"]],)- shipping_zone_id = shipping_zone_data["id"]- shipping_method_data = create_shipping_method(+ created_shipping_method = create_shipping_method(e2e_staff_api_client,- shipping_zone_id,+ shipping_zone_id=created_shipping_zone["id"],)- shipping_method_id = shipping_method_data["id"]- create_shipping_method_channel_listing(++ _ = create_shipping_method_channel_listing(e2e_staff_api_client,- shipping_method_id,- channel_id,- )- return (- warehouse_id,- channel_id,- channel_slug,- shipping_method_id,+ shipping_method_id=created_shipping_method["id"],+ channel_id=created_channel["id"],+ add_channels={},)++ return {+ "warehouse": created_warehouse,+ "channel": created_channel,+ "shipping_zone": created_shipping_zone,+ "shipping_method": created_shipping_method,+ }diff --git a/saleor/tests/e2e/shop/utils/shop_update_settings.py b/saleor/tests/e2e/shop/utils/shop_update_settings.pyindex 1e8cc3252c..f082a2c1f6 100644--- a/saleor/tests/e2e/shop/utils/shop_update_settings.py+++ b/saleor/tests/e2e/shop/utils/shop_update_settings.py@@ -18,8 +18,16 @@ mutation ShopSettingsUpdate($input: ShopSettingsInput!) {"""-def update_shop_settings(staff_api_client, input):- variables = {"input": input}+def update_shop_settings(+ staff_api_client,+ input_data={+ "enableAccountConfirmationByEmail": True,+ "allowLoginWithoutConfirmation": False,+ "fulfillmentAutoApprove": False,+ "fulfillmentAllowUnpaid": False,+ },+):+ variables = {"input": input_data}response = staff_api_client.post_graphql(SHOP_SETTING_UPDATE_MUTATION, variables)content = get_graphql_content(response)diff --git a/saleor/tests/e2e/taxes/utils/__init__.py b/saleor/tests/e2e/taxes/utils/__init__.pyindex 9dc285c3da..ff1012119c 100644--- a/saleor/tests/e2e/taxes/utils/__init__.py+++ b/saleor/tests/e2e/taxes/utils/__init__.py@@ -1,5 +1,6 @@from .query_tax_configurations import get_tax_configurationsfrom .tax_class_create import create_tax_class+from .tax_class_update import update_tax_classfrom .tax_configuration_update import update_tax_configurationfrom .tax_country_configuration_update import update_country_tax_rates@@ -8,4 +9,5 @@ __all__ = ["update_tax_configuration","update_country_tax_rates","create_tax_class",+ "update_tax_class",]diff --git a/saleor/tests/e2e/taxes/utils/tax_class_update.py b/saleor/tests/e2e/taxes/utils/tax_class_update.pynew file mode 100644index 0000000000..20ecdc4455--- /dev/null+++ b/saleor/tests/e2e/taxes/utils/tax_class_update.py@@ -0,0 +1,40 @@+from ...utils import get_graphql_content++TAX_CLASS_UPDATE_MUTATION = """+mutation taxClassUpdate($id:ID!, $input:TaxClassUpdateInput!){+ taxClassUpdate(id:$id, input:$input) {+ errors {+ field+ message+ }+ taxClass {+ id+ countries {+ country {+ code+ }+ rate+ taxClass { id }+ }+ }+ }+}+"""+++def update_tax_class(+ staff_api_client,+ tax_class_id,+ tax_class_update_input,+):+ variables = {"id": tax_class_id, "input": tax_class_update_input}++ response = staff_api_client.post_graphql(TAX_CLASS_UPDATE_MUTATION, variables)+ content = get_graphql_content(response)++ assert content["data"]["taxClassUpdate"]["errors"] == []++ data = content["data"]["taxClassUpdate"]["taxClass"]+ assert data["id"] is not None++ return datadiff --git a/saleor/tests/e2e/vouchers/test_export_voucher_codes.py b/saleor/tests/e2e/vouchers/test_export_voucher_codes.pyindex ddb7964cc5..0708b4d202 100644--- a/saleor/tests/e2e/vouchers/test_export_voucher_codes.py+++ b/saleor/tests/e2e/vouchers/test_export_voucher_codes.py@@ -2,7 +2,7 @@ import uuidimport pytest-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import (create_voucher,@@ -58,9 +58,7 @@ def create_vouchers_with_multiple_codes(e2e_staff_api_client, channel_id):)def test_export_valid_voucher_ids_CORE_0925(e2e_staff_api_client,- permission_manage_channels,- permission_manage_shipping,- permission_manage_products,+ shop_permissions,permission_manage_discounts,permission_manage_checkouts,file_type,@@ -69,20 +67,14 @@ def test_export_valid_voucher_ids_CORE_0925():# Beforepermissions = [- permission_manage_channels,- permission_manage_shipping,- permission_manage_products,+ *shop_permissions,permission_manage_discounts,permission_manage_checkouts,]assign_permissions(e2e_staff_api_client, permissions)- (- _warehouse_id,- channel_id,- _channel_slug,- _shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]voucher_ids, _voucher_code_ids = create_vouchers_with_multiple_codes(e2e_staff_api_client, channel_id@@ -122,9 +114,7 @@ def test_export_valid_voucher_ids_CORE_0925()def test_export_voucher_ids_and_codes_CORE_0925(e2e_staff_api_client,- permission_manage_channels,- permission_manage_shipping,- permission_manage_products,+ shop_permissions,permission_manage_discounts,permission_manage_checkouts,file_type,@@ -133,20 +123,14 @@ def test_export_voucher_ids_and_codes_CORE_0925():# Beforepermissions = [- permission_manage_channels,- permission_manage_shipping,- permission_manage_products,+ *shop_permissions,permission_manage_discounts,permission_manage_checkouts,]assign_permissions(e2e_staff_api_client, permissions)- (- _warehouse_id,- channel_id,- _channel_slug,- _shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]voucher_ids, voucher_code_ids = create_vouchers_with_multiple_codes(e2e_staff_api_client, channel_id@@ -180,9 +164,7 @@ def test_export_voucher_ids_and_codes_CORE_0925()def test_export_valid_voucher_code_ids_CORE_0925(e2e_staff_api_client,- permission_manage_channels,- permission_manage_shipping,- permission_manage_products,+ shop_permissions,permission_manage_discounts,permission_manage_checkouts,file_type,@@ -191,20 +173,15 @@ def test_export_valid_voucher_code_ids_CORE_0925():# Beforepermissions = [- permission_manage_channels,- permission_manage_shipping,- permission_manage_products,+ *shop_permissions,permission_manage_discounts,permission_manage_checkouts,]+assign_permissions(e2e_staff_api_client, permissions)- (- _warehouse_id,- channel_id,- _channel_slug,- _shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]_voucher_ids, voucher_code_ids = create_vouchers_with_multiple_codes(e2e_staff_api_client, channel_id@@ -234,18 +211,14 @@ def test_export_valid_voucher_code_ids_CORE_0925()def test_export_voucher_codes_with_invalid_voucher_id_CORE_0925(e2e_staff_api_client,- permission_manage_channels,- permission_manage_shipping,- permission_manage_products,+ shop_permissions,permission_manage_discounts,permission_manage_checkouts,file_type,):# Beforepermissions = [- permission_manage_channels,- permission_manage_shipping,- permission_manage_products,+ *shop_permissions,permission_manage_discounts,permission_manage_checkouts,]@@ -274,18 +247,14 @@ def test_export_voucher_codes_with_invalid_voucher_id_CORE_0925()def test_export_voucher_codes_with_invalid_voucher_codes_CORE_0925(e2e_staff_api_client,- permission_manage_channels,- permission_manage_shipping,- permission_manage_products,+ shop_permissions,permission_manage_discounts,permission_manage_checkouts,file_type,):# Beforepermissions = [- permission_manage_channels,- permission_manage_shipping,- permission_manage_products,+ *shop_permissions,permission_manage_discounts,permission_manage_checkouts,]@@ -313,18 +282,14 @@ def test_export_voucher_codes_with_invalid_voucher_codes_CORE_0925()def test_export_voucher_codes_without_voucher_id_nor_codes_CORE_0925(e2e_staff_api_client,- permission_manage_channels,- permission_manage_shipping,- permission_manage_products,+ shop_permissions,permission_manage_discounts,permission_manage_checkouts,file_type,):# Beforepermissions = [- permission_manage_channels,- permission_manage_shipping,- permission_manage_products,+ *shop_permissions,permission_manage_discounts,permission_manage_checkouts,]@@ -359,9 +324,7 @@ def test_export_voucher_codes_without_voucher_id_nor_codes_CORE_0925()def test_export_voucher_codes_with_invalid_file_type_CORE_0925(e2e_staff_api_client,- permission_manage_channels,- permission_manage_shipping,- permission_manage_products,+ shop_permissions,permission_manage_discounts,permission_manage_checkouts,file_type,@@ -369,20 +332,14 @@ def test_export_voucher_codes_with_invalid_file_type_CORE_0925():# Beforepermissions = [- permission_manage_channels,- permission_manage_shipping,- permission_manage_products,+ *shop_permissions,permission_manage_discounts,permission_manage_checkouts,]assign_permissions(e2e_staff_api_client, permissions)- (- _warehouse_id,- channel_id,- _channel_slug,- _shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]voucher_ids, _voucher_code_ids = create_vouchers_with_multiple_codes(e2e_staff_api_client, channel_iddiff --git a/saleor/tests/e2e/vouchers/test_staff_can_delete_vouchers_in_bulk.py b/saleor/tests/e2e/vouchers/test_staff_can_delete_vouchers_in_bulk.pyindex af5398ddbf..cb385b7578 100644--- a/saleor/tests/e2e/vouchers/test_staff_can_delete_vouchers_in_bulk.py+++ b/saleor/tests/e2e/vouchers/test_staff_can_delete_vouchers_in_bulk.py@@ -1,6 +1,6 @@import pytest-from ..shop.utils.preparing_shop import prepare_shop+from ..shop.utils.preparing_shop import prepare_default_shopfrom ..utils import assign_permissionsfrom .utils import (create_voucher,@@ -42,28 +42,20 @@ def create_multiple_vouchers(e2e_staff_api_client, channel_id):@pytest.mark.e2edef test_staff_can_delete_vouchers_in_bulk_CORE_0924(e2e_staff_api_client,- permission_manage_channels,- permission_manage_shipping,- permission_manage_products,+ shop_permissions,permission_manage_discounts,permission_manage_checkouts,):# Beforepermissions = [- permission_manage_channels,- permission_manage_shipping,- permission_manage_products,+ *shop_permissions,permission_manage_discounts,permission_manage_checkouts,]assign_permissions(e2e_staff_api_client, permissions)- (- _warehouse_id,- channel_id,- _channel_slug,- _shipping_method_id,- ) = prepare_shop(e2e_staff_api_client)+ shop_data = prepare_default_shop(e2e_staff_api_client)+ channel_id = shop_data["channel"]["id"]voucher_ids = create_multiple_vouchers(e2e_staff_api_client, channel_id)diff --git a/saleor/tests/e2e/warehouse/utils/create_warehouse.py b/saleor/tests/e2e/warehouse/utils/create_warehouse.pyindex 953a563463..ef9942f4cf 100644--- a/saleor/tests/e2e/warehouse/utils/create_warehouse.py+++ b/saleor/tests/e2e/warehouse/utils/create_warehouse.py@@ -1,3 +1,5 @@+import uuid+from ... import DEFAULT_ADDRESSfrom ...utils import get_graphql_content@@ -13,6 +15,18 @@ mutation createWarehouse($input: WarehouseCreateInput!) {idnameslug+ isPrivate+ shippingZones(first: 10) {+ edges {+ node {+ id+ countries {+ code+ }+ }+ }+ }+ clickAndCollectOption}}}@@ -22,7 +36,7 @@ mutation createWarehouse($input: WarehouseCreateInput!) {def create_warehouse(staff_api_client,name="Test warehouse",- slug="test-slug",+ slug=f"warehouse_slug_{uuid.uuid4()}",address=DEFAULT_ADDRESS,):variables = {diff --git a/saleor/tests/fixtures.py b/saleor/tests/fixtures.pyindex ca8d9cd9eb..8cbc384df4 100644--- a/saleor/tests/fixtures.py+++ b/saleor/tests/fixtures.py@@ -6049,6 +6049,23 @@ def permission_group_all_perms_without_any_channel(return group+def shop_permissions(+ permission_manage_products,+ permission_manage_channels,+ permission_manage_shipping,+ permission_manage_taxes,+ permission_manage_settings,+):+ return [+ permission_manage_products,+ permission_manage_channels,+ permission_manage_shipping,+ permission_manage_taxes,+ permission_manage_settings,+ ]++@pytest.fixturedef collection(db):collection = Collection.objects.create(