Skip to content

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

Update tests to work with stock location as model

Mira Szewczyk8df818bf5744
diff --git a/tests/conftest.py b/tests/conftest.py
index fd8b761444..c6fa240075 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -10,7 +10,7 @@ from saleor.cart.models import Cart
from saleor.checkout.core import Checkout
from saleor.discount.models import Voucher
from saleor.order.models import Order
-from saleor.product.models import Product, ProductVariant, Stock
+from saleor.product.models import Product, ProductVariant, Stock, StockLocation
from saleor.shipping.models import ShippingMethod
from saleor.userprofile.models import Address, User
@@ -92,15 +92,18 @@ def product_in_stock(db): # pylint: disable=W0613
product = Product.objects.create(
name='Test product', price=10, weight=1)
variant = ProductVariant.objects.create(product=product, sku='123')
+ warehouse_1 = StockLocation.objects.create(location='Warehouse 1')
+ warehouse_2 = StockLocation.objects.create(location='Warehouse 2')
+ warehouse_3 = StockLocation.objects.create(location='Warehouse 3')
Stock.objects.create(
variant=variant, cost_price=1, quantity=5, quantity_allocated=5,
- location='Warehouse 1')
+ location=warehouse_1)
Stock.objects.create(
variant=variant, cost_price=100, quantity=5, quantity_allocated=5,
- location='Warehouse 2')
+ location=warehouse_2)
Stock.objects.create(
variant=variant, cost_price=10, quantity=5, quantity_allocated=0,
- location='Warehouse 3')
+ location=warehouse_3)
return product
diff --git a/tests/dashboard/test_product.py b/tests/dashboard/test_product.py
index 15e9520cce..227244d041 100644
--- a/tests/dashboard/test_product.py
+++ b/tests/dashboard/test_product.py
@@ -16,7 +16,7 @@ def test_stock_record_update_works(admin_client, product_in_stock):
'product_pk': product_in_stock.pk,
'stock_pk': stock.pk})
admin_client.post(url, {
- 'variant': stock.variant_id, 'location': stock.location,
+ 'variant': stock.variant_id, 'location': stock.location.id,
'cost_price': stock.cost_price.net,
'quantity': quantity + 5})
new_stock = variant.stock.get(pk=stock.pk)