Пример #1
0
    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,
            })
Пример #2
0
 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')
Пример #3
0
    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,
        })
Пример #4
0
 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")
Пример #5
0
 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')
Пример #6
0
 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')
Пример #7
0
 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')
Пример #8
0
    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},
        )
Пример #9
0
 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']
Пример #10
0
 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"]
Пример #11
0
 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")
Пример #12
0
 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']