Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add test for product image delete confirmation view
Jakub Draganek2d6ed0336144
diff --git a/tests/conftest.py b/tests/conftest.pyindex 4e9fc476c7..d0114590d4 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -3,7 +3,8 @@ from __future__ import unicode_literalsfrom decimal import Decimalimport pytest-from io import StringIO+from io import BytesIO+from PIL import Imagefrom django.contrib.auth.models import AnonymousUserfrom django.utils.encoding import smart_textfrom django.core.files.uploadedfile import SimpleUploadedFile@@ -167,7 +168,9 @@ def stock_location():@pytest.fixturedef product_image():- img_data = StringIO()+ img_data = BytesIO()+ image = Image.new('RGB', size=(1, 1))+ image.save(img_data, format='JPEG')return SimpleUploadedFile('product.jpg', img_data.getvalue())diff --git a/tests/dashboard/test_product.py b/tests/dashboard/test_product.pyindex df0073e990..c25e33e9da 100644--- a/tests/dashboard/test_product.py+++ b/tests/dashboard/test_product.py@@ -259,6 +259,16 @@ def test_view_attribute_delete(admin_client, color_attribute):assert not ProductAttribute.objects.filter(pk=color_attribute.pk)+def test_view_product_image_not_deleted_before_confirmation(admin_client, product_with_image):+ product_image = product_with_image.images.all()[0]+ url = reverse('dashboard:product-image-delete',+ kwargs={'img_pk': product_image.pk,+ 'product_pk': product_with_image.pk})+ response = admin_client.get(url)+ assert response.status_code == HTTP_STATUS_OK+ assert ProductImage.objects.filter(pk=product_image.pk).count()++def test_view_product_image_delete(admin_client, product_with_image):product_image = product_with_image.images.all()[0]url = reverse('dashboard:product-image-delete',