test: Variant Selector - Fetch next valid Attribute values fetching after selection of one

This commit is contained in:
marination 2022-01-11 20:15:24 +05:30
parent 5a462db207
commit 2623046ba7

View File

@ -72,18 +72,22 @@ class TestVariantSelector(unittest.TestCase):
# Only L and M attribute values must be fetched since S is disabled # Only L and M attribute values must be fetched since S is disabled
self.assertEqual(len(attr_data[0]["values"]), 2) # ['Medium', 'Large'] self.assertEqual(len(attr_data[0]["values"]), 2) # ['Medium', 'Large']
# def test_next_item_variant_values(self): def test_next_item_variant_values(self):
# """ """
# Test if on selecting an attribute value, the next possible values Test if on selecting an attribute value, the next possible values
# are filtered accordingly. are filtered accordingly.
# Values that dont apply should not be fetched. Values that dont apply should not be fetched.
# E.g. E.g.
# There is a ** Small-Red ** Tshirt. No other colour in this size. There is a ** Small-Red ** Tshirt. No other colour in this size.
# On selecting ** Small **, only ** Red ** should be selectable next. On selecting ** Small **, only ** Red ** should be selectable next.
# """ """
# from erpnext.e_commerce.variant_selector.utils import get_next_attribute_and_values from erpnext.e_commerce.variant_selector.utils import get_next_attribute_and_values
# next_values = get_next_attribute_and_values("Test-Tshirt-Temp", selected_attributes={ next_values = get_next_attribute_and_values("Test-Tshirt-Temp", selected_attributes={"Test Size": "Small"})
# "Colour": "Red" next_colours = next_values["valid_options_for_attributes"]["Test Colour"]
# }) filtered_items = next_values["filtered_items"]
# print(next_values)
self.assertEqual(len(next_colours), 1)
self.assertEqual(next_colours.pop(), "Red")
self.assertEqual(len(filtered_items), 1)
self.assertEqual(filtered_items.pop(), "Test-Tshirt-Temp-S-R")