Skip to content

Saleor Core: the high performance, composable, headless commerce API.

refactor_e2e_tests_formatting_and_unused_variables_names (#13964)

Renata1a2058c706ca
diff --git a/saleor/tests/e2e/checkout/test_checkout_calculate_correct_discount_for_sale_and_voucher.py b/saleor/tests/e2e/checkout/test_checkout_calculate_correct_discount_for_sale_and_voucher.py
index 15f68756d8..78ce80f38b 100644
--- a/saleor/tests/e2e/checkout/test_checkout_calculate_correct_discount_for_sale_and_voucher.py
+++ b/saleor/tests/e2e/checkout/test_checkout_calculate_correct_discount_for_sale_and_voucher.py
@@ -23,7 +23,11 @@ def prepare_sale_for_variant(
sale_discount_value,
):
sale_name = "Sale"
- sale = create_sale(e2e_staff_api_client, sale_name, sale_discount_type)
+ sale = create_sale(
+ e2e_staff_api_client,
+ sale_name,
+ sale_discount_type,
+ )
sale_id = sale["id"]
sale_listing_input = [
{
@@ -32,10 +36,16 @@ def prepare_sale_for_variant(
}
]
create_sale_channel_listing(
- e2e_staff_api_client, sale_id, add_channels=sale_listing_input
+ e2e_staff_api_client,
+ sale_id,
+ add_channels=sale_listing_input,
)
catalogue_input = {"variants": [product_variant_id]}
- sale_catalogues_add(e2e_staff_api_client, sale_id, catalogue_input)
+ sale_catalogues_add(
+ e2e_staff_api_client,
+ sale_id,
+ catalogue_input,
+ )
return sale_id, sale_discount_value
@@ -55,9 +65,16 @@ def prepare_voucher(
)
voucher_id = voucher_data["id"]
channel_listing = [
- {"channelId": channel_id, "discountValue": voucher_discount_value}
+ {
+ "channelId": channel_id,
+ "discountValue": voucher_discount_value,
+ }
]
- create_voucher_channel_listing(e2e_staff_api_client, voucher_id, channel_listing)
+ create_voucher_channel_listing(
+ e2e_staff_api_client,
+ voucher_id,
+ channel_listing,
+ )
return voucher_discount_value, voucher_code
@@ -101,12 +118,22 @@ def test_checkout_calculate_discount_for_sale_and_voucher_1014(
]
assign_permissions(e2e_staff_api_client, permissions)
- warehouse_id, channel_id, channel_slug, shipping_method_id = prepare_shop(
- e2e_staff_api_client
- )
+ (
+ warehouse_id,
+ channel_id,
+ channel_slug,
+ shipping_method_id,
+ ) = prepare_shop(e2e_staff_api_client)
- _, product_variant_id, product_variant_price = prepare_product(
- e2e_staff_api_client, warehouse_id, channel_id, variant_price
+ (
+ _product_id,
+ product_variant_id,
+ product_variant_price,
+ ) = prepare_product(
+ e2e_staff_api_client,
+ warehouse_id,
+ channel_id,
+ variant_price,
)
sale_id, sale_discount_value = prepare_sale_for_variant(
@@ -159,7 +186,11 @@ def test_checkout_calculate_discount_for_sale_and_voucher_1014(
lines_add = [
{"variantId": product_variant_id, "quantity": 1},
]
- checkout_data = checkout_lines_add(e2e_staff_api_client, checkout_id, lines_add)
+ checkout_data = checkout_lines_add(
+ e2e_staff_api_client,
+ checkout_id,
+ lines_add,
+ )
checkout_lines = checkout_data["lines"][0]
assert checkout_lines["quantity"] == 2
assert checkout_lines["unitPrice"]["gross"]["amount"] == expected_unit_price
@@ -183,7 +214,10 @@ def test_checkout_calculate_discount_for_sale_and_voucher_1014(
)
# Step 6 - Complete checkout.
- order_data = checkout_complete(e2e_not_logged_api_client, checkout_id)
+ order_data = checkout_complete(
+ e2e_not_logged_api_client,
+ checkout_id,
+ )
assert order_data["status"] == "UNFULFILLED"
assert order_data["discounts"][0]["type"] == "VOUCHER"
assert order_data["voucher"]["code"] == voucher_code
diff --git a/saleor/tests/e2e/checkout/test_checkout_create_from_order.py b/saleor/tests/e2e/checkout/test_checkout_create_from_order.py
index 746d1233d8..4ff0719717 100644
--- a/saleor/tests/e2e/checkout/test_checkout_create_from_order.py
+++ b/saleor/tests/e2e/checkout/test_checkout_create_from_order.py
@@ -31,18 +31,25 @@ def test_checkout_create_from_order_core_0104(
price = 10
(
- result_warehouse_id,
- result_channel_id,
- _,
- _,
+ warehouse_id,
+ channel_id,
+ _channel_slug,
+ _shipping_method_id,
) = prepare_shop(e2e_staff_api_client)
- _, result_product_variant_id, _ = prepare_product(
- e2e_staff_api_client, result_warehouse_id, result_channel_id, price
+ (
+ _product_id,
+ product_variant_id,
+ _product_variant_price,
+ ) = prepare_product(
+ e2e_staff_api_client,
+ warehouse_id,
+ channel_id,
+ price,
)
# Step 1 - Create checkout from order
- channel_id = {"channelId": result_channel_id}
+ channel_id = {"channelId": channel_id}
data = draft_order_create(
e2e_staff_api_client,
channel_id,
@@ -51,13 +58,24 @@ def test_checkout_create_from_order_core_0104(
order_id = data["order"]["id"]
assert order_id is not None
order_lines = [
- {"variantId": result_product_variant_id, "quantity": 1, "price": 100}
+ {
+ "variantId": product_variant_id,
+ "quantity": 1,
+ "price": 100,
+ }
]
- order_data = order_lines_create(e2e_staff_api_client, order_id, order_lines)
+ order_data = order_lines_create(
+ e2e_staff_api_client,
+ order_id,
+ order_lines,
+ )
order_product_variant_id = order_data["order"]["lines"][0]["variant"]
order_product_quantity = order_data["order"]["lines"][0]["quantity"]
- checkout_data = checkout_create_from_order(e2e_staff_api_client, order_id)
+ checkout_data = checkout_create_from_order(
+ e2e_staff_api_client,
+ order_id,
+ )
checkout_id = checkout_data["checkout"]["id"]
assert checkout_id is not None
errors = checkout_data["errors"]
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.py
index 9e5c7afc49..6e15d74f1e 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
@@ -43,14 +43,22 @@ def create_shop_for_orders_without_payments(
shipping_zone_id = shipping_zone_data["id"]
shipping_method_data = create_shipping_method(
- e2e_staff_api_client, shipping_zone_id
+ 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
+ e2e_staff_api_client,
+ shipping_method_id,
+ channel_id,
+ )
+ return (
+ channel_slug,
+ warehouse_id,
+ channel_id,
+ shipping_method_id,
)
- return channel_slug, warehouse_id, channel_id, shipping_method_id
@pytest.mark.e2e
@@ -82,7 +90,11 @@ def test_should_be_able_to_create_order_with_no_payment_CORE_0111(
variant_price = 10
- _, result_product_variant_id, _ = prepare_product(
+ (
+ _product_id,
+ product_variant_id,
+ _product_variant_price,
+ ) = prepare_product(
e2e_staff_api_client,
warehouse_id,
channel_id,
@@ -93,7 +105,7 @@ def test_should_be_able_to_create_order_with_no_payment_CORE_0111(
# Step 1 - Create checkout.
lines = [
- {"variantId": result_product_variant_id, "quantity": 1},
+ {"variantId": product_variant_id, "quantity": 1},
]
checkout_data = checkout_create(
e2e_staff_api_client,
@@ -119,7 +131,10 @@ def test_should_be_able_to_create_order_with_no_payment_CORE_0111(
assert checkout_data["deliveryMethod"]["id"] == shipping_method_id
# Step 3 - Checkout complete results in the order creation
- data = raw_checkout_complete(e2e_staff_api_client, checkout_id)
+ data = raw_checkout_complete(
+ e2e_staff_api_client,
+ checkout_id,
+ )
order_data = data["order"]
assert order_data is not None
assert order_data["id"] is not None
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.py
index 62e6de8442..f2f4e4348e 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
@@ -44,14 +44,22 @@ def create_shop_for_orders_without_payments(
shipping_zone_id = shipping_zone_data["id"]
shipping_method_data = create_shipping_method(
- e2e_staff_api_client, shipping_zone_id
+ 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
+ e2e_staff_api_client,
+ shipping_method_id,
+ channel_id,
+ )
+ return (
+ channel_slug,
+ warehouse_id,
+ channel_id,
+ shipping_method_id,
)
- return channel_slug, warehouse_id, channel_id, shipping_method_id
@pytest.mark.e2e
@@ -89,7 +97,11 @@ def test_should_be_able_to_create_partially_paid_order_core_0112(
variant_price = 10
- _, result_product_variant_id, _ = prepare_product(
+ (
+ _product_id,
+ product_variant_id,
+ _product_variant_price,
+ ) = prepare_product(
e2e_staff_api_client,
warehouse_id,
channel_id,
@@ -99,7 +111,10 @@ def test_should_be_able_to_create_partially_paid_order_core_0112(
assert shipping_method_id is not None
# Step 1 - Create checkout.
lines = [
- {"variantId": result_product_variant_id, "quantity": 1},
+ {
+ "variantId": product_variant_id,
+ "quantity": 1,
+ },
]
checkout_data = checkout_create(
e2e_not_logged_api_client,
@@ -136,7 +151,10 @@ def test_should_be_able_to_create_partially_paid_order_core_0112(
)
# Step 4 - Complete checkout and check created order
- data = raw_checkout_complete(e2e_not_logged_api_client, checkout_id)
+ data = raw_checkout_complete(
+ e2e_not_logged_api_client,
+ checkout_id,
+ )
order_data = data["order"]
assert order_data["id"] is not None
assert order_data["isShippingRequired"] is True
diff --git a/saleor/tests/e2e/checkout/test_checkout_product_on_fixed_sale.py b/saleor/tests/e2e/checkout/test_checkout_product_on_fixed_sale.py
index a7a98c9052..2d2bfc2bbb 100644
--- a/saleor/tests/e2e/checkout/test_checkout_product_on_fixed_sale.py
+++ b/saleor/tests/e2e/checkout/test_checkout_product_on_fixed_sale.py
@@ -20,7 +20,11 @@ def prepare_sale_for_product(
sale_discount_value,
):
sale_name = "Sale"
- sale = create_sale(e2e_staff_api_client, sale_name, sale_discount_type)
+ sale = create_sale(
+ e2e_staff_api_client,
+ sale_name,
+ sale_discount_type,
+ )
sale_id = sale["id"]
sale_listing_input = [
{
@@ -29,10 +33,16 @@ def prepare_sale_for_product(
}
]
create_sale_channel_listing(
- e2e_staff_api_client, sale_id, add_channels=sale_listing_input
+ e2e_staff_api_client,
+ sale_id,
+ add_channels=sale_listing_input,
)
catalogue_input = {"products": [product_id]}
- sale_catalogues_add(e2e_staff_api_client, sale_id, catalogue_input)
+ sale_catalogues_add(
+ e2e_staff_api_client,
+ sale_id,
+ catalogue_input,
+ )
return sale_id, sale_discount_value
@@ -57,12 +67,22 @@ def test_checkout_products_on_fixed_sale_core_1002(
]
assign_permissions(e2e_staff_api_client, permissions)
- warehouse_id, channel_id, channel_slug, shipping_method_id = prepare_shop(
- e2e_staff_api_client
- )
+ (
+ warehouse_id,
+ channel_id,
+ channel_slug,
+ shipping_method_id,
+ ) = prepare_shop(e2e_staff_api_client)
- product_id, product_variant_id, product_variant_price = prepare_product(
- e2e_staff_api_client, warehouse_id, channel_id, variant_price="13.33"
+ (
+ product_id,
+ product_variant_id,
+ product_variant_price,
+ ) = prepare_product(
+ e2e_staff_api_client,
+ warehouse_id,
+ channel_id,
+ variant_price="13.33",
)
sale_id, sale_discount_value = prepare_sale_for_product(
@@ -108,11 +128,16 @@ def test_checkout_products_on_fixed_sale_core_1002(
# Step 3 - Create payment for checkout.
checkout_dummy_payment_create(
- e2e_not_logged_api_client, checkout_id, total_gross_amount
+ e2e_not_logged_api_client,
+ checkout_id,
+ total_gross_amount,
)
# Step 5 - Complete checkout.
- order_data = checkout_complete(e2e_not_logged_api_client, checkout_id)
+ order_data = checkout_complete(
+ e2e_not_logged_api_client,
+ checkout_id,
+ )
assert order_data["status"] == "UNFULFILLED"
assert order_data["total"]["gross"]["amount"] == total_gross_amount
assert order_data["subtotal"]["gross"]["amount"] == subtotal_gross_amount
diff --git a/saleor/tests/e2e/checkout/test_checkout_product_on_percentage_sale.py b/saleor/tests/e2e/checkout/test_checkout_product_on_percentage_sale.py
index 35a10cb50c..5ef742f783 100644
--- a/saleor/tests/e2e/checkout/test_checkout_product_on_percentage_sale.py
+++ b/saleor/tests/e2e/checkout/test_checkout_product_on_percentage_sale.py
@@ -20,7 +20,11 @@ def prepare_sale_for_product(
sale_discount_value,
):
sale_name = "Sale"
- sale = create_sale(e2e_staff_api_client, sale_name, sale_discount_type)
+ sale = create_sale(
+ e2e_staff_api_client,
+ sale_name,
+ sale_discount_type,
+ )
sale_id = sale["id"]
sale_listing_input = [
{
@@ -29,10 +33,16 @@ def prepare_sale_for_product(
}
]
create_sale_channel_listing(
- e2e_staff_api_client, sale_id, add_channels=sale_listing_input
+ e2e_staff_api_client,
+ sale_id,
+ add_channels=sale_listing_input,
)
catalogue_input = {"products": [product_id]}
- sale_catalogues_add(e2e_staff_api_client, sale_id, catalogue_input)
+ sale_catalogues_add(
+ e2e_staff_api_client,
+ sale_id,
+ catalogue_input,
+ )
return sale_id, sale_discount_value
@@ -57,12 +67,22 @@ def test_checkout_products_on_percentage_sale_core_1004(
]
assign_permissions(e2e_staff_api_client, permissions)
- warehouse_id, channel_id, channel_slug, shipping_method_id = prepare_shop(
- e2e_staff_api_client
- )
+ (
+ warehouse_id,
+ channel_id,
+ channel_slug,
+ shipping_method_id,
+ ) = prepare_shop(e2e_staff_api_client)
- product_id, product_variant_id, product_variant_price = prepare_product(
- e2e_staff_api_client, warehouse_id, channel_id, variant_price="13.33"
+ (
+ product_id,
+ product_variant_id,
+ product_variant_price,
+ ) = prepare_product(
+ e2e_staff_api_client,
+ warehouse_id,
+ channel_id,
+ variant_price="13.33",
)
sale_id, sale_discount_value = prepare_sale_for_product(
@@ -75,7 +95,10 @@ def test_checkout_products_on_percentage_sale_core_1004(
# Step 1 - checkoutCreate for product on sale
lines = [
- {"variantId": product_variant_id, "quantity": 2},
+ {
+ "variantId": product_variant_id,
+ "quantity": 2,
+ },
]
checkout_data = checkout_create(
e2e_not_logged_api_client,
@@ -109,11 +132,16 @@ def test_checkout_products_on_percentage_sale_core_1004(
# Step 3 - Create payment for checkout.
checkout_dummy_payment_create(
- e2e_not_logged_api_client, checkout_id, total_gross_amount
+ e2e_not_logged_api_client,
+ checkout_id,
+ total_gross_amount,
)
# Step 5 - Complete checkout.
- order_data = checkout_complete(e2e_not_logged_api_client, checkout_id)
+ order_data = checkout_complete(
+ e2e_not_logged_api_client,
+ checkout_id,
+ )
assert order_data["status"] == "UNFULFILLED"
assert order_data["total"]["gross"]["amount"] == total_gross_amount
assert order_data["subtotal"]["gross"]["amount"] == subtotal_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.py
index 3a9f7de5c4..c36b2120c8 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
@@ -28,12 +28,19 @@ def test_should_not_be_able_to_make_purchase_with_no_payment_CORE_0113(
]
assign_permissions(e2e_staff_api_client, permissions)
- warehouse_id, channel_id, channel_slug, shipping_method_id = prepare_shop(
- e2e_staff_api_client
- )
+ (
+ warehouse_id,
+ channel_id,
+ channel_slug,
+ shipping_method_id,
+ ) = prepare_shop(e2e_staff_api_client)
variant_price = 10
- _, result_product_variant_id, _ = prepare_product(
+ (
+ _product_id,
+ product_variant_id,
+ _product_variant_price,
+ ) = prepare_product(
e2e_staff_api_client,
warehouse_id,
channel_id,
@@ -42,7 +49,10 @@ def test_should_not_be_able_to_make_purchase_with_no_payment_CORE_0113(
# Step 1 - Create checkout.
lines = [
- {"variantId": result_product_variant_id, "quantity": 1},
+ {
+ "variantId": product_variant_id,
+ "quantity": 1,
+ },
]
checkout_data = checkout_create(
e2e_not_logged_api_client,
@@ -69,7 +79,10 @@ def test_should_not_be_able_to_make_purchase_with_no_payment_CORE_0113(
assert checkout_data["deliveryMethod"]["id"] == shipping_method_id
# Step 3 - Unable to complete checkout without payment
- order_data = raw_checkout_complete(e2e_not_logged_api_client, checkout_id)
+ order_data = raw_checkout_complete(
+ e2e_not_logged_api_client,
+ checkout_id,
+ )
assert order_data["order"] is None
errors = order_data["errors"]
assert errors == [
diff --git a/saleor/tests/e2e/checkout/test_checkout_with_fixed_voucher.py b/saleor/tests/e2e/checkout/test_checkout_with_fixed_voucher.py
index 4c7e6bc799..a4ae625dd9 100644
--- a/saleor/tests/e2e/checkout/test_checkout_with_fixed_voucher.py
+++ b/saleor/tests/e2e/checkout/test_checkout_with_fixed_voucher.py
@@ -35,7 +35,11 @@ def prepare_fixed_voucher(
"discountValue": voucher_discount_value,
},
]
- create_voucher_channel_listing(e2e_staff_api_client, voucher_id, channel_listing)
+ create_voucher_channel_listing(
+ e2e_staff_api_client,
+ voucher_id,
+ channel_listing,
+ )
return voucher_code
@@ -60,12 +64,22 @@ def test_checkout_use_fixed_voucher_core_0901(
]
assign_permissions(e2e_staff_api_client, permissions)
- warehouse_id, channel_id, channel_slug, shipping_method_id = prepare_shop(
- e2e_staff_api_client
- )
+ (
+ warehouse_id,
+ channel_id,
+ channel_slug,
+ shipping_method_id,
+ ) = prepare_shop(e2e_staff_api_client)
- _, product_variant_id, product_variant_price = prepare_product(
- e2e_staff_api_client, warehouse_id, channel_id, variant_price=30
+ (
+ _product_id,
+ product_variant_id,
+ product_variant_price,
+ ) = prepare_product(
+ e2e_staff_api_client,
+ warehouse_id,
+ channel_id,
+ variant_price=30,
)
voucher_code = prepare_fixed_voucher(
@@ -79,7 +93,10 @@ def test_checkout_use_fixed_voucher_core_0901(
# Step 1 - Create checkout
lines = [
- {"variantId": product_variant_id, "quantity": 2},
+ {
+ "variantId": product_variant_id,
+ "quantity": 2,
+ },
]
checkout = checkout_create(
e2e_not_logged_api_client,
@@ -116,18 +133,27 @@ def test_checkout_use_fixed_voucher_core_0901(
assert undiscounted_total_gross == total_without_shipping + shipping_price
# Step 3 - Add voucher code to checkout
- data = checkout_add_promo_code(e2e_not_logged_api_client, checkout_id, voucher_code)
+ data = checkout_add_promo_code(
+ e2e_not_logged_api_client,
+ checkout_id,
+ voucher_code,
+ )
discounted_total_gross = data["totalPrice"]["gross"]["amount"]
discount_value = data["discount"]["amount"]
assert discounted_total_gross == undiscounted_total_gross - discount_value
# Step 4 - Create payment for checkout.
checkout_dummy_payment_create(
- e2e_not_logged_api_client, checkout_id, discounted_total_gross
+ e2e_not_logged_api_client,
+ checkout_id,
+ discounted_total_gross,
)
# Step 5 - Complete checkout.
- order_data = checkout_complete(e2e_staff_api_client, checkout_id)
+ order_data = checkout_complete(
+ e2e_staff_api_client,
+ checkout_id,
+ )
assert order_data["status"] == "UNFULFILLED"
assert order_data["discounts"][0]["type"] == "VOUCHER"
assert order_data["voucher"]["code"] == voucher_code
diff --git a/saleor/tests/e2e/checkout/test_checkout_with_free_shipping_voucher.py b/saleor/tests/e2e/checkout/test_checkout_with_free_shipping_voucher.py
index 27b158b6d2..6238275faa 100644
--- a/saleor/tests/e2e/checkout/test_checkout_with_free_shipping_voucher.py
+++ b/saleor/tests/e2e/checkout/test_checkout_with_free_shipping_voucher.py
@@ -38,7 +38,11 @@ def prepare_free_shipping_voucher(
"minAmountSpent": min_amount_spent,
},
]
- create_voucher_channel_listing(e2e_staff_api_client, voucher_id, channel_listing)
+ create_voucher_channel_listing(
+ e2e_staff_api_client,
+ voucher_id,
+ channel_listing,
+ )
return voucher_code
@@ -63,12 +67,22 @@ def test_checkout_use_free_shipping_voucher_with_min_spent_amount_0903(
]
assign_permissions(e2e_staff_api_client, permissions)
- warehouse_id, channel_id, channel_slug, shipping_method_id = prepare_shop(
- e2e_staff_api_client
- )
+ (
+ warehouse_id,
+ channel_id,
+ channel_slug,
+ shipping_method_id,
+ ) = prepare_shop(e2e_staff_api_client)
- _, product_variant_id, product_variant_price = prepare_product(
- e2e_staff_api_client, warehouse_id, channel_id, variant_price=25
+ (
+ _product_id,
+ product_variant_id,
+ product_variant_price,
+ ) = prepare_product(
+ e2e_staff_api_client,
+ warehouse_id,
+ channel_id,
+ variant_price=25,
)
voucher_code = prepare_free_shipping_voucher(
@@ -83,7 +97,10 @@ def test_checkout_use_free_shipping_voucher_with_min_spent_amount_0903(
# Step 1 - Create checkout for product
lines = [
- {"variantId": product_variant_id, "quantity": 1},
+ {
+ "variantId": product_variant_id,
+ "quantity": 1,
+ },
]
checkout_data = checkout_create(
e2e_not_logged_api_client,
@@ -111,9 +128,16 @@ def test_checkout_use_free_shipping_voucher_with_min_spent_amount_0903(
# Step 3 Add lines to the checkout to increase the total amount
lines_add = [
- {"variantId": product_variant_id, "quantity": 2},
+ {
+ "variantId": product_variant_id,
+ "quantity": 2,
+ },
]
- checkout_data = checkout_lines_add(e2e_staff_api_client, checkout_id, lines_add)
+ checkout_data = checkout_lines_add(
+ e2e_staff_api_client,
+ checkout_id,
+ lines_add,
+ )
checkout_lines = checkout_data["lines"][0]
assert checkout_lines["quantity"] == 3
subtotal_amount = float(product_variant_price) * 3
@@ -132,18 +156,25 @@ def test_checkout_use_free_shipping_voucher_with_min_spent_amount_0903(
# Step 5 Add free shipping voucher code to checkout
checkout_data = checkout_add_promo_code(
- e2e_not_logged_api_client, checkout_id, voucher_code
+ e2e_not_logged_api_client,
+ checkout_id,
+ voucher_code,
)
total_gross_amount = checkout_data["totalPrice"]["gross"]["amount"]
assert total_gross_amount == subtotal_amount
# Step 6 - Create payment for checkout.
checkout_dummy_payment_create(
- e2e_not_logged_api_client, checkout_id, total_gross_amount
+ e2e_not_logged_api_client,
+ checkout_id,
+ total_gross_amount,
)
# Step 7 - Complete checkout.
- order_data = checkout_complete(e2e_not_logged_api_client, checkout_id)
+ order_data = checkout_complete(
+ e2e_not_logged_api_client,
+ checkout_id,
+ )
assert order_data["status"] == "UNFULFILLED"
assert order_data["discounts"][0]["type"] == "VOUCHER"
assert order_data["discounts"][0]["value"] == shipping_price
diff --git a/saleor/tests/e2e/checkout/test_logged_customer_is_unable_to_buy_more_products_than_the_limit_per_customer.py b/saleor/tests/e2e/checkout/test_logged_customer_is_unable_to_buy_more_products_than_the_limit_per_customer.py
index ebccb0dacd..879d0ff8f8 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
@@ -14,9 +14,12 @@ from .utils import checkout_create, checkout_lines_update
def prepare_product_with_limit(e2e_staff_api_client):
- result_warehouse_id, result_channel_id, result_channel_slug, _ = prepare_shop(
- e2e_staff_api_client
- )
+ (
+ warehouse_id,
+ channel_id,
+ channel_slug,
+ _shipping_method_id,
+ ) = prepare_shop(e2e_staff_api_client)
product_type_data = create_product_type(
e2e_staff_api_client,
@@ -26,14 +29,22 @@ def prepare_product_with_limit(e2e_staff_api_client):
category_data = create_category(e2e_staff_api_client)
category_id = category_data["id"]
- product_data = create_product(e2e_staff_api_client, product_type_id, category_id)
+ product_data = create_product(
+ e2e_staff_api_client,
+ product_type_id,
+ category_id,
+ )
product_id = product_data["id"]
- create_product_channel_listing(e2e_staff_api_client, product_id, result_channel_id)
+ create_product_channel_listing(
+ e2e_staff_api_client,
+ product_id,
+ channel_id,
+ )
stocks = [
{
- "warehouse": result_warehouse_id,
+ "warehouse": warehouse_id,
"quantity": 5,
}
]
@@ -52,7 +63,7 @@ def prepare_product_with_limit(e2e_staff_api_client):
create_product_variant_channel_listing(
e2e_staff_api_client,
product_variant_id,
- result_channel_id,
+ channel_id,
price=10,
)
@@ -60,7 +71,7 @@ def prepare_product_with_limit(e2e_staff_api_client):
product_variant_id,
product_variant_name,
product_variant_quantity_limit_per_customer,
- result_channel_slug,
+ channel_slug,
)
@@ -85,7 +96,7 @@ def test_checkout_with_product_quantity_exceeding_the_limit_per_customer_core_01
product_variant_id,
product_variant_name,
product_variant_quantity_limit_per_customer,
- result_channel_slug,
+ channel_slug,
) = prepare_product_with_limit(
e2e_staff_api_client,
)
@@ -97,7 +108,7 @@ def test_checkout_with_product_quantity_exceeding_the_limit_per_customer_core_01
checkout_data = checkout_create(
e2e_logged_api_client,
lines,
- result_channel_slug,
+ channel_slug,
set_default_billing_address=True,
)
diff --git a/saleor/tests/e2e/checkout/test_logged_in_customer_should_be_able_to_order_physical_product.py b/saleor/tests/e2e/checkout/test_logged_in_customer_should_be_able_to_order_physical_product.py
index 1b6c8f62de..65e501953c 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
@@ -42,7 +42,11 @@ def test_process_checkout_with_physical_product_CORE_0103(
variant_price = 10
- _, result_product_variant_id, _ = prepare_product(
+ (
+ _product_id,
+ product_variant_id,
+ _product_variant_price,
+ ) = prepare_product(
e2e_staff_api_client,
warehouse_id,
channel_id,
@@ -51,7 +55,7 @@ def test_process_checkout_with_physical_product_CORE_0103(
# Step 1 - Create checkout.
lines = [
- {"variantId": result_product_variant_id, "quantity": 1},
+ {"variantId": product_variant_id, "quantity": 1},
]
checkout_data = checkout_create(
e2e_logged_api_client,
@@ -81,11 +85,16 @@ def test_process_checkout_with_physical_product_CORE_0103(
# Step 4 - Create payment for checkout.
checkout_dummy_payment_create(
- e2e_logged_api_client, checkout_id, total_gross_amount
+ e2e_logged_api_client,
+ checkout_id,
+ total_gross_amount,
)
# Step 5 - Complete checkout.
- order_data = checkout_complete(e2e_logged_api_client, checkout_id)
+ order_data = checkout_complete(
+ e2e_logged_api_client,
+ checkout_id,
+ )
assert order_data["isShippingRequired"] is True
assert order_data["user"]["email"] == expected_email
assert order_data["status"] == "UNFULFILLED"
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.py
index eb14d36711..9cb6b2df8e 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
@@ -16,9 +16,12 @@ from .utils import raw_checkout_create
def prepare_unavailable_product(
e2e_staff_api_client,
):
- result_warehouse_id, result_channel_id, result_channel_slug, _ = prepare_shop(
- e2e_staff_api_client
- )
+ (
+ warehouse_id,
+ channel_id,
+ channel_slug,
+ _shipping_method_id,
+ ) = prepare_shop(e2e_staff_api_client)
product_type_data = create_product_type(
e2e_staff_api_client,
@@ -40,7 +43,7 @@ def prepare_unavailable_product(
product_channel_listing = raw_create_product_channel_listing(
e2e_staff_api_client,
product_id,
- result_channel_id,
+ channel_id,
is_available_for_purchase=False,
available_for_purchase_datetime=None,
)
@@ -51,20 +54,25 @@ def prepare_unavailable_product(
stocks = [
{
- "warehouse": result_warehouse_id,
+ "warehouse": warehouse_id,
"quantity": 5,
}
]
variant_data = create_product_variant(
- e2e_staff_api_client, product_id, stocks=stocks
+ e2e_staff_api_client,
+ product_id,
+ stocks=stocks,
)
variant_id = variant_data["id"]
create_product_variant_channel_listing(
- e2e_staff_api_client, variant_id, result_channel_id, price=10
+ e2e_staff_api_client,
+ variant_id,
+ channel_id,
+ price=10,
)
- return variant_id, result_channel_slug
+ return variant_id, channel_slug
@pytest.mark.e2e
@@ -85,15 +93,25 @@ def test_should_not_be_able_to_buy_unavailable_product_core_0108(
]
assign_permissions(e2e_staff_api_client, permissions)
- variant_id, channel_slug = prepare_unavailable_product(
+ (
+ variant_id,
+ channel_slug,
+ ) = prepare_unavailable_product(
e2e_staff_api_client,
)
# Step 1 - Create checkout with non available for purchase product
lines = [
- {"variantId": variant_id, "quantity": 1},
+ {
+ "variantId": variant_id,
+ "quantity": 1,
+ },
]
- checkout_data = raw_checkout_create(e2e_logged_api_client, lines, channel_slug)
+ checkout_data = raw_checkout_create(
+ e2e_logged_api_client,
+ lines,
+ channel_slug,
+ )
errors = checkout_data["errors"]
assert errors[0]["code"] == "PRODUCT_UNAVAILABLE_FOR_PURCHASE"
diff --git a/saleor/tests/e2e/checkout/test_staff_user_can_use_voucher_for_staff_only.py b/saleor/tests/e2e/checkout/test_staff_user_can_use_voucher_for_staff_only.py
index b0c9528458..a4c326c260 100644
--- a/saleor/tests/e2e/checkout/test_staff_user_can_use_voucher_for_staff_only.py
+++ b/saleor/tests/e2e/checkout/test_staff_user_can_use_voucher_for_staff_only.py
@@ -29,9 +29,16 @@ def prepare_voucher_for_staff_only(
)
voucher_id = voucher_data["id"]
channel_listing = [
- {"channelId": channel_id, "discountValue": voucher_discount_value}
+ {
+ "channelId": channel_id,
+ "discountValue": voucher_discount_value,
+ }
]
- create_voucher_channel_listing(e2e_staff_api_client, voucher_id, channel_listing)
+ create_voucher_channel_listing(
+ e2e_staff_api_client,
+ voucher_id,
+ channel_listing,
+ )
return voucher_discount_value, voucher_code
@@ -57,11 +64,18 @@ def test_staff_can_use_voucher_for_staff_only_in_checkout_core_0904(
]
assign_permissions(e2e_staff_api_client, permissions)
- warehouse_id, channel_id, channel_slug, shipping_method_id = prepare_shop(
- e2e_staff_api_client
- )
+ (
+ warehouse_id,
+ channel_id,
+ channel_slug,
+ shipping_method_id,
+ ) = prepare_shop(e2e_staff_api_client)
- _, product_variant_id, product_variant_price = prepare_product(
+ (
+ _product_id,
+ product_variant_id,
+ product_variant_price,
+ ) = prepare_product(
e2e_staff_api_client,
warehouse_id,
channel_id,
@@ -78,7 +92,10 @@ def test_staff_can_use_voucher_for_staff_only_in_checkout_core_0904(
# Step 1 - Create checkout for product on sale
lines = [
- {"variantId": product_variant_id, "quantity": 1},
+ {
+ "variantId": product_variant_id,
+ "quantity": 1,
+ },
]
checkout_data = checkout_create(
e2e_no_permission_staff_api_client,
@@ -98,7 +115,9 @@ def test_staff_can_use_voucher_for_staff_only_in_checkout_core_0904(
# Step 2 Add voucher code to checkout
checkout_data = checkout_add_promo_code(
- e2e_no_permission_staff_api_client, checkout_id, voucher_code
+ e2e_no_permission_staff_api_client,
+ checkout_id,
+ voucher_code,
)
unit_price_with_voucher = float(product_variant_price) - voucher_discount_value
assert (
@@ -119,11 +138,16 @@ def test_staff_can_use_voucher_for_staff_only_in_checkout_core_0904(
# Step 5 - Create payment for checkout.
checkout_dummy_payment_create(
- e2e_no_permission_staff_api_client, checkout_id, total_gross_amount
+ e2e_no_permission_staff_api_client,
+ checkout_id,
+ total_gross_amount,
)
# Step 6 - Complete checkout.
- order_data = checkout_complete(e2e_no_permission_staff_api_client, checkout_id)
+ order_data = checkout_complete(
+ e2e_no_permission_staff_api_client,
+ checkout_id,
+ )
assert order_data["status"] == "UNFULFILLED"
assert order_data["discounts"][0]["type"] == "VOUCHER"
assert order_data["voucher"]["code"] == voucher_code
diff --git a/saleor/tests/e2e/checkout/test_unlogged_customer_is_unable_to_buy_unpublished_product.py b/saleor/tests/e2e/checkout/test_unlogged_customer_is_unable_to_buy_unpublished_product.py
index 0d0795639c..0d0496d461 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
@@ -16,9 +16,12 @@ from .utils import raw_checkout_create
def prepare_unpublished_product(
e2e_staff_api_client,
):
- result_warehouse_id, result_channel_id, result_channel_slug, _ = prepare_shop(
- e2e_staff_api_client
- )
+ (
+ warehouse_id,
+ channel_id,
+ channel_slug,
+ _shipping_method_id,
+ ) = prepare_shop(e2e_staff_api_client)
product_type_data = create_product_type(
e2e_staff_api_client,
@@ -28,20 +31,24 @@ def prepare_unpublished_product(
category_data = create_category(e2e_staff_api_client)
category_id = category_data["id"]
- product_data = create_product(e2e_staff_api_client, product_type_id, category_id)
+ product_data = create_product(
+ e2e_staff_api_client,
+ product_type_id,
+ category_id,
+ )
product_id = product_data["id"]
raw_create_product_channel_listing(
e2e_staff_api_client,
product_id,
- result_channel_id,
+ channel_id,
is_published=False,
is_available_for_purchase=True,
)
stocks = [
{
- "warehouse": result_warehouse_id,
+ "warehouse": warehouse_id,
"quantity": 5,
}
]
@@ -55,11 +62,11 @@ def prepare_unpublished_product(
create_product_variant_channel_listing(
e2e_staff_api_client,
product_variant_id,
- result_channel_id,
+ channel_id,
price=10,
)
- return product_variant_id, result_channel_slug
+ return product_variant_id, channel_slug
@pytest.mark.e2e
@@ -79,19 +86,25 @@ def test_unlogged_customer_is_unable_to_buy_unpublished_product_core_0109(
permission_manage_shipping,
]
assign_permissions(e2e_staff_api_client, permissions)
- product_variant_id, result_channel_slug = prepare_unpublished_product(
+ (
+ product_variant_id,
+ channel_slug,
+ ) = prepare_unpublished_product(
e2e_staff_api_client,
)
# Step 1 - Create checkout with unpublished product variant
lines = [
- {"variantId": product_variant_id, "quantity": 1},
+ {
+ "variantId": product_variant_id,
+ "quantity": 1,
+ },
]
checkout_data = raw_checkout_create(
e2e_not_logged_api_client,
lines,
- result_channel_slug,
+ channel_slug,
set_default_billing_address=True,
)
diff --git a/saleor/tests/e2e/checkout/test_unlogged_customer_should_be_able_to_buy_by_click_and_collect.py b/saleor/tests/e2e/checkout/test_unlogged_customer_should_be_able_to_buy_by_click_and_collect.py
index c5f5d6cdd5..c46b81d9c1 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
@@ -23,7 +23,10 @@ def prepare_shop_click_and_collect(
is_private=False,
click_and_collect_option="LOCAL",
)
- channel_data = create_channel(e2e_staff_api_client, warehouse_data["id"])
+ channel_data = create_channel(
+ e2e_staff_api_client,
+ warehouse_data["id"],
+ )
channel_id = channel_data["id"]
channel_slug = channel_data["slug"]
@@ -46,13 +49,21 @@ def test_unlogged_customer_buy_by_click_and_collect_CORE_0105(
]
assign_permissions(e2e_staff_api_client, permissions)
- channel_id, channel_slug, warehouse_id = prepare_shop_click_and_collect(
+ (
+ channel_id,
+ channel_slug,
+ warehouse_id,
+ ) = prepare_shop_click_and_collect(
e2e_staff_api_client,
)
variant_price = 10
- _, result_product_variant_id, _ = prepare_product(
+ (
+ _product_id,
+ product_variant_id,
+ _product_variant_price,
+ ) = prepare_product(
e2e_staff_api_client,
warehouse_id,
channel_id,
@@ -61,7 +72,10 @@ def test_unlogged_customer_buy_by_click_and_collect_CORE_0105(
# Step 1 - Create checkout and check collection point
lines = [
- {"variantId": result_product_variant_id, "quantity": 1},
+ {
+ "variantId": product_variant_id,
+ "quantity": 1,
+ },
]
checkout_data = checkout_create(
e2e_not_logged_api_client,
@@ -80,18 +94,25 @@ def test_unlogged_customer_buy_by_click_and_collect_CORE_0105(
# Step 2 - Assign delivery method
checkout_data = checkout_delivery_method_update(
- e2e_not_logged_api_client, checkout_id, collection_point["id"]
+ e2e_not_logged_api_client,
+ checkout_id,
+ collection_point["id"],
)
assert checkout_data["deliveryMethod"]["id"] == warehouse_id
total_gross_amount = checkout_data["totalPrice"]["gross"]["amount"]
# Step 3 - Create dummy payment
checkout_dummy_payment_create(
- e2e_not_logged_api_client, checkout_id, total_gross_amount
+ e2e_not_logged_api_client,
+ checkout_id,
+ total_gross_amount,
)
# Step 4 - Complete checkout and verify created order
- order_data = checkout_complete(e2e_not_logged_api_client, checkout_id)
+ order_data = checkout_complete(
+ e2e_not_logged_api_client,
+ checkout_id,
+ )
assert order_data["status"] == "UNFULFILLED"
assert order_data["total"]["gross"]["amount"] == total_gross_amount
assert order_data["deliveryMethod"]["id"] == warehouse_id
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.py
index 7fafad02b6..04eff3cc26 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
@@ -22,9 +22,12 @@ from .utils import (
def prepare_product(
e2e_staff_api_client,
):
- result_warehouse_id, result_channel_id, result_channel_slug, _ = prepare_shop(
- e2e_staff_api_client
- )
+ (
+ warehouse_id,
+ channel_id,
+ channel_slug,
+ _shipping_method_id,
+ ) = prepare_shop(e2e_staff_api_client)
product_type_data = create_product_type(
e2e_staff_api_client,
@@ -36,14 +39,22 @@ def prepare_product(
category_data = create_category(e2e_staff_api_client)
category_id = category_data["id"]
- product_data = create_product(e2e_staff_api_client, product_type_id, category_id)
+ product_data = create_product(
+ e2e_staff_api_client,
+ product_type_id,
+ category_id,
+ )
product_id = product_data["id"]
- create_product_channel_listing(e2e_staff_api_client, product_id, result_channel_id)
+ create_product_channel_listing(
+ e2e_staff_api_client,
+ product_id,
+ channel_id,
+ )
stocks = [
{
- "warehouse": result_warehouse_id,
+ "warehouse": warehouse_id,
"quantity": 5,
}
]
@@ -55,11 +66,11 @@ def prepare_product(
product_variant_id = product_variant_data["id"]
create_product_variant_channel_listing(
- e2e_staff_api_client, product_variant_id, result_channel_id, price=10
+ e2e_staff_api_client, product_variant_id, channel_id, price=10
)
create_digital_content(e2e_staff_api_client, product_variant_id)
- return product_variant_id, result_channel_slug
+ return product_variant_id, channel_slug
@pytest.mark.e2e
@@ -79,18 +90,21 @@ def test_process_checkout_with_digital_product_CORE_0101(
permission_manage_shipping,
]
assign_permissions(e2e_staff_api_client, permissions)
- product_variant_id, result_channel_slug = prepare_product(
+ product_variant_id, channel_slug = prepare_product(
e2e_staff_api_client,
)
# Step 1 - Create checkout.
lines = [
- {"variantId": product_variant_id, "quantity": 1},
+ {
+ "variantId": product_variant_id,
+ "quantity": 1,
+ },
]
checkout_data = checkout_create(
e2e_not_logged_api_client,
lines,
- result_channel_slug,
+ channel_slug,
)
checkout_id = checkout_data["id"]
@@ -98,15 +112,23 @@ def test_process_checkout_with_digital_product_CORE_0101(
assert checkout_data["isShippingRequired"] is False
# Step 2 - Set billing address for checkout.
- checkout_billing_address_update(e2e_not_logged_api_client, checkout_id)
+ checkout_billing_address_update(
+ e2e_not_logged_api_client,
+ checkout_id,
+ )
# Step 3 - Create payment for checkout.
checkout_dummy_payment_create(
- e2e_not_logged_api_client, checkout_id, total_gross_amount
+ e2e_not_logged_api_client,
+ checkout_id,
+ total_gross_amount,
)
# Step 4 - Complete checkout.
- order_data = checkout_complete(e2e_not_logged_api_client, checkout_id)
+ order_data = checkout_complete(
+ e2e_not_logged_api_client,
+ checkout_id,
+ )
assert order_data["isShippingRequired"] is False
assert order_data["status"] == "UNFULFILLED"
assert order_data["total"]["gross"]["amount"] == total_gross_amount
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.py
index be3cf7c7ab..b3404a445c 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
@@ -43,7 +43,11 @@ def test_process_checkout_with_physical_product_CORE_0102(
variant_price = 10
- _, result_product_variant_id, _ = prepare_product(
+ (
+ _product_id,
+ product_variant_id,
+ _product_variant_price,
+ ) = prepare_product(
e2e_staff_api_client,
warehouse_id,
channel_id,
@@ -52,7 +56,10 @@ def test_process_checkout_with_physical_product_CORE_0102(
# Step 1 - Create checkout.
lines = [
- {"variantId": result_product_variant_id, "quantity": 1},
+ {
+ "variantId": product_variant_id,
+ "quantity": 1,
+ },
]
checkout_data = checkout_create(
e2e_not_logged_api_client,
@@ -70,7 +77,8 @@ def test_process_checkout_with_physical_product_CORE_0102(
# Step 2 - Set shipping address for checkout.
checkout_data = checkout_shipping_address_update(
- e2e_not_logged_api_client, checkout_id
+ e2e_not_logged_api_client,
+ checkout_id,
)
assert len(checkout_data["shippingMethods"]) == 1
shipping_method_id = checkout_data["shippingMethods"][0]["id"]
@@ -86,11 +94,16 @@ def test_process_checkout_with_physical_product_CORE_0102(
# Step 4 - Create payment for checkout.
checkout_dummy_payment_create(
- e2e_not_logged_api_client, checkout_id, total_gross_amount
+ e2e_not_logged_api_client,
+ checkout_id,
+ total_gross_amount,
)
# Step 5 - Complete checkout.
- order_data = checkout_complete(e2e_not_logged_api_client, checkout_id)
+ order_data = checkout_complete(
+ e2e_not_logged_api_client,
+ checkout_id,
+ )
assert order_data["isShippingRequired"] is True
assert order_data["status"] == "UNFULFILLED"
assert order_data["total"]["gross"]["amount"] == total_gross_amount
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.py
index 892caa61e6..c269bc79dd 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
@@ -21,7 +21,9 @@ def prepare_shop_with_no_shipping_method(
)
channel_data = create_channel(
- e2e_staff_api_client, slug="test___0e00", warehouse_ids=warehouse_ids
+ e2e_staff_api_client,
+ slug="test___0e00",
+ warehouse_ids=warehouse_ids,
)
channel_id = channel_data["id"]
channel_ids = [channel_id]
@@ -63,7 +65,11 @@ def test_unlogged_customer_unable_to_buy_product_without_shipping_option_CORE_01
)
variant_price = 10
- _, result_product_variant_id, _ = prepare_product(
+ (
+ _product_id,
+ product_variant_id,
+ _product_variant_price,
+ ) = prepare_product(
e2e_staff_api_client,
warehouse_id,
channel_id,
@@ -72,7 +78,10 @@ def test_unlogged_customer_unable_to_buy_product_without_shipping_option_CORE_01
# Step 1 - Create checkout with no shipping method
lines = [
- {"variantId": result_product_variant_id, "quantity": 1},
+ {
+ "variantId": product_variant_id,
+ "quantity": 1,
+ },
]
checkout_data = checkout_create(
e2e_not_logged_api_client,
@@ -93,7 +102,9 @@ def test_unlogged_customer_unable_to_buy_product_without_shipping_option_CORE_01
# Step 2 - Create dummy payment and verify no purchase was made
checkout_payment_data = raw_checkout_dummy_payment_create(
- e2e_not_logged_api_client, checkout_id, total_gross_amount
+ e2e_not_logged_api_client,
+ checkout_id,
+ total_gross_amount,
)
errors = checkout_payment_data["errors"]
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.py
index 5ec0082ff4..e2f9b6673e 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
@@ -17,10 +17,10 @@ def prepare_product(
e2e_staff_api_client,
):
(
- result_warehouse_id,
- result_channel_id,
- result_channel_slug,
- _,
+ warehouse_id,
+ channel_id,
+ channel_slug,
+ _shipping_method_id,
) = prepare_shop(e2e_staff_api_client)
product_type_data = create_product_type(
@@ -41,18 +41,24 @@ def prepare_product(
)
product_id = product_data["id"]
- create_product_channel_listing(e2e_staff_api_client, product_id, result_channel_id)
+ create_product_channel_listing(
+ e2e_staff_api_client,
+ product_id,
+ channel_id,
+ )
stock_quantity = 5
stocks = [
{
- "warehouse": result_warehouse_id,
+ "warehouse": warehouse_id,
"quantity": stock_quantity,
}
]
variant_data = raw_create_product_variant(
- e2e_staff_api_client, product_id, stocks=stocks
+ e2e_staff_api_client,
+ product_id,
+ stocks=stocks,
)
product_variant_id = variant_data["productVariant"]["id"]
product_variant_name = variant_data["productVariant"]["name"]
@@ -60,11 +66,16 @@ def prepare_product(
create_product_variant_channel_listing(
e2e_staff_api_client,
product_variant_id,
- result_channel_id,
+ channel_id,
price=10,
)
- return product_variant_id, product_variant_name, result_channel_slug, stock_quantity
+ return (
+ product_variant_id,
+ product_variant_name,
+ channel_slug,
+ stock_quantity,
+ )
@pytest.mark.e2e
@@ -87,19 +98,22 @@ def test_unlogged_customer_cannot_buy_product_in_quantity_grater_than_stock_core
(
product_variant_id,
product_variant_name,
- result_channel_slug,
+ channel_slug,
stock_quantity,
) = prepare_product(
e2e_staff_api_client,
)
# Step 1 - Create checkout with product quantity greater than the available stock
lines = [
- {"variantId": product_variant_id, "quantity": stock_quantity + 1},
+ {
+ "variantId": product_variant_id,
+ "quantity": stock_quantity + 1,
+ },
]
checkout_data = raw_checkout_create(
e2e_not_logged_api_client,
lines,
- result_channel_slug,
+ channel_slug,
set_default_billing_address=True,
set_default_shipping_address=True,
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.py
index 39a21f4791..b6a7c4e265 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
@@ -129,10 +129,15 @@ def test_cannot_fullfill_order_with_invalid_shipping_method_core_0203(
price = 2
(
- _,
- result_product_variant_id,
- _,
- ) = prepare_product(e2e_staff_api_client, warehouse_id, channel_id, price)
+ _product_id,
+ product_variant_id,
+ _product_variant_price,
+ ) = prepare_product(
+ e2e_staff_api_client,
+ warehouse_id,
+ channel_id,
+ price,
+ )
# Step 1 - Create draft order and add lines
draft_order_input = {
@@ -145,10 +150,14 @@ def test_cannot_fullfill_order_with_invalid_shipping_method_core_0203(
order_id = data["order"]["id"]
assert order_id is not None
- lines = [{"variantId": result_product_variant_id, "quantity": 1}]
- order_lines = order_lines_create(e2e_staff_api_client, order_id, lines)
+ lines = [{"variantId": product_variant_id, "quantity": 1}]
+ order_lines = order_lines_create(
+ e2e_staff_api_client,
+ order_id,
+ lines,
+ )
order_product_variant_id = order_lines["order"]["lines"][0]["variant"]["id"]
- assert order_product_variant_id == result_product_variant_id
+ assert order_product_variant_id == product_variant_id
# Step 2 - Update order's shipping method
input = {
@@ -156,7 +165,11 @@ def test_cannot_fullfill_order_with_invalid_shipping_method_core_0203(
"shippingAddress": first_address,
"billingAddress": first_address,
}
- draft_order = draft_order_update(e2e_staff_api_client, order_id, input)
+ draft_order = draft_order_update(
+ e2e_staff_api_client,
+ order_id,
+ input,
+ )
order_shipping_id = draft_order["order"]["deliveryMethod"]["id"]
first_shipping_id_number = decode_base64_and_get_last_2_chars(
first_shipping_method_id
@@ -179,17 +192,27 @@ def test_cannot_fullfill_order_with_invalid_shipping_method_core_0203(
"streetAddress2": "13/1",
}
update_input = {"shippingAddress": second_address}
- draft_update = draft_order_update(e2e_staff_api_client, order_id, update_input)
+ 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
# Step 4 - Complete the order and check that 2nd shipping method is now available
- order_complete = raw_draft_order_complete(e2e_staff_api_client, order_id)
+ order_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"
)
- order_details = order_query(e2e_staff_api_client, order_id)
+ order_details = order_query(
+ 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
diff --git a/saleor/tests/e2e/orders/test_delete_draft_order.py b/saleor/tests/e2e/orders/test_delete_draft_order.py
index 64ae92c41a..de5bdadd10 100644
--- a/saleor/tests/e2e/orders/test_delete_draft_order.py
+++ b/saleor/tests/e2e/orders/test_delete_draft_order.py
@@ -35,19 +35,26 @@ def test_delete_draft_order_CORE_0205(
price = 10
(
- result_warehouse_id,
- result_channel_id,
- _,
- result_shipping_method_id,
+ warehouse_id,
+ channel_id,
+ _channel_slug,
+ shipping_method_id,
) = prepare_shop(e2e_staff_api_client)
- _, result_product_variant_id, _ = prepare_product(
- e2e_staff_api_client, result_warehouse_id, result_channel_id, price
+ (
+ _product_id,
+ product_variant_id,
+ _product_variant_price,
+ ) = prepare_product(
+ e2e_staff_api_client,
+ warehouse_id,
+ channel_id,
+ price,
)
# Step 1 - Create draft order
draft_order_input = {
- "channelId": result_channel_id,
+ "channelId": channel_id,
"userEmail": "[email protected]",
"shippingAddress": DEFAULT_ADDRESS,
"billingAddress": DEFAULT_ADDRESS,
@@ -60,19 +67,35 @@ def test_delete_draft_order_CORE_0205(
assert order_id is not None
# Step 2 - Add lines to the order
- lines = [{"variantId": result_product_variant_id, "quantity": 1}]
- order_lines = order_lines_create(e2e_staff_api_client, order_id, lines)
+ lines = [
+ {
+ "variantId": product_variant_id,
+ "quantity": 1,
+ }
+ ]
+ order_lines = order_lines_create(
+ e2e_staff_api_client,
+ order_id,
+ lines,
+ )
order_product_variant_id = order_lines["order"]["lines"][0]["variant"]["id"]
- assert order_product_variant_id == result_product_variant_id
+ assert order_product_variant_id == product_variant_id
# Step 3 - Update order's shipping method
- input = {"shippingMethod": result_shipping_method_id}
- draft_order = draft_order_update(e2e_staff_api_client, order_id, input)
+ input = {"shippingMethod": shipping_method_id}
+ draft_order = draft_order_update(
+ e2e_staff_api_client,
+ order_id,
+ input,
+ )
order_shipping_id = draft_order["order"]["deliveryMethod"]["id"]
assert order_shipping_id is not None
# Step 4 - Delete the order
- cancelled_order = draft_order_delete(e2e_staff_api_client, order_id)
+ cancelled_order = draft_order_delete(
+ e2e_staff_api_client,
+ order_id,
+ )
assert cancelled_order["order"]["status"] is not None
order = order_query(e2e_staff_api_client, order_id)
assert order is None
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.py
index cfa308602d..98642eca90 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
@@ -32,19 +32,26 @@ def test_order_created_by_staff_member_CORE_0201(
price = 10
(
- result_warehouse_id,
- result_channel_id,
- _,
- result_shipping_method_id,
+ warehouse_id,
+ channel_id,
+ _channel_slug,
+ shipping_method_id,
) = prepare_shop(e2e_staff_api_client)
- _, result_product_variant_id, _ = prepare_product(
- e2e_staff_api_client, result_warehouse_id, result_channel_id, price
+ (
+ _product_id,
+ product_variant_id,
+ _product_variant_price,
+ ) = prepare_product(
+ e2e_staff_api_client,
+ warehouse_id,
+ channel_id,
+ price,
)
# Step 1 - Create draft order
draft_order_input = {
- "channelId": result_channel_id,
+ "channelId": channel_id,
}
data = draft_order_create(
e2e_staff_api_client,
@@ -54,10 +61,19 @@ def test_order_created_by_staff_member_CORE_0201(
assert order_id is not None
# Step 2 - Add lines to the order
- lines = [{"variantId": result_product_variant_id, "quantity": 1}]
- order_lines = order_lines_create(e2e_staff_api_client, order_id, lines)
+ lines = [
+ {
+ "variantId": product_variant_id,
+ "quantity": 1,
+ }
+ ]
+ order_lines = order_lines_create(
+ e2e_staff_api_client,
+ order_id,
+ lines,
+ )
order_product_variant_id = order_lines["order"]["lines"][0]["variant"]["id"]
- assert order_product_variant_id == result_product_variant_id
+ assert order_product_variant_id == product_variant_id
# Step 3 - Update order's addresses and email
input = {
@@ -65,21 +81,32 @@ def test_order_created_by_staff_member_CORE_0201(
"shippingAddress": DEFAULT_ADDRESS,
"billingAddress": DEFAULT_ADDRESS,
}
- draft_order = draft_order_update(e2e_staff_api_client, order_id, input)
+ draft_order = draft_order_update(
+ e2e_staff_api_client,
+ order_id,
+ input,
+ )
assert draft_order["order"]["userEmail"] == "[email protected]"
assert draft_order["order"]["shippingAddress"] is not None
assert draft_order["order"]["billingAddress"] is not None
# Step 4 - Update order's shipping method
- input = {"shippingMethod": result_shipping_method_id}
- draft_order = draft_order_update(e2e_staff_api_client, order_id, input)
+ input = {"shippingMethod": shipping_method_id}
+ draft_order = draft_order_update(
+ e2e_staff_api_client,
+ order_id,
+ input,
+ )
order_shipping_id = draft_order["order"]["deliveryMethod"]["id"]
assert order_shipping_id is not None
# Step 5 - Complete the order and check it's status
- order = draft_order_complete(e2e_staff_api_client, order_id)
+ order = draft_order_complete(
+ e2e_staff_api_client,
+ order_id,
+ )
order_complete_id = order["order"]["id"]
assert order_complete_id == order_id
order_line = order["order"]["lines"][0]
- assert order_line["productVariantId"] == result_product_variant_id
+ assert order_line["productVariantId"] == product_variant_id
assert order["order"]["status"] == "UNFULFILLED"
diff --git a/saleor/tests/e2e/orders/test_order_mark_as_paid.py b/saleor/tests/e2e/orders/test_order_mark_as_paid.py
index ba49ec6fa1..a5db14cfd6 100644
--- a/saleor/tests/e2e/orders/test_order_mark_as_paid.py
+++ b/saleor/tests/e2e/orders/test_order_mark_as_paid.py
@@ -35,19 +35,22 @@ def test_order_mark_as_paid_CORE_0208(
price = 10
(
- result_warehouse_id,
- result_channel_id,
- _,
- result_shipping_method_id,
+ warehouse_id,
+ channel_id,
+ _channel_slug,
+ shipping_method_id,
) = prepare_shop(e2e_staff_api_client)
- _, result_product_variant_id, _ = prepare_product(
- e2e_staff_api_client, result_warehouse_id, result_channel_id, price
+ _product_id, product_variant_id, _product_variant_price = prepare_product(
+ e2e_staff_api_client,
+ warehouse_id,
+ channel_id,
+ price,
)
# Step 1 - Create draft order
draft_order_input = {
- "channelId": result_channel_id,
+ "channelId": channel_id,
"userEmail": "[email protected]",
"shippingAddress": DEFAULT_ADDRESS,
"billingAddress": DEFAULT_ADDRESS,
@@ -60,27 +63,46 @@ def test_order_mark_as_paid_CORE_0208(
assert order_id is not None
# Step 2 - Add lines to the order
- lines = [{"variantId": result_product_variant_id, "quantity": 1}]
- order_lines = order_lines_create(e2e_staff_api_client, order_id, lines)
+ lines = [
+ {
+ "variantId": product_variant_id,
+ "quantity": 1,
+ }
+ ]
+ order_lines = order_lines_create(
+ e2e_staff_api_client,
+ order_id,
+ lines,
+ )
order_product_variant_id = order_lines["order"]["lines"][0]["variant"]["id"]
- assert order_product_variant_id == result_product_variant_id
+ assert order_product_variant_id == product_variant_id
# Step 3 - Update order's shipping method
- input = {"shippingMethod": result_shipping_method_id}
- draft_order = draft_order_update(e2e_staff_api_client, order_id, input)
+ input = {"shippingMethod": shipping_method_id}
+ draft_order = draft_order_update(
+ e2e_staff_api_client,
+ order_id,
+ input,
+ )
order_shipping_id = draft_order["order"]["deliveryMethod"]["id"]
assert order_shipping_id is not None
# Step 4 - Complete the order and check it's status
- order = draft_order_complete(e2e_staff_api_client, order_id)
+ order = draft_order_complete(
+ e2e_staff_api_client,
+ order_id,
+ )
order_complete_id = order["order"]["id"]
assert order_complete_id == order_id
order_line = order["order"]["lines"][0]
- assert order_line["productVariantId"] == result_product_variant_id
+ assert order_line["productVariantId"] == product_variant_id
assert order["order"]["status"] == "UNFULFILLED"
# Step 5 - Mark order as paid
- order_paid_data = mark_order_paid(e2e_staff_api_client, order_id)
+ order_paid_data = mark_order_paid(
+ e2e_staff_api_client,
+ order_id,
+ )
assert order_paid_data["order"]["isPaid"] is True
assert order_paid_data["order"]["paymentStatus"] == "FULLY_CHARGED"
assert order_paid_data["order"]["status"] == "UNFULFILLED"
diff --git a/saleor/tests/e2e/orders/test_order_products_on_fixed_sale.py b/saleor/tests/e2e/orders/test_order_products_on_fixed_sale.py
index e1cceead7d..37c77504c1 100644
--- a/saleor/tests/e2e/orders/test_order_products_on_fixed_sale.py
+++ b/saleor/tests/e2e/orders/test_order_products_on_fixed_sale.py
@@ -21,7 +21,11 @@ def prepare_sale_for_product(
sale_discount_value,
):
sale_name = "Sale"
- sale = create_sale(e2e_staff_api_client, sale_name, sale_discount_type)
+ sale = create_sale(
+ e2e_staff_api_client,
+ sale_name,
+ sale_discount_type,
+ )
sale_id = sale["id"]
sale_listing_input = [
{
@@ -30,10 +34,16 @@ def prepare_sale_for_product(
}
]
create_sale_channel_listing(
- e2e_staff_api_client, sale_id, add_channels=sale_listing_input
+ e2e_staff_api_client,
+ sale_id,
+ add_channels=sale_listing_input,
)
catalogue_input = {"products": [product_id]}
- sale_catalogues_add(e2e_staff_api_client, sale_id, catalogue_input)
+ sale_catalogues_add(
+ e2e_staff_api_client,
+ sale_id,
+ catalogue_input,
+ )
return sale_id, sale_discount_value
@@ -59,12 +69,22 @@ def test_order_products_on_fixed_sale_CORE_1001(
]
assign_permissions(e2e_staff_api_client, permissions)
- warehouse_id, channel_id, _channel_slug, shipping_method_id = prepare_shop(
- e2e_staff_api_client
- )
+ (
+ warehouse_id,
+ channel_id,
+ _channel_slug,
+ shipping_method_id,
+ ) = prepare_shop(e2e_staff_api_client)
- product_id, product_variant_id, product_variant_price = prepare_product(
- e2e_staff_api_client, warehouse_id, channel_id, variant_price="41.99"
+ (
+ product_id,
+ product_variant_id,
+ product_variant_price,
+ ) = prepare_product(
+ e2e_staff_api_client,
+ warehouse_id,
+ channel_id,
+ variant_price="41.99",
)
sale_id, sale_discount_value = prepare_sale_for_product(
@@ -81,7 +101,10 @@ def test_order_products_on_fixed_sale_CORE_1001(
"billingAddress": DEFAULT_ADDRESS,
"shippingAddress": DEFAULT_ADDRESS,
}
- data = draft_order_create(e2e_staff_api_client, input)
+ data = draft_order_create(
+ e2e_staff_api_client,
+ input,
+ )
order_id = data["order"]["id"]
assert data["order"]["billingAddress"] is not None
assert data["order"]["shippingAddress"] is not None
@@ -89,7 +112,11 @@ def test_order_products_on_fixed_sale_CORE_1001(
# Step 2 - Add product on sale to draft order
lines = [{"variantId": product_variant_id, "quantity": 1}]
- order_lines = order_lines_create(e2e_staff_api_client, order_id, lines)
+ order_lines = order_lines_create(
+ e2e_staff_api_client,
+ order_id,
+ lines,
+ )
draft_line = order_lines["order"]["lines"][0]
assert draft_line["variant"]["id"] == product_variant_id
@@ -100,14 +127,21 @@ def test_order_products_on_fixed_sale_CORE_1001(
# Step 3 - Add a shipping method to the order
input = {"shippingMethod": shipping_method_id}
- draft_update = draft_order_update(e2e_staff_api_client, order_id, input)
+ draft_update = draft_order_update(
+ e2e_staff_api_client,
+ order_id,
+ input,
+ )
order_shipping_id = draft_update["order"]["deliveryMethod"]["id"]
assert order_shipping_id is not None
shipping_price = draft_update["order"]["shippingPrice"]["gross"]["amount"]
# Step 4 - Complete the draft order
- order = draft_order_complete(e2e_staff_api_client, order_id)
+ order = draft_order_complete(
+ e2e_staff_api_client,
+ order_id,
+ )
assert order["order"]["status"] == "UNFULFILLED"
total = order["order"]["total"]["gross"]["amount"]
assert total == round(float(shipping_price + unit_price), 2)
diff --git a/saleor/tests/e2e/orders/test_order_products_on_percentage_sale.py b/saleor/tests/e2e/orders/test_order_products_on_percentage_sale.py
index fae13ad1c8..0f537d90f7 100644
--- a/saleor/tests/e2e/orders/test_order_products_on_percentage_sale.py
+++ b/saleor/tests/e2e/orders/test_order_products_on_percentage_sale.py
@@ -21,7 +21,11 @@ def prepare_sale_for_product(
sale_discount_value,
):
sale_name = "Sale"
- sale = create_sale(e2e_staff_api_client, sale_name, sale_discount_type)
+ sale = create_sale(
+ e2e_staff_api_client,
+ sale_name,
+ sale_discount_type,
+ )
sale_id = sale["id"]
sale_listing_input = [
{
@@ -30,10 +34,16 @@ def prepare_sale_for_product(
}
]
create_sale_channel_listing(
- e2e_staff_api_client, sale_id, add_channels=sale_listing_input
+ e2e_staff_api_client,
+ sale_id,
+ add_channels=sale_listing_input,
)
catalogue_input = {"products": [product_id]}
- sale_catalogues_add(e2e_staff_api_client, sale_id, catalogue_input)
+ sale_catalogues_add(
+ e2e_staff_api_client,
+ sale_id,
+ catalogue_input,
+ )
return sale_id, sale_discount_value
@@ -59,12 +69,22 @@ def test_order_products_on_percentage_sale_CORE_1003(
]
assign_permissions(e2e_staff_api_client, permissions)
- warehouse_id, channel_id, _channel_slug, shipping_method_id = prepare_shop(
- e2e_staff_api_client
- )
+ (
+ warehouse_id,
+ channel_id,
+ _channel_slug,
+ shipping_method_id,
+ ) = prepare_shop(e2e_staff_api_client)
- product_id, product_variant_id, product_variant_price = prepare_product(
- e2e_staff_api_client, warehouse_id, channel_id, variant_price="11.99"
+ (
+ product_id,
+ product_variant_id,
+ product_variant_price,
+ ) = prepare_product(
+ e2e_staff_api_client,
+ warehouse_id,
+ channel_id,
+ variant_price="11.99",
)
sale_id, sale_discount_value = prepare_sale_for_product(
@@ -81,7 +101,10 @@ def test_order_products_on_percentage_sale_CORE_1003(
"billingAddress": DEFAULT_ADDRESS,
"shippingAddress": DEFAULT_ADDRESS,
}
- data = draft_order_create(e2e_staff_api_client, input)
+ data = draft_order_create(
+ e2e_staff_api_client,
+ input,
+ )
order_id = data["order"]["id"]
assert data["order"]["billingAddress"] is not None
assert data["order"]["shippingAddress"] is not None
@@ -89,7 +112,11 @@ def test_order_products_on_percentage_sale_CORE_1003(
# Step 2 - Add product on sale to draft order
lines = [{"variantId": product_variant_id, "quantity": 1}]
- order_lines = order_lines_create(e2e_staff_api_client, order_id, lines)
+ order_lines = order_lines_create(
+ e2e_staff_api_client,
+ order_id,
+ lines,
+ )
draft_line = order_lines["order"]["lines"][0]
assert draft_line["variant"]["id"] == product_variant_id
@@ -101,14 +128,21 @@ def test_order_products_on_percentage_sale_CORE_1003(
# Step 3 - Add a shipping method to the order
input = {"shippingMethod": shipping_method_id}
- draft_update = draft_order_update(e2e_staff_api_client, order_id, input)
+ 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"]
assert order_shipping_id is not None
# Step 4 - Complete the draft order
- order = draft_order_complete(e2e_staff_api_client, order_id)
+ order = draft_order_complete(
+ e2e_staff_api_client,
+ order_id,
+ )
assert order["order"]["status"] == "UNFULFILLED"
total = order["order"]["total"]["gross"]["amount"]
assert total == round(float(shipping_price + unit_price), 2)
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.py
index 3d56d6e8ec..78536f796a 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
@@ -32,22 +32,26 @@ def test_order_staff_can_overwrite_prices_CORE_0202(
regular_variant_price = 10
(
- result_warehouse_id,
- result_channel_id,
- _,
- result_shipping_method_id,
+ warehouse_id,
+ channel_id,
+ _channel_slug,
+ shipping_method_id,
) = prepare_shop(e2e_staff_api_client)
- _, result_product_variant_id, _ = prepare_product(
+ (
+ _product_id,
+ product_variant_id,
+ _product_variant_price,
+ ) = prepare_product(
e2e_staff_api_client,
- result_warehouse_id,
- result_channel_id,
+ warehouse_id,
+ channel_id,
regular_variant_price,
)
# Step 1 - Create draft order
draft_order_input = {
- "channelId": result_channel_id,
+ "channelId": channel_id,
"userEmail": "[email protected]",
"shippingAddress": DEFAULT_ADDRESS,
"billingAddress": DEFAULT_ADDRESS,
@@ -62,29 +66,40 @@ def test_order_staff_can_overwrite_prices_CORE_0202(
# Step 2 - Add lines to the order and overwrite variant's price
lines = [
{
- "variantId": result_product_variant_id,
+ "variantId": product_variant_id,
"quantity": 1,
"price": 3,
}
]
- order_lines = order_lines_create(e2e_staff_api_client, order_id, lines)
+ order_lines = order_lines_create(
+ e2e_staff_api_client,
+ order_id,
+ lines,
+ )
order_product_variant_id = order_lines["order"]["lines"][0]["variant"]["id"]
- assert order_product_variant_id == result_product_variant_id
+ assert order_product_variant_id == product_variant_id
new_price = order_lines["order"]["lines"][0]["unitPrice"]["gross"]["amount"]
assert new_price != regular_variant_price
# Step 3 - Update order's shipping method
- input = {"shippingMethod": result_shipping_method_id}
- draft_order = draft_order_update(e2e_staff_api_client, order_id, input)
+ input = {"shippingMethod": shipping_method_id}
+ draft_order = draft_order_update(
+ e2e_staff_api_client,
+ order_id,
+ input,
+ )
order_shipping_id = draft_order["order"]["deliveryMethod"]["id"]
assert order_shipping_id is not None
# Step 4 - Complete the order
- order = draft_order_complete(e2e_staff_api_client, order_id)
+ order = draft_order_complete(
+ e2e_staff_api_client,
+ order_id,
+ )
order_complete_id = order["order"]["id"]
assert order_complete_id == order_id
order_line = order["order"]["lines"][0]
order_variant_price = order_line["unitPrice"]["gross"]["amount"]
assert order_variant_price != regular_variant_price
- assert order_line["productVariantId"] == result_product_variant_id
+ assert order_line["productVariantId"] == product_variant_id
assert order["order"]["status"] == "UNFULFILLED"
diff --git a/saleor/tests/e2e/product/utils/preparing_product.py b/saleor/tests/e2e/product/utils/preparing_product.py
index 1de18174a5..7a2b7897c3 100644
--- a/saleor/tests/e2e/product/utils/preparing_product.py
+++ b/saleor/tests/e2e/product/utils/preparing_product.py
@@ -49,7 +49,10 @@ def prepare_product(
product_variant_id = product_variant_data["id"]
product_variant_channel_listing_data = create_product_variant_channel_listing(
- e2e_staff_api_client, product_variant_id, channel_id, variant_price
+ e2e_staff_api_client,
+ product_variant_id,
+ channel_id,
+ variant_price,
)
product_variant_price = product_variant_channel_listing_data["channelListings"][0][
"price"
diff --git a/saleor/tests/e2e/shop/utils/preparing_shop.py b/saleor/tests/e2e/shop/utils/preparing_shop.py
index d05e7dcd7f..d903814ccc 100644
--- a/saleor/tests/e2e/shop/utils/preparing_shop.py
+++ b/saleor/tests/e2e/shop/utils/preparing_shop.py
@@ -27,10 +27,18 @@ def prepare_shop(e2e_staff_api_client):
shipping_zone_id = shipping_zone_data["id"]
shipping_method_data = create_shipping_method(
- e2e_staff_api_client, shipping_zone_id
+ 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
+ e2e_staff_api_client,
+ shipping_method_id,
+ channel_id,
+ )
+ return (
+ warehouse_id,
+ channel_id,
+ channel_slug,
+ shipping_method_id,
)
- return warehouse_id, channel_id, channel_slug, shipping_method_id