Esempio n. 1
0
 def test_callComparableValue(self):
     """
     L{ScrollingElement} should attempt to call L{IColumn.toComparableValue} to
     translate input from JavaScript if it is provided by the sort column.
     """
     calledWithValues = []
     column = AttributeColumn(DataThunk.a)
     column.toComparableValue = lambda v: (calledWithValues.append(v), 0)[1]
     scrollingElement = ScrollingElement(
         Store(), DataThunk, None, [column], webTranslator=FakeTranslator())
     scrollingElement.rowsAfterValue(16, 10)
     self.assertEqual(calledWithValues, [16])
     calledWithValues.pop()
     scrollingElement.rowsBeforeValue(11, 10)
     self.assertEqual(calledWithValues, [11])
Esempio n. 2
0
    def test_unsortableColumnWrapper(self):
        attr = DataThunk.a
        col = AttributeColumn(attr)
        unsortableCol = UnsortableColumnWrapper(col)

        item = DataThunk(store=Store(), a=26)

        value = unsortableCol.extractValue(None, item)
        self.assertEquals(value, item.a)
        self.assertEquals(value, col.extractValue(None, item))

        typ = unsortableCol.getType()
        self.assertEquals(typ, 'integer')
        self.assertEquals(typ, col.getType())

        self.assertEquals(unsortableCol.sortAttribute(), None)
Esempio n. 3
0
    def test_unsortableColumnWrapper(self):
        attr = DataThunk.a
        col = AttributeColumn(attr)
        unsortableCol = UnsortableColumnWrapper(col)

        item = DataThunk(store=Store(), a=26)

        value = unsortableCol.extractValue(None, item)
        self.assertEquals(value, item.a)
        self.assertEquals(value, col.extractValue(None, item))

        typ = unsortableCol.getType()
        self.assertEquals(typ, 'integer')
        self.assertEquals(typ, col.getType())

        self.assertEquals(unsortableCol.sortAttribute(), None)
Esempio n. 4
0
 def test_callComparableValue(self):
     """
     L{ScrollingElement} should attempt to call L{IColumn.toComparableValue} to
     translate input from JavaScript if it is provided by the sort column.
     """
     calledWithValues = []
     column = AttributeColumn(DataThunk.a)
     column.toComparableValue = lambda v: (calledWithValues.append(v), 0)[1]
     scrollingElement = ScrollingElement(Store(),
                                         DataThunk,
                                         None, [column],
                                         webTranslator=FakeTranslator())
     scrollingElement.rowsAfterValue(16, 10)
     self.assertEqual(calledWithValues, [16])
     calledWithValues.pop()
     scrollingElement.rowsBeforeValue(11, 10)
     self.assertEqual(calledWithValues, [11])
Esempio n. 5
0
 def test_unsortableColumnType(self):
     """
     L{UnsortableColumn.getType} should return the same value as
     L{AttributeColumn.getType} for a particular attribute.
     """
     self.assertEqual(
         AttributeColumn(DataThunk.a).getType(),
         UnsortableColumn(DataThunk.a).getType())
Esempio n. 6
0
    def testUnsortableColumnWrapper(self):
        """
        Test that an L{UnsortableColumnWrapper} wrapping an L{AttributeColumn}
        is treated the same as L{UnsortableColumn}
        """
        sf = ScrollingFragment(self.store, DataThunk, None,
                               (UnsortableColumnWrapper(
                                   AttributeColumn(DataThunk.a)), DataThunk.b))

        self.assertEquals(sf.currentSortColumn, DataThunk.b)