Esempio n. 1
0
    def test_groupList(self):
        """
        Adapting a C{list} of nested C{list}s, as used by
        L{methanal.view.GroupedSelectInput}, results in an L{Enum} with
        L{EnumItems} with a C{'group'} extra value the same as the first
        element in each C{tuple}. L{IEnumeration.as_pairs} returns a flat
        C{list} for nested C{list}s adapted to L{IEnumeration}.
        """
        values = [
            (u'Group', [
                (u'foo', u'Foo'),
                (u'bar', u'Bar')]),
            (u'Group 2', [
                (u'quux', u'Quux'),
                (u'frob', u'Frob')])]

        enum = IEnumeration(values)
        for groupName, innerValues in values:
            for value, desc in innerValues:
                item = enum.get(value)
                self.assertEquals(item.value, value)
                self.assertEquals(item.desc, desc)
                self.assertEquals(item.get('group'), groupName)

        pairs = sum(zip(*values)[1], [])
        self.assertEquals(enum.as_pairs(), pairs)
Esempio n. 2
0
 def test_list(self):
     """
     Adapting a C{list} to L{IEnumeration} results in an L{Enum} accurately
     representing the list.
     """
     values = [(u'foo', u'Foo'), (u'bar', u'Bar')]
     enum = IEnumeration(values)
     self.assertEquals(enum.as_pairs(), values)
     for value, desc in values:
         item = enum.get(value)
         self.assertEquals(item.value, value)
         self.assertEquals(item.desc, desc)
Esempio n. 3
0
 def test_list(self):
     """
     Adapting a C{list} to L{IEnumeration} results in an L{Enum} accurately
     representing the list.
     """
     values = [
         (u'foo', u'Foo'),
         (u'bar', u'Bar')]
     enum = IEnumeration(values)
     self.assertEquals(enum.as_pairs(), values)
     for value, desc in values:
         item = enum.get(value)
         self.assertEquals(item.value, value)
         self.assertEquals(item.desc, desc)
Esempio n. 4
0
    def test_groupList(self):
        """
        Adapting a C{list} of nested C{list}s, as used by
        L{methanal.view.GroupedSelectInput}, results in an L{Enum} with
        L{EnumItems} with a C{'group'} extra value the same as the first
        element in each C{tuple}. L{IEnumeration.as_pairs} returns a flat
        C{list} for nested C{list}s adapted to L{IEnumeration}.
        """
        values = [(u'Group', [(u'foo', u'Foo'), (u'bar', u'Bar')]),
                  (u'Group 2', [(u'quux', u'Quux'), (u'frob', u'Frob')])]

        enum = IEnumeration(values)
        for groupName, innerValues in values:
            for value, desc in innerValues:
                item = enum.get(value)
                self.assertEquals(item.value, value)
                self.assertEquals(item.desc, desc)
                self.assertEquals(item.get('group'), groupName)

        pairs = sum(zip(*values)[1], [])
        self.assertEquals(enum.as_pairs(), pairs)