def testMakeTableData_GroupBy(self): issue = fake.MakeTestIssue(789, 1, 'summary', 'New', 0, labels=['Type-Defect', 'Priority-Medium']) visible_results = [issue] # 2 columns -> 2 cells with 1 value in each cell, row is part of a 1-row # group of issues with type=defect. lower_columns = ['type', 'priority'] table_data = issuelist._MakeTableData(visible_results, [], lower_columns, ['type'], {}, CELL_FACTORIES, {}, self.config) self.assertEqual(1, len(table_data)) row = table_data[0] self.assertEqual(len(lower_columns), len(row.cells)) self.assertEqual(0, row.cells[0].col_index) self.assertEqual(1, len(row.cells[0].values)) self.assertEqual('Defect', row.cells[0].values[0].item) self.assertEqual(1, row.cells[1].col_index) self.assertEqual(1, len(row.cells[1].values)) self.assertEqual('Medium', row.cells[1].values[0].item) self.assertEqual(1, len(row.group.cells)) self.assertEqual('Defect', row.group.cells[0].values[0].item)
def testMakeTableData_Normal(self): issue = fake.MakeTestIssue(789, 123, 'summary', 'New', 0, labels=['Type-Defect', 'Priority-Medium']) issue.project_name = 'proj' visible_results = [issue] # Standard columns lower_columns = _GetColumns() table_data = issuelist._MakeTableData(visible_results, [], lower_columns, [], {}, CELL_FACTORIES, {}, self.config) self.assertEqual(1, len(table_data)) row = table_data[0] self.assertEqual(len(lower_columns), len(row.cells)) self.assertEqual([], row.group.cells) # Also test row info that we pass to JS code. self.assertEqual(123, row.local_id) self.assertEqual('proj', row.project_name) self.assertEqual('proj:123', row.issue_ref) self.assertEqual('/p/proj/issues/detail?id=123', row.issue_url) # 2 columns -> 2 cells with 1 value in each cell. lower_columns = ['type', 'priority'] table_data = issuelist._MakeTableData(visible_results, [], lower_columns, [], {}, CELL_FACTORIES, {}, self.config) self.assertEqual(1, len(table_data)) row = table_data[0] self.assertEqual(len(lower_columns), len(row.cells)) self.assertEqual(0, row.cells[0].col_index) self.assertEqual(1, len(row.cells[0].values)) self.assertEqual('Defect', row.cells[0].values[0].item) self.assertEqual(1, row.cells[1].col_index) self.assertEqual(1, len(row.cells[1].values)) self.assertEqual('Medium', row.cells[1].values[0].item) self.assertEqual([], row.group.cells)
def testMakeTableData_Combined(self): issue = fake.MakeTestIssue( 789, 1, 'summary', 'New', 0, labels=['Type-Defect', 'Priority-Medium']) visible_results = [issue] # A combined column -> 1 cell with 2 values in it. lower_columns = ['type/priority'] table_data = issuelist._MakeTableData( visible_results, [], lower_columns, [], {}, CELL_FACTORIES, {}, self.config) self.assertEqual(1, len(table_data)) row = table_data[0] self.assertEqual(len(lower_columns), len(row.cells)) self.assertEqual(0, row.cells[0].col_index) self.assertEqual(2, len(row.cells[0].values)) self.assertEqual('Defect', row.cells[0].values[0].item) self.assertEqual('Medium', row.cells[0].values[1].item) self.assertEqual([], row.group.cells)