Exemple #1
0
    def test_missingTypeDefaultsToText(self):
        """
        When constructed with an L{IColumn} which returns C{None} from its
        C{getType} method, L{ScrollingElement} should use the default of
        C{text} for that column's type.
        """
        class UntypedColumn(object):
            implements(IColumn)
            attributeID = 'foo'

            def sortAttribute(self):
                return None

            def getType(self):
                return None

        column = UntypedColumn()

        scroller = ScrollingElement(None,
                                    None,
                                    None, [DataThunk.a, column],
                                    None,
                                    webTranslator=object())
        attribute, columnList, ascending = scroller.getInitialArguments()
        self.assertEqual(columnList, [{
            u'type': u'integer',
            u'name': u'a'
        }, {
            u'type': u'text',
            u'name': u'foo'
        }])
 def test_initialWidgetArguments(self):
     """
     Verify that the arguments the client widget expects: the name of the
     current sort column, a list of the available data columns, and the sort
     order.
     """
     s = Store()
     testElement = ScrollingElement(s, DataThunk, None,
                                    [DataThunk.a, DataThunk.c],
                                    DataThunk.a, True,
                                    FakeTranslator())
     self.assertEqual(testElement.getInitialArguments(),
                      [u"a",
                      [{u"name": u"a",
                        u"type": u"integer"},
                       {u"name": u"c",
                        u"type": u"text"}],
                       True])
Exemple #3
0
 def test_initialWidgetArguments(self):
     """
     Verify that the arguments the client widget expects: the name of the
     current sort column, a list of the available data columns, and the sort
     order.
     """
     s = Store()
     testElement = ScrollingElement(s, DataThunk, None,
                                    [DataThunk.a, DataThunk.c], DataThunk.a,
                                    True, FakeTranslator())
     self.assertEqual(testElement.getInitialArguments(), [
         u"a",
         [{
             u"name": u"a",
             u"type": u"integer"
         }, {
             u"name": u"c",
             u"type": u"text"
         }], True
     ])
    def test_missingTypeDefaultsToText(self):
        """
        When constructed with an L{IColumn} which returns C{None} from its
        C{getType} method, L{ScrollingElement} should use the default of
        C{text} for that column's type.
        """
        class UntypedColumn(object):
            implements(IColumn)
            attributeID = 'foo'
            def sortAttribute(self):
                return None
            def getType(self):
                return None
        column = UntypedColumn()

        scroller = ScrollingElement(
            None, None, None, [DataThunk.a, column], None,
            webTranslator=object())
        attribute, columnList, ascending = scroller.getInitialArguments()
        self.assertEqual(
            columnList,
            [{u'type': u'integer', u'name': u'a'},
             {u'type': u'text', u'name': u'foo'}])