Skip to content

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

Move tests to more suitable module

Mira Szewczykda88972e6be0
diff --git a/tests/test_product.py b/tests/test_product.py
index 54b53b8ba3..5bef5af653 100644
--- a/tests/test_product.py
+++ b/tests/test_product.py
@@ -14,32 +14,6 @@ from saleor.product.thumbnails import create_product_thumbnails
from saleor.product.utils.attributes import associate_attribute_values_to_instance
from saleor.product.utils.costs import get_margin_for_variant
from saleor.product.utils.digital_products import increment_download_count
-from saleor.stock.management import (
- allocate_stock,
- deallocate_stock,
- decrease_stock,
- increase_stock,
-)
-
-
- "func, expected_quantity, expected_quantity_allocated",
- (
- (increase_stock, 150, 80),
- (decrease_stock, 50, 30),
- (deallocate_stock, 100, 30),
- (allocate_stock, 100, 130),
- ),
-)
-def test_stock_utils(product, func, expected_quantity, expected_quantity_allocated):
- variant = product.variants.first()
- variant.quantity = 100
- variant.quantity_allocated = 80
- variant.save()
- func(variant, 50)
- variant.refresh_from_db()
- assert variant.quantity == expected_quantity
- assert variant.quantity_allocated == expected_quantity_allocated
def test_filtering_by_attribute(db, color_attribute, category, settings):
diff --git a/tests/test_stock.py b/tests/test_stock.py
index 87eb932861..1cdc4b74be 100644
--- a/tests/test_stock.py
+++ b/tests/test_stock.py
@@ -6,6 +6,12 @@ from saleor.stock.availability import (
check_stock_quantity,
products_with_low_stock,
)
+from saleor.stock.management import (
+ allocate_stock,
+ deallocate_stock,
+ decrease_stock,
+ increase_stock,
+)
from saleor.stock.models import Stock
COUNTRY_CODE = "US"
@@ -86,3 +92,24 @@ def test_products_with_low_stock_filter_properly(stock, settings):
settings.LOW_STOCK_THRESHOLD = quantities[0] + 1
result = products_with_low_stock()
assert len(result) == 0
+
+
+ "func, expected_quantity, expected_quantity_allocated",
+ (
+ (increase_stock, 150, 80),
+ (decrease_stock, 50, 30),
+ (deallocate_stock, 100, 30),
+ (allocate_stock, 100, 130),
+ ),
+)
+def test_changing_stock(product, func, expected_quantity, expected_quantity_allocated):
+ stock = Stock.objects.first()
+ stock.quantity = 100
+ stock.quantity_allocated = 80
+ stock.save()
+ variant = stock.product_variant
+ func(variant, COUNTRY_CODE, 50)
+ stock.refresh_from_db()
+ assert stock.quantity == expected_quantity
+ assert stock.quantity_allocated == expected_quantity_allocated