From 4823be1325c577018ef366722d72161d3b7a3a47 Mon Sep 17 00:00:00 2001 From: Samar Hassan Date: Fri, 9 Aug 2024 07:59:35 +0100 Subject: [PATCH] feat :star: add test to check saving multiple products with same new product class --- tests/reverse/test_catalogue.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/reverse/test_catalogue.py b/tests/reverse/test_catalogue.py index 6bd1cb4..00083ec 100644 --- a/tests/reverse/test_catalogue.py +++ b/tests/reverse/test_catalogue.py @@ -794,7 +794,7 @@ def test_error_handling_on_product_operations(self): ) -class SingleProductFieldsToUpdateTest(TestCase): +class ProductFieldsToUpdateTest(TestCase): def setUp(self): super().setUp() ProductClass.objects.create( @@ -953,3 +953,33 @@ def test_product_class_fields_to_update(self): prd.refresh_from_db() # Product class is updated as it was added in fields_to_update self.assertEqual(prd.product_class.requires_shipping, True) + + def test_check_multiple_products_with_same_new_product_class(self): + product_resources = [ + ProductResource( + upc="checking", + title="Checking", + slug="checking", + structure=Product.STANDALONE, + product_class=ProductClassResource( + name="Better", + slug="better", + requires_shipping=False, + track_stock=True, + ), + ), + ProductResource( + upc="testing", + title="Testing", + slug="testing", + structure=Product.STANDALONE, + product_class=ProductClassResource( + name="Better", + slug="better", + requires_shipping=False, + track_stock=True, + ), + ), + ] + _, errors = products_to_db(product_resources) + self.assertEqual(len(errors), 0)