def testInvalidColumnAlignmentsLength(self):
        t = TableGenerator.createTableWithDefaultContainer(7, 7)
        defaultAlignments = [Table.ALIGN_LEFT, Table.ALIGN_LEFT,
                Table.ALIGN_LEFT, Table.ALIGN_LEFT, Table.ALIGN_LEFT,
                Table.ALIGN_LEFT, Table.ALIGN_LEFT]

        try:
            t.setColumnAlignments([Table.ALIGN_LEFT])
            self.fail('No exception thrown for invalid array length')
        except ValueError:
            pass  # Ok, expected

        self.assertEquals(defaultAlignments, t.getColumnAlignments(),
                'Invalid change affected alignments')

        try:
            t.setColumnAlignments([])
            self.fail('No exception thrown for invalid array length')
        except ValueError:
            pass  # Ok, expected

        self.assertEquals(defaultAlignments, t.getColumnAlignments(),
                'Invalid change affected alignments')

        try:
            t.setColumnAlignments([Table.ALIGN_LEFT, Table.ALIGN_LEFT,
                    Table.ALIGN_LEFT, Table.ALIGN_LEFT, Table.ALIGN_LEFT,
                    Table.ALIGN_LEFT, Table.ALIGN_LEFT, Table.ALIGN_LEFT])
            self.fail('No exception thrown for invalid array length')
        except ValueError:
            pass  # Ok, expected

        self.assertEquals(defaultAlignments, t.getColumnAlignments(),
                'Invalid change affected alignments')
 def testDefaultVisibleColumns(self):
     for properties in range(10):
         t = TableGenerator.createTableWithDefaultContainer(properties, 10)
         expected = [None] * properties
         for i in range(properties):
             expected[i] = 'Property %d' % i
         self.assertEquals(expected, t.getVisibleColumns(),
                 'getVisibleColumns')
 def testExplicitColumnAlignments(self):
     properties = 5
     t = TableGenerator.createTableWithDefaultContainer(properties, 10)
     explicitAlignments = [Table.ALIGN_CENTER, Table.ALIGN_LEFT,
             Table.ALIGN_RIGHT, Table.ALIGN_RIGHT, Table.ALIGN_LEFT]
     t.setColumnAlignments(explicitAlignments)
     self.assertEquals(explicitAlignments, t.getColumnAlignments(),
             'Explicit visible columns, 5 properties')
 def testDefaultColumnAlignments(self):
     for properties in range(10):
         t = TableGenerator.createTableWithDefaultContainer(properties, 10)
         expected = [None] * properties
         for i in range(properties):
             expected[i] = Table.ALIGN_LEFT
         self.assertEquals(expected, t.getColumnAlignments(),
                 'getColumnAlignments')
    def testInvalidVisibleColumnIds(self):
        t = TableGenerator.createTableWithDefaultContainer(3, 10)

        try:
            t.setVisibleColumns(['a', 'Property 2', 'Property 3'])
            self.fail('IllegalArgumentException expected')
        except ValueError:
            pass  # OK, expected

        self.assertEquals(self._defaultColumns3, t.getVisibleColumns())
    def testDuplicateVisibleColumnIds(self):
        t = TableGenerator.createTableWithDefaultContainer(3, 10)

        try:
            t.setVisibleColumns(['Property 0', 'Property 1', 'Property 2',
                    'Property 1'])
            # FIXME: Multiple properties in the Object array should be detected
            # (#6476)
            #self.fail("IllegalArgumentException expected")
        except ValueError:
            pass  # OK, expected
    def testColumnAlignmentForPropertyNotInContainer(self):
        t = TableGenerator.createTableWithDefaultContainer(3, 7)
        defaultAlignments = [Table.ALIGN_LEFT, Table.ALIGN_LEFT,
                Table.ALIGN_LEFT]

        try:
            t.setColumnAlignment('Property 1200', Table.ALIGN_LEFT)
            # FIXME: Uncomment as there should be an exception (#6475)
            #self.fail("No exception thrown for property not in container")
        except ValueError:
            pass  # Ok, expected

        self.assertEquals(defaultAlignments, t.getColumnAlignments(),
                'Invalid change affected alignments')
    def testExplicitColumnAlignmentOneByOne(self):
        properties = 5
        t = TableGenerator.createTableWithDefaultContainer(properties, 10)
        explicitAlignments = [Table.ALIGN_CENTER, Table.ALIGN_LEFT,
                Table.ALIGN_RIGHT, Table.ALIGN_RIGHT, Table.ALIGN_LEFT]

        currentAlignments = [Table.ALIGN_LEFT, Table.ALIGN_LEFT,
                Table.ALIGN_LEFT, Table.ALIGN_LEFT, Table.ALIGN_LEFT]

        for i in range(properties):
            t.setColumnAlignment('Property %d' % i, explicitAlignments[i])
            currentAlignments[i] = explicitAlignments[i]
            self.assertEquals(currentAlignments, t.getColumnAlignments(),
                    'Explicit visible columns, %d alignments set' % i)
 def noVisibleColumns(self):
     t = TableGenerator.createTableWithDefaultContainer(3, 10)
     t.setVisibleColumns([])
     self.assertEquals([], t.getVisibleColumns())
 def testExplicitVisibleColumns(self):
     t = TableGenerator.createTableWithDefaultContainer(5, 10)
     newVisibleColumns = ['Property 1', 'Property 2']
     t.setVisibleColumns(newVisibleColumns)
     self.assertEquals(newVisibleColumns, t.getVisibleColumns(),
             'Explicit visible columns, 5 properties')