Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Remove unneeded variables, fix tests and simplify `get_available_sizes`
NyanKiyoshi8e3876475a72
diff --git a/saleor/product/templatetags/product_images.py b/saleor/product/templatetags/product_images.pyindex cc971bb666..02fffbfd25 100644--- a/saleor/product/templatetags/product_images.py+++ b/saleor/product/templatetags/product_images.py@@ -15,9 +15,7 @@ def get_available_sizes():rendition_sizes = {}keys = settings.VERSATILEIMAGEFIELD_RENDITION_KEY_SETSfor dummy_size_group, sizes in keys.items():- group_sizes = rendition_sizes.setdefault(dummy_size_group, set())- for dummy_size_name, size in sizes:- group_sizes.add(size)+ rendition_sizes[dummy_size_group] = tuple(sizes)return rendition_sizesdiff --git a/tests/api/test_category.py b/tests/api/test_category.pyindex d80ab43e38..c07cca050d 100644--- a/tests/api/test_category.py+++ b/tests/api/test_category.py@@ -143,14 +143,12 @@ def test_category_create_mutation_without_background_image('create_category_background_image_thumbnails.delay'),mock_create_thumbnails)- category_name = 'Test category'- category_slug = slugify(category_name)- category_description = 'Test description'-# test creating root category+ category_name = 'Test category'variables = {- 'name': category_name, 'description': category_description,- 'slug': category_slug}+ 'name': category_name,+ 'description': 'Test description',+ 'slug': slugify(category_name)}response = staff_api_client.post_graphql(query, variables, permissions=[permission_manage_products])content = get_graphql_content(response)@@ -251,21 +249,13 @@ def test_category_update_mutation_without_background_image('create_category_background_image_thumbnails.delay'),mock_create_thumbnails)- # create child category and test that the update mutation won't change- # it's parent- child_category = category.children.create(name='child')-category_name = 'Updated name'- category_slug = slugify(category_name)- category_description = 'Updated description'-- category_id = graphene.Node.to_global_id('Category', child_category.pk)-- # test creating root categoryvariables = {- 'id': category_id,- 'name': category_name, 'description': category_description,- 'slug': category_slug}+ 'id': graphene.Node.to_global_id(+ 'Category', category.children.create(name='child').pk),+ 'name': category_name,+ 'description': 'Updated description',+ 'slug': slugify(category_name)}response = staff_api_client.post_graphql(query, variables, permissions=[permission_manage_products])diff --git a/tests/test_product_tags.py b/tests/test_product_tags.pyindex 91c3f015ef..a0aea44109 100644--- a/tests/test_product_tags.py+++ b/tests/test_product_tags.py@@ -31,9 +31,9 @@ def test_get_thumbnail_no_instance(monkeypatch):@patch('saleor.product.templatetags.product_images.AVAILABLE_SIZES',- {+ {'products': ('thumbnail__800x800', 'crop__100x100', 'crop__1000x1000',- 'crop__2000x2000'})+ 'crop__2000x2000')})@override_settings(VERSATILEIMAGEFIELD_SETTINGS={'create_images_on_demand': False})def test_get_thumbnail_to_larger():@@ -46,7 +46,8 @@ def test_get_thumbnail_to_larger():@patch('saleor.product.templatetags.product_images.AVAILABLE_SIZES',- {'crop__10x10', 'crop__100x100', 'crop__1000x1000', 'crop__2000x2000'})+ {'products': (+ 'crop__10x10', 'crop__100x100', 'crop__1000x1000', 'crop__2000x2000')})@override_settings(VERSATILEIMAGEFIELD_SETTINGS={'create_images_on_demand': False})def test_get_thumbnail_to_smaller():@@ -59,7 +60,7 @@ def test_get_thumbnail_to_smaller():@patch('saleor.product.templatetags.product_images.AVAILABLE_SIZES',- {'thumbnail__800x800'})+ {'products': ('thumbnail__800x800', )})@override_settings(VERSATILEIMAGEFIELD_SETTINGS={'create_images_on_demand': False},PLACEHOLDER_IMAGES={1080: 'images/placeholder1080x1080.png'})