def test_basic(self): """Correct options should be set and values should be sorted. """ options = counts_to_options(self.counts, 'fruit', 'Fruit') eq_(options['name'], 'fruit') eq_(options['display'], 'Fruit') eq_( options['options'][0], { 'name': 'bananas', 'display': 'bananas', 'value': 'bananas', 'count': 10, 'checked': False, }) eq_( options['options'][1], { 'name': 'oranges', 'display': 'oranges', 'value': 'oranges', 'count': 6, 'checked': False, }) eq_( options['options'][2], { 'name': 'apples', 'display': 'apples', 'value': 'apples', 'count': 5, 'checked': False, })
def test_map_func(self): options = counts_to_options(self.counts, 'fruit', value_map=lambda s: s.upper()) # Note that options get sorted by count. eq_(options['options'][0]['value'], 'BANANAS') eq_(options['options'][1]['value'], 'ORANGES') eq_(options['options'][2]['value'], 'APPLES')
def test_basic(self): """Correct options should be set and values should be sorted. """ options = counts_to_options(self.counts, 'fruit', 'Fruit') eq_(options['name'], 'fruit') eq_(options['display'], 'Fruit') eq_(options['options'][0], { 'name': 'bananas', 'display': 'bananas', 'value': 'bananas', 'count': 10, 'checked': False, }) eq_(options['options'][1], { 'name': 'oranges', 'display': 'oranges', 'value': 'oranges', 'count': 6, 'checked': False, }) eq_(options['options'][2], { 'name': 'apples', 'display': 'apples', 'value': 'apples', 'count': 5, 'checked': False, })
def test_map_dict(self): options = counts_to_options( self.counts, "fruit", display_map={"apples": "Apples", "bananas": "Bananas", "oranges": "Oranges"} ) # Note that options get sorted by count. eq_(options["options"][0]["display"], "Bananas") eq_(options["options"][1]["display"], "Oranges") eq_(options["options"][2]["display"], "Apples")
def test_map_dict(self): options = counts_to_options(self.counts, 'fruit', display_map={ 'apples': 'Apples', 'bananas': 'Bananas', 'oranges': 'Oranges', }) # Note that options get sorted by count. eq_(options['options'][0]['display'], 'Bananas') eq_(options['options'][1]['display'], 'Oranges') eq_(options['options'][2]['display'], 'Apples')
def test_basic(self): """The right options should be set, and the values should be sorted.""" options = counts_to_options(self.counts, "fruit", "Fruit") eq_(options["name"], "fruit") eq_(options["display"], "Fruit") eq_( options["options"][0], {"name": "bananas", "display": "bananas", "value": "bananas", "count": 10, "checked": False}, ) eq_( options["options"][1], {"name": "oranges", "display": "oranges", "value": "oranges", "count": 6, "checked": False}, ) eq_( options["options"][2], {"name": "apples", "display": "apples", "value": "apples", "count": 5, "checked": False}, )
def test_checked(self): options = counts_to_options(self.counts, 'fruit', checked='apples') # Note that options get sorted by count. assert not options['options'][0]['checked'] assert not options['options'][1]['checked'] assert options['options'][2]['checked']
def test_checked(self): options = counts_to_options(self.counts, "fruit", checked="apples") # Note that options get sorted by count. assert not options["options"][0]["checked"] assert not options["options"][1]["checked"] assert options["options"][2]["checked"]
def test_map_func(self): options = counts_to_options(self.counts, "fruit", value_map=lambda s: s.upper()) # Note that options get sorted by count. eq_(options["options"][0]["value"], "BANANAS") eq_(options["options"][1]["value"], "ORANGES") eq_(options["options"][2]["value"], "APPLES")