Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Rename product_in_stock to producT
Pacu28ff27d3d246a
diff --git a/saleor/cart/models.py b/saleor/cart/models.pyindex 7db118f410..6096a9d185 100644--- a/saleor/cart/models.py+++ b/saleor/cart/models.py@@ -1,7 +1,6 @@"""Cart-related ORM models."""from collections import namedtuplefrom decimal import Decimal-from itertools import groupbyfrom uuid import uuid4from django.conf import settings@@ -53,8 +52,7 @@ class CartQueryset(models.QuerySet):return self.prefetch_related('lines__variant__product__category','lines__variant__product__images',- 'lines__variant__product__product_type__product_attributes__values', # noqa- 'lines__variant__stock')+ 'lines__variant__product__product_type__product_attributes__values') # noqaclass Cart(models.Model):diff --git a/saleor/core/permissions.py b/saleor/core/permissions.pyindex 562b4475c8..558065e7f2 100644--- a/saleor/core/permissions.py+++ b/saleor/core/permissions.py@@ -13,8 +13,6 @@ MODELS_PERMISSIONS = ['product.edit_product','product.view_properties','product.edit_properties',- 'product.view_stock_location',- 'product.edit_stock_location','sale.view_sale','sale.edit_sale','shipping.view_shipping',diff --git a/saleor/core/utils/random_data.py b/saleor/core/utils/random_data.pyindex f801d52038..2997a685a9 100644--- a/saleor/core/utils/random_data.py+++ b/saleor/core/utils/random_data.py@@ -23,13 +23,12 @@ from ...order.utils import update_order_statusfrom ...page.models import Pagefrom ...product.models import (AttributeChoiceValue, Category, Collection, Product, ProductAttribute,- ProductImage, ProductType, ProductVariant, Stock, StockLocation)+ ProductImage, ProductType, ProductVariant)from ...product.thumbnails import create_product_thumbnailsfrom ...product.utils.attributes import get_name_from_attributesfrom ...shipping.models import ANY_COUNTRY, ShippingMethodfake = Factory.create()-STOCK_LOCATION = 'default'DELIVERY_REGIONS = [ANY_COUNTRY, 'US', 'PL', 'DE', 'GB']PRODUCTS_LIST_DIR = 'products-list/'@@ -283,26 +282,16 @@ def create_product(**kwargs):return Product.objects.create(**defaults)-def create_stock(variant, **kwargs):- default_location = StockLocation.objects.get_or_create(- name=STOCK_LOCATION)[0]- defaults = {- 'variant': variant,- 'location': default_location,- 'quantity': fake.random_int(1, 50)}- defaults.update(kwargs)- return Stock.objects.create(**defaults)--def create_variant(product, **kwargs):defaults = {- 'product': product}+ 'product': product,+ 'quantity': fake.random_int(1, 50),+ 'cost_price': fake.money()}defaults.update(kwargs)variant = ProductVariant(**defaults)if variant.attributes:variant.name = get_name_from_attributes(variant)variant.save()- create_stock(variant)return variantdiff --git a/saleor/dashboard/order/forms.py b/saleor/dashboard/order/forms.pyindex 8f5a8d9c5b..2965bedcd4 100644--- a/saleor/dashboard/order/forms.py+++ b/saleor/dashboard/order/forms.py@@ -22,7 +22,7 @@ from ...order.utils import (add_variant_to_order, cancel_fulfillment, cancel_order,change_order_line_quantity, merge_duplicates_into_order_line,recalculate_order)-from ...product.models import Product, ProductVariant, Stock+from ...product.models import Product, ProductVariantfrom ...product.utils import allocate_stock, deallocate_stockfrom ...shipping.models import ANY_COUNTRY, ShippingMethodCountryfrom ..forms import AjaxSelect2ChoiceFielddiff --git a/saleor/dashboard/product/forms.py b/saleor/dashboard/product/forms.pyindex b6e9b7a8ab..8fb9b15937 100644--- a/saleor/dashboard/product/forms.py+++ b/saleor/dashboard/product/forms.py@@ -55,11 +55,9 @@ class ProductTypeSelectorForm(forms.Form):class StockForm(forms.ModelForm):class Meta:- model = Stock- exclude = ['quantity_allocated', 'variant']+ model = ProductVariant+ exclude = ['quantity_allocated']labels = {- 'location': pgettext_lazy(- 'Stock location', 'Location'),'quantity': pgettext_lazy('Integer number', 'Quantity'),'cost_price': pgettext_lazy(@@ -69,22 +67,6 @@ class StockForm(forms.ModelForm):self.variant = kwargs.pop('variant')super().__init__(*args, **kwargs)- def clean_location(self):- location = self.cleaned_data['location']- if (- not self.instance.pk and- self.variant.stock.filter(location=location).exists()):- self.add_error(- 'location',- pgettext_lazy(- 'stock form error',- 'Stock item for this location and variant already exists'))- return location-- def save(self, commit=True):- self.instance.variant = self.variant- return super().save(commit)-class ProductTypeForm(forms.ModelForm):class Meta:@@ -387,15 +369,6 @@ class ProductAttributeForm(forms.ModelForm):'Product internal name', 'Internal name')}-class StockLocationForm(forms.ModelForm):- class Meta:- model = StockLocation- exclude = []- labels = {- 'name': pgettext_lazy(- 'Item name', 'Name')}--class AttributeChoiceValueForm(forms.ModelForm):class Meta:model = AttributeChoiceValuediff --git a/saleor/product/__init__.py b/saleor/product/__init__.pyindex df767e1f52..7e17397aa9 100644--- a/saleor/product/__init__.py+++ b/saleor/product/__init__.py@@ -4,7 +4,6 @@ from django.utils.translation import pgettext_lazyclass ProductAvailabilityStatus:NOT_PUBLISHED = 'not-published'VARIANTS_MISSSING = 'variants-missing'- NOT_CARRIED = 'not-carried'OUT_OF_STOCK = 'out-of-stock'LOW_STOCK = 'low-stock'NOT_YET_AVAILABLE = 'not-yet-available'@@ -16,8 +15,6 @@ class ProductAvailabilityStatus:return pgettext_lazy('Product status', 'not published')elif status == ProductAvailabilityStatus.VARIANTS_MISSSING:return pgettext_lazy('Product status', 'variants missing')- elif status == ProductAvailabilityStatus.NOT_CARRIED:- return pgettext_lazy('Product status', 'not carried')elif status == ProductAvailabilityStatus.OUT_OF_STOCK:return pgettext_lazy('Product status', 'out of stock')elif status == ProductAvailabilityStatus.LOW_STOCK:@@ -32,15 +29,12 @@ class ProductAvailabilityStatus:class VariantAvailabilityStatus:AVAILABLE = 'available'- NOT_CARRIED = 'not-carried'OUT_OF_STOCK = 'out-of-stock'@staticmethoddef get_display(status):if status == VariantAvailabilityStatus.AVAILABLE:return pgettext_lazy('Variant status', 'available')- elif status == VariantAvailabilityStatus.NOT_CARRIED:- return pgettext_lazy('Variant status', 'not carried')elif status == VariantAvailabilityStatus.OUT_OF_STOCK:return pgettext_lazy('Variant status', 'out of stock')else:diff --git a/tests/conftest.py b/tests/conftest.pyindex 97303d95d3..444f186102 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -86,8 +86,8 @@ def request_cart(cart, monkeypatch):@pytest.fixture-def request_cart_with_item(product_in_stock, request_cart):- variant = product_in_stock.variants.get()+def request_cart_with_item(product, request_cart):+ variant = product.variants.get()# Prepare some datarequest_cart.add(variant)return request_cart@@ -256,7 +256,7 @@ def product_type(color_attribute, size_attribute):@pytest.fixture-def product_in_stock(product_type, default_category):+def product(product_type, default_category):product_attr = product_type.product_attributes.first()attr_value = product_attr.values.first()attributes = {smart_text(product_attr.pk): smart_text(attr_value.pk)}@@ -352,8 +352,7 @@ def product_image():@pytest.fixture-def product_with_image(product_in_stock, product_image):- product = product_in_stock+def product_with_image(product, product_image):ProductImage.objects.create(product=product, image=product_image)return productdiff --git a/tests/dashboard/test_collection.py b/tests/dashboard/test_collection.pyindex 869c637c97..b97f2ea611 100644--- a/tests/dashboard/test_collection.py+++ b/tests/dashboard/test_collection.py@@ -28,8 +28,8 @@ def test_collection_form_name():@pytest.mark.django_db-def test_collection_form_with_products(product_in_stock):- data = {'name': 'Test collection', 'products': [product_in_stock.id]}+def test_collection_form_with_products(product):+ data = {'name': 'Test collection', 'products': [product.id]}form = CollectionForm(data)assert form.is_valid()@@ -49,19 +49,19 @@ def test_collection_create_view(admin_client):assert redirected_url == reverse('dashboard:collection-list')-def test_collection_update_view(admin_client, collection, product_in_stock):+def test_collection_update_view(admin_client, collection, product):url = reverse('dashboard:collection-update', kwargs={'pk': collection.id})response = admin_client.get(url)assert response.status_code == 200current_name = collection.name- data = {'name': 'New name', 'products': [product_in_stock.id]}+ data = {'name': 'New name', 'products': [product.id]}response = admin_client.post(url, data)assert response.status_code == 302collection.refresh_from_db()assert not current_name == collection.name- assert list(collection.products.all()) == [product_in_stock]+ assert list(collection.products.all()) == [product]def test_collection_delete_view(admin_client, collection):diff --git a/tests/dashboard/test_discount.py b/tests/dashboard/test_discount.pynew file mode 100644index 0000000000..22448726f9--- /dev/null+++ b/tests/dashboard/test_discount.py@@ -0,0 +1,91 @@+from datetime import date+from decimal import Decimal++from django.urls import reverse+from prices import Money++from saleor.discount import DiscountValueType, VoucherType+from saleor.discount.models import Sale, Voucher+++def test_sales_list(admin_client, sale):+ url = reverse('dashboard:sale-list')+ response = admin_client.get(url)+ assert response.status_code == 200+++def test_vouchers_list(admin_client, voucher):+ url = reverse('dashboard:voucher-list')+ response = admin_client.get(url)+ assert response.status_code == 200+++def test_voucher_shipping_add(admin_client):+ assert len(Voucher.objects.all()) == 0+ url = reverse('dashboard:voucher-add')+ data = {+ 'code': 'TESTVOUCHER', 'name': 'Test Voucher',+ 'start_date': '2018-01-01', 'end_date': '2018-06-01',+ 'type': VoucherType.SHIPPING, 'discount_value': '15.99',+ 'discount_value_type': DiscountValueType.FIXED,+ 'shipping-limit': '59.99'}+ response = admin_client.post(url, data, follow=True)+ assert response.status_code == 200+ assert len(Voucher.objects.all()) == 1++ voucher = Voucher.objects.all()[0]+ assert voucher.type == VoucherType.SHIPPING+ assert voucher.code == data['code']+ assert voucher.name == data['name']+ assert voucher.start_date == date(2018, 1, 1)+ assert voucher.end_date == date(2018, 6, 1)+ assert voucher.discount_value_type == DiscountValueType.FIXED+ assert voucher.discount_value == Decimal('15.99')+ assert voucher.limit == Money('59.99', 'USD')+++def test_view_sale_add(admin_client, default_category):+ url = reverse('dashboard:sale-add')+ data = {+ 'name': 'Free products',+ 'type': DiscountValueType.PERCENTAGE,+ 'value': 100,+ 'categories': [default_category.id]}++ response = admin_client.post(url, data)++ assert response.status_code == 302+ assert Sale.objects.count() == 1+ sale = Sale.objects.first()+ assert sale.name == data['name']+ assert default_category in sale.categories.all()+++def test_view_sale_add_requires_product_or_category(+ admin_client, default_category, product):+ url = reverse('dashboard:sale-add')+ data = {+ 'name': 'Free products',+ 'type': DiscountValueType.PERCENTAGE,+ 'value': 100}++ response = admin_client.post(url, data)++ assert response.status_code == 200+ assert Sale.objects.count() == 0++ data_with_category = data.copy()+ data_with_category.update({'categories': [default_category.id]})++ response = admin_client.post(url, data_with_category)++ assert response.status_code == 302+ assert Sale.objects.count() == 1++ data_with_product = data.copy()+ data_with_product.update({'products': [product.id]})++ response = admin_client.post(url, data_with_product)++ assert response.status_code == 302+ assert Sale.objects.count() == 2diff --git a/tests/dashboard/test_discounts.py b/tests/dashboard/test_discounts.pyindex 4ec76843ce..9afbf2e4f5 100644--- a/tests/dashboard/test_discounts.py+++ b/tests/dashboard/test_discounts.py@@ -1,3 +1,4 @@+import jsonfrom datetime import datefrom decimal import Decimalfrom unittest.mock import Mock@@ -185,3 +186,16 @@ def test_category_voucher_checkout_discount_not_applicable(monkeypatch):order = Mock(voucher=voucher)discount = get_voucher_discount_for_order(order)assert discount == Money(0, 'USD')+++def test_ajax_voucher_list(admin_client, voucher):+ voucher.name = 'Summer sale'+ voucher.save()+ vouchers_list = [{'id': voucher.pk, 'text': str(voucher)}]+ url = reverse('dashboard:ajax-vouchers')++ response = admin_client.get(url, HTTP_X_REQUESTED_WITH='XMLHttpRequest')+ resp_decoded = json.loads(response.content.decode('utf-8'))++ assert response.status_code == 200+ assert resp_decoded == {'results': vouchers_list}diff --git a/tests/dashboard/test_permissions.py b/tests/dashboard/test_permissions.pyindex 6f2691dce8..fa0a540380 100644--- a/tests/dashboard/test_permissions.py+++ b/tests/dashboard/test_permissions.py@@ -289,40 +289,40 @@ def test_staff_can_access_product_list(def test_staff_cant_access_product_detail(- staff_client, staff_user, product_in_stock):+ staff_client, staff_user, product):assert not staff_user.has_perm("product.view_product")response = staff_client.get(reverse('dashboard:product-detail',- args=[product_in_stock.pk]))+ args=[product.pk]))assert response.status_code == 302def test_staff_can_access_product_detail(- staff_client, staff_user, product_in_stock, permission_view_product):+ staff_client, staff_user, product, permission_view_product):assert not staff_user.has_perm("product.view_product")staff_user.user_permissions.add(permission_view_product)staff_user = User.objects.get(pk=staff_user.pk)assert staff_user.has_perm("product.view_product")response = staff_client.get(reverse('dashboard:product-detail',- args=[product_in_stock.pk]))+ args=[product.pk]))assert response.status_code == 200def test_staff_cant_access_product_update(- staff_client, staff_user, product_in_stock):+ staff_client, staff_user, product):assert not staff_user.has_perm("product.edit_product")response = staff_client.get(reverse('dashboard:product-update',- args=[product_in_stock.pk]))+ args=[product.pk]))assert response.status_code == 302def test_staff_can_access_product_update(- staff_client, staff_user, product_in_stock, permission_edit_product):+ staff_client, staff_user, product, permission_edit_product):assert not staff_user.has_perm("product.edit_product")staff_user.user_permissions.add(permission_edit_product)staff_user = User.objects.get(pk=staff_user.pk)assert staff_user.has_perm("product.edit_product")response = staff_client.get(reverse('dashboard:product-update',- args=[product_in_stock.pk]))+ args=[product.pk]))assert response.status_code == 200diff --git a/tests/dashboard/test_product.py b/tests/dashboard/test_product.pyindex 1cedae7732..44f544ceda 100644--- a/tests/dashboard/test_product.py+++ b/tests/dashboard/test_product.py@@ -16,7 +16,7 @@ from saleor.dashboard.product.forms import (from saleor.product.forms import VariantChoiceFieldfrom saleor.product.models import (AttributeChoiceValue, Collection, Product, ProductAttribute, ProductImage,- ProductType, ProductVariant, Stock, StockLocation)+ ProductType, ProductVariant)HTTP_STATUS_OK = 200HTTP_REDIRECTION = 302@@ -47,15 +47,15 @@ def test_product_variant_form(product_in_stock):@pytest.mark.integration@pytest.mark.django_db-def test_stock_record_update_works(admin_client, product_in_stock):- variant = product_in_stock.variants.get()+def test_stock_record_update_works(admin_client, product):+ variant = product.variants.get()stock = variant.stock.order_by('-quantity_allocated').first()quantity = stock.quantityquantity_allocated = stock.quantity_allocatedurl = reverse('dashboard:variant-stock-update',kwargs={- 'product_pk': product_in_stock.pk,+ 'product_pk': product.pk,'variant_pk': variant.pk,'stock_pk': stock.pk})admin_client.post(url, {@@ -143,9 +143,7 @@ def test_edit_used_product_type(db, default_category):assert 'has_variants' in form.errors.keys()-def test_change_attributes_in_product_form(- db, product_in_stock, color_attribute):- product = product_in_stock+def test_change_attributes_in_product_form(db, product, color_attribute):product_type = product.product_typetext_attribute = ProductAttribute.objects.create(slug='author', name='Author')@@ -169,7 +167,7 @@ def test_change_attributes_in_product_form(assert product.attributes[str(text_attribute.pk)] == str(author_value.pk)-def test_attribute_list(db, product_in_stock, color_attribute, admin_client):+def test_attribute_list(db, product, color_attribute, admin_client):assert len(ProductAttribute.objects.all()) == 2response = admin_client.get(reverse('dashboard:product-attributes'))assert response.status_code == 200@@ -287,8 +285,7 @@ def test_get_formfield_name_with_unicode_characters(db):assert text_attribute.get_formfield_name() == 'attribute-ąęαβδηθλμπ'-def test_view_product_toggle_publish(db, admin_client, product_in_stock):- product = product_in_stock+def test_view_product_toggle_publish(db, admin_client, product):url = reverse('dashboard:product-publish', kwargs={'pk': product.pk})response = admin_client.post(url)assert response.status_code == HTTP_STATUS_OK@@ -300,16 +297,14 @@ def test_view_product_toggle_publish(db, admin_client, product_in_stock):def test_view_product_not_deleted_before_confirmation(- db, admin_client, product_in_stock):- product = product_in_stock+ db, admin_client, product):url = reverse('dashboard:product-delete', kwargs={'pk': product.pk})response = admin_client.get(url)assert response.status_code == HTTP_STATUS_OKproduct.refresh_from_db()-def test_view_product_delete(db, admin_client, product_in_stock):- product = product_in_stock+def test_view_product_delete(db, admin_client, product):url = reverse('dashboard:product-delete', kwargs={'pk': product.pk})response = admin_client.post(url)assert response.status_code == HTTP_REDIRECTION@@ -317,8 +312,8 @@ def test_view_product_delete(db, admin_client, product_in_stock):def test_view_product_type_not_deleted_before_confirmation(- admin_client, product_in_stock):- product_type = product_in_stock.product_type+ admin_client, product):+ product_type = product.product_typeurl = reverse('dashboard:product-type-delete', kwargs={'pk': product_type.pk})response = admin_client.get(url)@@ -326,8 +321,8 @@ def test_view_product_type_not_deleted_before_confirmation(assert ProductType.objects.filter(pk=product_type.pk)-def test_view_product_type_delete(db, admin_client, product_in_stock):- product_type = product_in_stock.product_type+def test_view_product_type_delete(db, admin_client, product):+ product_type = product.product_typeurl = reverse('dashboard:product-type-delete', kwargs={'pk': product_type.pk})response = admin_client.post(url)@@ -336,24 +331,24 @@ def test_view_product_type_delete(db, admin_client, product_in_stock):def test_view_product_variant_not_deleted_before_confirmation(- admin_client, product_in_stock):- product_variant_pk = product_in_stock.variants.first().pk+ admin_client, product):+ product_variant_pk = product.variants.first().pkurl = reverse('dashboard:variant-delete',kwargs={- 'product_pk': product_in_stock.pk,+ 'product_pk': product.pk,'variant_pk': product_variant_pk})response = admin_client.get(url)assert response.status_code == HTTP_STATUS_OKassert ProductVariant.objects.filter(pk=product_variant_pk)-def test_view_product_variant_delete(admin_client, product_in_stock):- product_variant_pk = product_in_stock.variants.first().pk+def test_view_product_variant_delete(admin_client, product):+ product_variant_pk = product.variants.first().pkurl = reverse('dashboard:variant-delete',kwargs={- 'product_pk': product_in_stock.pk,+ 'product_pk': product.pk,'variant_pk': product_variant_pk})response = admin_client.post(url)assert response.status_code == HTTP_REDIRECTION@@ -361,13 +356,13 @@ def test_view_product_variant_delete(admin_client, product_in_stock):def test_view_stock_not_deleted_before_confirmation(- admin_client, product_in_stock):- product_variant = product_in_stock.variants.first()+ admin_client, product):+ product_variant = product.variants.first()stock = Stock.objects.filter(variant=product_variant).first()url = reverse('dashboard:variant-stock-delete',kwargs={- 'product_pk': product_in_stock.pk,+ 'product_pk': product.pk,'variant_pk': product_variant.pk,'stock_pk': stock.pk})response = admin_client.get(url)@@ -375,13 +370,13 @@ def test_view_stock_not_deleted_before_confirmation(assert Stock.objects.filter(pk=stock.pk)-def test_view_stock_delete(admin_client, product_in_stock):- product_variant = product_in_stock.variants.first()+def test_view_stock_delete(admin_client, product):+ product_variant = product.variants.first()stock = Stock.objects.filter(variant=product_variant).first()url = reverse('dashboard:variant-stock-delete',kwargs={- 'product_pk': product_in_stock.pk,+ 'product_pk': product.pk,'variant_pk': product_variant.pk,'stock_pk': stock.pk})response = admin_client.post(url)@@ -685,8 +680,7 @@ def test_hide_field_in_variant_choice_field_form():assert form.widget.attrs.get('value') == 'test'-def test_assign_collection_to_product(product_in_stock):- product = product_in_stock+def test_assign_collection_to_product(product):collection = Collection.objects.create(name='test_collections')data = {'name': product.name,diff --git a/tests/test_cart.py b/tests/test_cart.pyindex 4d1e19c981..56ae42f41f 100644--- a/tests/test_cart.py+++ b/tests/test_cart.py@@ -278,20 +278,20 @@ def test_find_and_assign_anonymous_cart_and_close_opened(assert user_cart.status == CartStatus.CANCELED-def test_adding_without_checking(cart, product_in_stock):- variant = product_in_stock.variants.get()+def test_adding_without_checking(cart, product):+ variant = product.variants.get()cart.add(variant, 1000, check_quantity=False)assert len(cart) == 1-def test_adding_zero_quantity(cart, product_in_stock):- variant = product_in_stock.variants.get()+def test_adding_zero_quantity(cart, product):+ variant = product.variants.get()cart.add(variant, 0)assert len(cart) == 0-def test_adding_same_variant(cart, product_in_stock):- variant = product_in_stock.variants.get()+def test_adding_same_variant(cart, product):+ variant = product.variants.get()cart.add(variant, 1)cart.add(variant, 2)assert len(cart) == 1@@ -299,16 +299,16 @@ def test_adding_same_variant(cart, product_in_stock):assert cart.get_total().gross == Money(30, 'USD')-def test_replacing_same_variant(cart, product_in_stock):- variant = product_in_stock.variants.get()+def test_replacing_same_variant(cart, product):+ variant = product.variants.get()cart.add(variant, 1, replace=True)cart.add(variant, 2, replace=True)assert len(cart) == 1assert cart.count() == {'total_quantity': 2}-def test_adding_invalid_quantity(cart, product_in_stock):- variant = product_in_stock.variants.get()+def test_adding_invalid_quantity(cart, product):+ variant = product.variants.get()with pytest.raises(ValueError):cart.add(variant, -1)@@ -318,8 +318,8 @@ def test_adding_invalid_quantity(cart, product_in_stock):({'gift-wrap': True}, None, False),({'gift-wrap': True}, {'gift-wrap': True}, True)])def test_getting_line(- create_line_data, get_line_data, lines_equal, cart, product_in_stock):- variant = product_in_stock.variants.get()+ create_line_data, get_line_data, lines_equal, cart, product):+ variant = product.variants.get()assert cart.get_line(variant) is Noneline = cart.create_line(variant, 1, create_line_data)fetched_line = cart.get_line(variant, data=get_line_data)@@ -337,8 +337,8 @@ def test_change_status(cart):assert cart.status == CartStatus.CANCELED-def test_shipping_detection(cart, product_in_stock):- variant = product_in_stock.variants.get()+def test_shipping_detection(cart, product):+ variant = product.variants.get()assert not cart.is_shipping_required()cart.add(variant, 1, replace=True)assert cart.is_shipping_required()@@ -375,8 +375,8 @@ def test_contains_unavailable_variants():assert not utils.contains_unavailable_variants(cart)-def test_remove_unavailable_variants(cart, product_in_stock):- variant = product_in_stock.variants.get()+def test_remove_unavailable_variants(cart, product):+ variant = product.variants.get()cart.add(variant, 1)variant.stock.update(quantity=0)utils.remove_unavailable_variants(cart)@@ -384,8 +384,8 @@ def test_remove_unavailable_variants(cart, product_in_stock):def test_check_product_availability_and_warn(- monkeypatch, cart, product_in_stock):- variant = product_in_stock.variants.get()+ monkeypatch, cart, product):+ variant = product.variants.get()cart.add(variant, 1)monkeypatch.setattr('django.contrib.messages.warning', Mock(warning=Mock()))@@ -471,8 +471,8 @@ def test_add_to_cart_form_when_insufficient_stock():assert not form.is_valid()-def test_replace_cart_line_form(cart, product_in_stock):- variant = product_in_stock.variants.get()+def test_replace_cart_line_form(cart, product):+ variant = product.variants.get()initial_quantity = 1replaced_quantity = 4@@ -485,8 +485,8 @@ def test_replace_cart_line_form(cart, product_in_stock):def test_replace_cartline_form_when_insufficient_stock(- monkeypatch, cart, product_in_stock):- variant = product_in_stock.variants.get()+ monkeypatch, cart, product):+ variant = product.variants.get()initial_quantity = 1replaced_quantity = 4@@ -509,8 +509,8 @@ def test_view_empty_cart(client, request_cart):assert response.status_code == 200-def test_view_cart(client, sale, product_in_stock, request_cart):- variant = product_in_stock.variants.get()+def test_view_cart(client, sale, product, request_cart):+ variant = product.variants.get()request_cart.add(variant, 1)response = client.get(reverse('cart:index'))response_cart_line = response.context[0]['cart_lines'][0]@@ -520,8 +520,8 @@ def test_view_cart(client, sale, product_in_stock, request_cart):def test_view_update_cart_quantity(- client, local_currency, product_in_stock, request_cart):- variant = product_in_stock.variants.get()+ client, local_currency, product, request_cart):+ variant = product.variants.get()request_cart.add(variant, 1)response = client.post(reverse('cart:update-line', kwargs={'variant_id': variant.pk}),@@ -530,8 +530,8 @@ def test_view_update_cart_quantity(assert request_cart.quantity == 3-def test_view_invalid_update_cart(client, product_in_stock, request_cart):- variant = product_in_stock.variants.get()+def test_view_invalid_update_cart(client, product, request_cart):+ variant = product.variants.get()request_cart.add(variant, 1)response = client.post(reverse('cart:update-line', kwargs={'variant_id': variant.pk}),@@ -543,9 +543,9 @@ def test_view_invalid_update_cart(client, product_in_stock, request_cart):def test_cart_page_without_openexchagerates(- client, product_in_stock, request_cart, settings):+ client, product, request_cart, settings):settings.OPENEXCHANGERATES_API_KEY = None- variant = product_in_stock.variants.get()+ variant = product.variants.get()request_cart.add(variant, 1)response = client.get(reverse('cart:index'))context = response.context@@ -553,10 +553,10 @@ def test_cart_page_without_openexchagerates(def test_cart_page_with_openexchagerates(- client, monkeypatch, product_in_stock, request_cart, settings):+ client, monkeypatch, product, request_cart, settings):settings.DEFAULT_COUNTRY = 'PL'settings.OPENEXCHANGERATES_API_KEY = 'fake-key'- variant = product_in_stock.variants.get()+ variant = product.variants.get()request_cart.add(variant, 1)response = client.get(reverse('cart:index'))context = response.context@@ -569,8 +569,8 @@ def test_cart_page_with_openexchagerates(assert context['local_cart_total'].currency == 'PLN'-def test_cart_summary_page(client, product_in_stock, request_cart):- variant = product_in_stock.variants.get()+def test_cart_summary_page(client, product, request_cart):+ variant = product.variants.get()request_cart.add(variant, 1)response = client.get(reverse('cart:cart-summary'))assert response.status_code == 200@@ -592,9 +592,9 @@ def test_cart_summary_page_empty_cart(client, request_cart):assert data['quantity'] == 0-def test_total_with_discount(client, sale, request_cart, product_in_stock):+def test_total_with_discount(client, sale, request_cart, product):sales = Sale.objects.all()- variant = product_in_stock.variants.get()+ variant = product.variants.get()request_cart.add(variant, 1)line = request_cart.lines.first()assert line.get_total(discounts=sales) == TaxedMoney(@@ -646,15 +646,15 @@ def test_cart_change_user(customer_user):assert old_cart.status == CartStatus.CANCELED-def test_cart_line_repr(product_in_stock, request_cart_with_item):- variant = product_in_stock.variants.get()+def test_cart_line_repr(product, request_cart_with_item):+ variant = product.variants.get()line = request_cart_with_item.lines.first()assert repr(line) == 'CartLine(variant=%r, quantity=%r, data=%r)' % (variant, line.quantity, line.data)-def test_cart_line_state(product_in_stock, request_cart_with_item):- variant = product_in_stock.variants.get()+def test_cart_line_state(product, request_cart_with_item):+ variant = product.variants.get()line = request_cart_with_item.lines.first()assert line.__getstate__() == (variant, line.quantity, line.data)@@ -665,10 +665,10 @@ def test_cart_line_state(product_in_stock, request_cart_with_item):def test_get_category_variants_and_prices(- default_category, product_in_stock, request_cart_with_item):+ default_category, product, request_cart_with_item):result = list(utils.get_category_variants_and_prices(request_cart_with_item, default_category))- variant = product_in_stock.variants.get()+ variant = product.variants.get()assert result[0][0] == variantdiff --git a/tests/test_checkout.py b/tests/test_checkout.pyindex 38ea0dfd20..3a6bbfb955 100644--- a/tests/test_checkout.py+++ b/tests/test_checkout.py@@ -185,11 +185,11 @@ def test_checkout_discount(checkout_with_items, sale):def test_checkout_create_order_insufficient_stock(- request_cart, customer_user, product_in_stock):- product_type = product_in_stock.product_type+ request_cart, customer_user, product):+ product_type = product.product_typeproduct_type.is_shipping_required = Falseproduct_type.save()- variant = product_in_stock.variants.get()+ variant = product.variants.get()request_cart.add(variant, quantity=10, check_quantity=False)checkout = Checkout(request_cart, customer_user, 'tracking_code')with pytest.raises(InsufficientStock):diff --git a/tests/test_data_feeds.py b/tests/test_data_feeds.pyindex 45dd53d2f6..d1a99d965f 100644--- a/tests/test_data_feeds.py+++ b/tests/test_data_feeds.py@@ -9,8 +9,8 @@ from saleor.data_feeds.google_merchant import (from saleor.product.models import AttributeChoiceValue, Category-def test_saleor_feed_items(product_in_stock, site_settings):- valid_variant = product_in_stock.variants.first()+def test_saleor_feed_items(product, site_settings):+ valid_variant = product.variants.first()items = get_feed_items()assert len(items) == 1categories = Category.objects.all()@@ -38,7 +38,7 @@ def test_category_formatter(db):assert item_google_product_category(sub_category_item, {}) == 'Main > Sub'-def test_write_feed(product_in_stock, monkeypatch):+def test_write_feed(product, monkeypatch):buffer = StringIO()write_feed(buffer)buffer.seek(0)@@ -58,7 +58,7 @@ def test_write_feed(product_in_stock, monkeypatch):@patch('saleor.data_feeds.google_merchant.item_link')def test_feed_contains_site_settings_domain(- mocked_item_link, product_in_stock, site_settings):+ mocked_item_link, product, site_settings):write_feed(StringIO())mocked_item_link.assert_called_once_with(- product_in_stock.variants.first(), site_settings.site)+ product.variants.first(), site_settings.site)diff --git a/tests/test_discounts.py b/tests/test_discounts.pyindex 4517950b7f..182350fd9f 100644--- a/tests/test_discounts.py+++ b/tests/test_discounts.py@@ -1,9 +1,7 @@-import jsonfrom datetime import date, timedeltafrom unittest.mock import Mockimport pytest-from django.urls import reversefrom freezegun import freeze_timefrom prices import Money, TaxedMoney@@ -32,32 +30,32 @@ def test_valid_voucher_limit(settings, limit, value):@pytest.mark.integration@pytest.mark.django_db(transaction=True)-def test_variant_discounts(product_in_stock):- variant = product_in_stock.variants.get()+def test_variant_discounts(product):+ variant = product.variants.get()low_discount = Sale.objects.create(type=DiscountValueType.FIXED,value=5)- low_discount.products.add(product_in_stock)+ low_discount.products.add(product)discount = Sale.objects.create(type=DiscountValueType.FIXED,value=8)- discount.products.add(product_in_stock)+ discount.products.add(product)high_discount = Sale.objects.create(type=DiscountValueType.FIXED,value=50)- high_discount.products.add(product_in_stock)+ high_discount.products.add(product)final_price = variant.get_price_per_item(discounts=Sale.objects.all())assert final_price.gross == Money(0, 'USD')@pytest.mark.integration@pytest.mark.django_db(transaction=True)-def test_percentage_discounts(product_in_stock):- variant = product_in_stock.variants.get()+def test_percentage_discounts(product):+ variant = product.variants.get()discount = Sale.objects.create(type=DiscountValueType.PERCENTAGE,value=50)- discount.products.add(product_in_stock)+ discount.products.add(product)final_price = variant.get_price_per_item(discounts=[discount])assert final_price.gross == Money(5, 'USD')@@ -282,16 +280,3 @@ def test_get_product_or_category_voucher_discount_all_products(discount = get_product_or_category_voucher_discount(voucher, prices)assert discount == Money(expected_value, 'USD')---def test_ajax_voucher_list(admin_client, voucher):- voucher.name = 'Summer sale'- voucher.save()- vouchers_list = [{'id': voucher.pk, 'text': str(voucher)}]- url = reverse('dashboard:ajax-vouchers')-- response = admin_client.get(url, HTTP_X_REQUESTED_WITH='XMLHttpRequest')- resp_decoded = json.loads(response.content.decode('utf-8'))-- assert response.status_code == 200- assert resp_decoded == {'results': vouchers_list}diff --git a/tests/test_graphql.py b/tests/test_graphql.pyindex 01f1060a8d..0013fa0bdb 100644--- a/tests/test_graphql.py+++ b/tests/test_graphql.py@@ -14,7 +14,7 @@ from saleor.product.models import Category, Product, ProductAttributefrom .utils import get_graphql_content-def test_category_query(client, product_in_stock):+def test_category_query(client, product):category = Category.objects.first()query = '''query {@@ -52,7 +52,7 @@ def test_category_query(client, product_in_stock):category.get_children().count())-def test_fetch_all_products(client, product_in_stock):+def test_fetch_all_products(client, product):query = '''query {products {@@ -74,7 +74,7 @@ def test_fetch_all_products(client, product_in_stock):@pytest.mark.djangodb-def test_fetch_unavailable_products(client, product_in_stock):+def test_fetch_unavailable_products(client, product):Product.objects.update(is_published=False)query = '''query {@@ -95,7 +95,11 @@ def test_fetch_unavailable_products(client, product_in_stock):assert not content['data']['products']['edges']+<<<<<<< HEADdef test_product_query(admin_client, product_in_stock):+=======+def test_product_query(client, product):+>>>>>>> Rename product_in_stock to producTcategory = Category.objects.first()product = category.products.first()query = '''@@ -201,8 +205,8 @@ def test_product_query(admin_client, product_in_stock):'priceRange']['stop']['gross']['amount']-def test_filter_product_by_category(client, product_in_stock):- category = product_in_stock.category+def test_filter_product_by_category(client, product):+ category = product.categoryquery = '''query getProducts($categoryId: ID) {products(category: $categoryId) {@@ -226,10 +230,10 @@ def test_filter_product_by_category(client, product_in_stock):content = get_graphql_content(response)assert 'errors' not in contentproduct_data = content['data']['products']['edges'][0]['node']- assert product_data['name'] == product_in_stock.name+ assert product_data['name'] == product.name-def test_fetch_product_by_id(client, product_in_stock):+def test_fetch_product_by_id(client, product):query = '''query ($productId: ID!) {node(id: $productId) {@@ -246,16 +250,16 @@ def test_fetch_product_by_id(client, product_in_stock):'variables': json.dumps({'productId': graphene.Node.to_global_id(- 'Product', product_in_stock.id)})})+ 'Product', product.id)})})content = get_graphql_content(response)assert 'errors' not in contentproduct_data = content['data']['node']- assert product_data['name'] == product_in_stock.name+ assert product_data['name'] == product.name-def test_filter_product_by_attributes(client, product_in_stock):- product_attr = product_in_stock.product_type.product_attributes.first()- category = product_in_stock.category+def test_filter_product_by_attributes(client, product):+ product_attr = product.product_type.product_attributes.first()+ category = product.categoryattr_value = product_attr.values.first()filter_by = '%s:%s' % (product_attr.slug, attr_value.slug)query = '''@@ -277,18 +281,18 @@ def test_filter_product_by_attributes(client, product_in_stock):content = get_graphql_content(response)assert 'errors' not in contentproduct_data = content['data']['category']['products']['edges'][0]['node']- assert product_data['name'] == product_in_stock.name+ assert product_data['name'] == product.name-def test_sort_products(client, product_in_stock):+def test_sort_products(client, product):# set price of the first product- product_in_stock.price = Money('10.00', 'USD')- product_in_stock.save()+ product.price = Money('10.00', 'USD')+ product.save()# create the second product with higher price- product_in_stock.pk = None- product_in_stock.price = Money('20.00', 'USD')- product_in_stock.save()+ product.pk = None+ product.price = Money('20.00', 'USD')+ product.save()query = '''query {@@ -323,7 +327,7 @@ def test_sort_products(client, product_in_stock):assert price_0 > price_1-def test_attributes_query(client, product_in_stock):+def test_attributes_query(client, product):attributes = ProductAttribute.objects.prefetch_related('values')query = '''query {@@ -350,7 +354,7 @@ def test_attributes_query(client, product_in_stock):assert len(attributes_data) == attributes.count()-def test_attributes_in_category_query(client, product_in_stock):+def test_attributes_in_category_query(client, product):category = Category.objects.first()query = '''query {@@ -377,9 +381,16 @@ def test_attributes_in_category_query(client, product_in_stock):assert len(attributes_data) == ProductAttribute.objects.count()+<<<<<<< HEADdef test_real_query(admin_client, product_in_stock):product_attr = product_in_stock.product_type.product_attributes.first()category = product_in_stock.category+=======+def test_real_query(client, product):+ category = product.category+ product_attr = product.product_type.product_attributes.first()+ category = product.category+>>>>>>> Rename product_in_stock to producTattr_value = product_attr.values.first()filter_by = '%s:%s' % (product_attr.slug, attr_value.slug)query = '''diff --git a/tests/test_order.py b/tests/test_order.pyindex 1c55539dc5..b0d53f6318 100644--- a/tests/test_order.py+++ b/tests/test_order.py@@ -37,9 +37,9 @@ def test_order_get_subtotal(order_with_lines):def test_add_variant_to_order_adds_line_for_new_variant(- order_with_lines, product_in_stock):+ order_with_lines, product):order = order_with_lines- variant = product_in_stock.variants.get()+ variant = product.variants.get()lines_before = order.lines.count()add_variant_to_order(order, variant, 1)@@ -51,9 +51,9 @@ def test_add_variant_to_order_adds_line_for_new_variant(def test_add_variant_to_order_allocates_stock_for_new_variant(- order_with_lines, product_in_stock):+ order_with_lines, product):order = order_with_lines- variant = product_in_stock.variants.get()+ variant = product.variants.get()stock = variant.select_stockrecord()stock_before = stock.quantity_allocateddiff --git a/tests/test_product.py b/tests/test_product.pyindex 3c6a6a29d7..c110cac55b 100644--- a/tests/test_product.py+++ b/tests/test_product.py@@ -16,14 +16,8 @@ from saleor.product.utils.variants_picker import get_variant_picker_datafrom .utils import filter_products_by_attribute-def test_stock_selector(product_in_stock):- variant = product_in_stock.variants.get()- preferred_stock = variant.select_stockrecord(5)- assert preferred_stock.quantity_available >= 5---def test_allocate_stock(product_in_stock):- variant = product_in_stock.variants.get()+def test_allocate_stock(product):+ variant = product.variants.get()stock = variant.select_stockrecord(5)assert stock.quantity_allocated == 0allocate_stock(stock, 1)@@ -31,8 +25,8 @@ def test_allocate_stock(product_in_stock):assert stock.quantity_allocated == 1-def test_deallocate_stock(product_in_stock):- stock = product_in_stock.variants.first().stock.first()+def test_deallocate_stock(product):+ stock = product.variants.first().stock.first()stock.quantity = 100stock.quantity_allocated = 80stock.save()@@ -42,8 +36,8 @@ def test_deallocate_stock(product_in_stock):assert stock.quantity_allocated == 30-def test_decrease_stock(product_in_stock):- stock = product_in_stock.variants.first().stock.first()+def test_decrease_stock(product):+ stock = product.variants.first().stock.first()stock.quantity = 100stock.quantity_allocated = 80stock.save()@@ -53,8 +47,8 @@ def test_decrease_stock(product_in_stock):assert stock.quantity_allocated == 30-def test_increase_stock(product_in_stock):- stock = product_in_stock.variants.first().stock.first()+def test_increase_stock(product):+ stock = product.variants.first().stock.first()stock.quantity = 100stock.quantity_allocated = 80stock.save()@@ -64,24 +58,24 @@ def test_increase_stock(product_in_stock):assert stock.quantity_allocated == 80-def test_product_page_redirects_to_correct_slug(client, product_in_stock):- uri = product_in_stock.get_absolute_url()- uri = uri.replace(product_in_stock.get_slug(), 'spanish-inquisition')+def test_product_page_redirects_to_correct_slug(client, product):+ uri = product.get_absolute_url()+ uri = uri.replace(product.get_slug(), 'spanish-inquisition')response = client.get(uri)assert response.status_code == 301location = response['location']if location.startswith('http'):location = location.split('http://testserver')[1]- assert location == product_in_stock.get_absolute_url()+ assert location == product.get_absolute_url()-def test_product_preview(admin_client, client, product_in_stock):- product_in_stock.available_on = (+def test_product_preview(admin_client, client, product):+ product.available_on = (datetime.date.today() + datetime.timedelta(days=7))- product_in_stock.save()- response = client.get(product_in_stock.get_absolute_url())+ product.save()+ response = client.get(product.get_absolute_url())assert response.status_code == 404- response = admin_client.get(product_in_stock.get_absolute_url())+ response = admin_client.get(product.get_absolute_url())assert response.status_code == 200@@ -125,39 +119,39 @@ def test_filtering_by_attribute(db, color_attribute, default_category):assert product_b not in list(filtered)-def test_view_invalid_add_to_cart(client, product_in_stock, request_cart):- variant = product_in_stock.variants.get()+def test_view_invalid_add_to_cart(client, product, request_cart):+ variant = product.variants.get()request_cart.add(variant, 2)response = client.post(reverse('product:add-to-cart',kwargs={- 'slug': product_in_stock.get_slug(),- 'product_id': product_in_stock.pk}),+ 'slug': product.get_slug(),+ 'product_id': product.pk}),{})assert response.status_code == 200assert request_cart.quantity == 2-def test_view_add_to_cart(client, product_in_stock, request_cart):- variant = product_in_stock.variants.get()+def test_view_add_to_cart(client, product, request_cart):+ variant = product.variants.get()request_cart.add(variant, 1)response = client.post(reverse('product:add-to-cart',- kwargs={'slug': product_in_stock.get_slug(),- 'product_id': product_in_stock.pk}),+ kwargs={'slug': product.get_slug(),+ 'product_id': product.pk}),{'quantity': 1, 'variant': variant.pk})assert response.status_code == 302assert request_cart.quantity == 1def test_adding_to_cart_with_current_user_token(- admin_user, admin_client, product_in_stock):+ admin_user, admin_client, product):client = admin_clientkey = utils.COOKIE_NAMEcart = Cart.objects.create(user=admin_user)- variant = product_in_stock.variants.first()+ variant = product.variants.first()cart.add(variant, 1)response = client.get(reverse('cart:index'))@@ -166,8 +160,8 @@ def test_adding_to_cart_with_current_user_token(client.post(reverse('product:add-to-cart',- kwargs={'slug': product_in_stock.get_slug(),- 'product_id': product_in_stock.pk}),+ kwargs={'slug': product.get_slug(),+ 'product_id': product.pk}),{'quantity': 1, 'variant': variant.pk})assert Cart.objects.count() == 1@@ -175,11 +169,11 @@ def test_adding_to_cart_with_current_user_token(def test_adding_to_cart_with_another_user_token(- admin_user, admin_client, product_in_stock, customer_user):+ admin_user, admin_client, product, customer_user):client = admin_clientkey = utils.COOKIE_NAMEcart = Cart.objects.create(user=customer_user)- variant = product_in_stock.variants.first()+ variant = product.variants.first()cart.add(variant, 1)response = client.get(reverse('cart:index'))@@ -188,8 +182,8 @@ def test_adding_to_cart_with_another_user_token(client.post(reverse('product:add-to-cart',- kwargs={'slug': product_in_stock.get_slug(),- 'product_id': product_in_stock.pk}),+ kwargs={'slug': product.get_slug(),+ 'product_id': product.pk}),{'quantity': 1, 'variant': variant.pk})assert Cart.objects.count() == 2@@ -197,10 +191,10 @@ def test_adding_to_cart_with_another_user_token(def test_anonymous_adding_to_cart_with_another_user_token(- client, product_in_stock, customer_user):+ client, product, customer_user):key = utils.COOKIE_NAMEcart = Cart.objects.create(user=customer_user)- variant = product_in_stock.variants.first()+ variant = product.variants.first()cart.add(variant, 1)response = client.get(reverse('cart:index'))@@ -209,8 +203,8 @@ def test_anonymous_adding_to_cart_with_another_user_token(client.post(reverse('product:add-to-cart',- kwargs={'slug': product_in_stock.get_slug(),- 'product_id': product_in_stock.pk}),+ kwargs={'slug': product.get_slug(),+ 'product_id': product.pk}),{'quantity': 1, 'variant': variant.pk})assert Cart.objects.count() == 2@@ -218,12 +212,12 @@ def test_anonymous_adding_to_cart_with_another_user_token(def test_adding_to_cart_with_deleted_cart_token(- admin_user, admin_client, product_in_stock):+ admin_user, admin_client, product):client = admin_clientkey = utils.COOKIE_NAMEcart = Cart.objects.create(user=admin_user)old_token = cart.token- variant = product_in_stock.variants.first()+ variant = product.variants.first()cart.add(variant, 1)response = client.get(reverse('cart:index'))@@ -233,8 +227,8 @@ def test_adding_to_cart_with_deleted_cart_token(client.post(reverse('product:add-to-cart',- kwargs={'slug': product_in_stock.get_slug(),- 'product_id': product_in_stock.pk}),+ kwargs={'slug': product.get_slug(),+ 'product_id': product.pk}),{'quantity': 1, 'variant': variant.pk})assert Cart.objects.count() == 1@@ -242,11 +236,11 @@ def test_adding_to_cart_with_deleted_cart_token(def test_adding_to_cart_with_closed_cart_token(- admin_user, admin_client, product_in_stock):+ admin_user, admin_client, product):client = admin_clientkey = utils.COOKIE_NAMEcart = Cart.objects.create(user=admin_user)- variant = product_in_stock.variants.first()+ variant = product.variants.first()cart.add(variant, 1)response = client.get(reverse('cart:index'))@@ -255,8 +249,8 @@ def test_adding_to_cart_with_closed_cart_token(client.post(reverse('product:add-to-cart',- kwargs={'slug': product_in_stock.get_slug(),- 'product_id': product_in_stock.pk}),+ kwargs={'slug': product.get_slug(),+ 'product_id': product.pk}),{'quantity': 1, 'variant': variant.pk})assert Cart.objects.filter(@@ -264,7 +258,7 @@ def test_adding_to_cart_with_closed_cart_token(def test_product_filter_before_filtering(- authorized_client, product_in_stock, default_category):+ authorized_client, product, default_category):products = models.Product.objects.all().filter(category__name=default_category).order_by('-price')url = reverse(@@ -274,7 +268,7 @@ def test_product_filter_before_filtering(assert list(products) == list(response.context['filter_set'].qs)-def test_product_filter_product_exists(authorized_client, product_in_stock,+def test_product_filter_product_exists(authorized_client, product,default_category):products = (models.Product.objects.all()@@ -289,7 +283,7 @@ def test_product_filter_product_exists(authorized_client, product_in_stock,def test_product_filter_product_does_not_exist(- authorized_client, product_in_stock, default_category):+ authorized_client, product, default_category):url = reverse('product:category', kwargs={'path': default_category.slug, 'category_id': default_category.pk})@@ -298,7 +292,7 @@ def test_product_filter_product_does_not_exist(assert not list(response.context['filter_set'].qs)-def test_product_filter_form(authorized_client, product_in_stock,+def test_product_filter_form(authorized_client, product,default_category):products = (models.Product.objects.all()@@ -328,7 +322,7 @@ def test_product_filter_sorted_by_price_descending(def test_product_filter_sorted_by_wrong_parameter(- authorized_client, product_in_stock, default_category):+ authorized_client, product, default_category):url = reverse('product:category', kwargs={'path': default_category.slug, 'category_id': default_category.pk})@@ -337,15 +331,15 @@ def test_product_filter_sorted_by_wrong_parameter(assert not list(response.context['filter_set'].qs)-def test_get_variant_picker_data_proper_variant_count(product_in_stock):+def test_get_variant_picker_data_proper_variant_count(product):data = get_variant_picker_data(- product_in_stock, discounts=None, local_currency=None)+ product, discounts=None, local_currency=None)assert len(data['variantAttributes'][0]['values']) == 1-def test_view_ajax_available_variants_list(admin_client, product_in_stock):- variant = product_in_stock.variants.first()+def test_view_ajax_available_variants_list(admin_client, product):+ variant = product.variants.first()variant_list = [{'id': variant.pk, 'text': '123, Test product, $10.00'}]@@ -357,8 +351,8 @@ def test_view_ajax_available_variants_list(admin_client, product_in_stock):assert resp_decoded == {'results': variant_list}-def test_view_ajax_available_products_list(admin_client, product_in_stock):- product_list = [{'id': product_in_stock.pk, 'text': 'Test product'}]+def test_view_ajax_available_products_list(admin_client, product):+ product_list = [{'id': product.pk, 'text': 'Test product'}]url = reverse('dashboard:ajax-products')response = admin_client.get(url, HTTP_X_REQUESTED_WITH='XMLHttpRequest')@@ -384,10 +378,9 @@ def test_render_product_page_with_no_variant(def test_include_products_from_subcategories_in_main_view(- default_category, product_in_stock, authorized_client):+ default_category, product, authorized_client):subcategory = Category.objects.create(name='sub', slug='test', parent=default_category)- product = product_in_stockproduct.category = subcategoryproduct.save()path = default_category.get_full_path()diff --git a/tests/test_sitemap.py b/tests/test_sitemap.pyindex 239dd4dc7d..d4614394ca 100644--- a/tests/test_sitemap.py+++ b/tests/test_sitemap.py@@ -4,10 +4,10 @@ from django.urls import reverse, translate_urlfrom saleor.core.utils import build_absolute_uri-def test_sitemap(client, product_in_stock):- product_url = build_absolute_uri(product_in_stock.get_absolute_url())+def test_sitemap(client, product):+ product_url = build_absolute_uri(product.get_absolute_url())category_url = build_absolute_uri(- product_in_stock.category.get_absolute_url())+ product.category.get_absolute_url())expected_urls = [product_url, category_url]language_codes = [lang_code for lang_code, lang_name in settings.LANGUAGES]