def test_select_single(self): table = Table(self.rows, self.column_names, self.column_types) new_table = table.select('three') self.assertColumnNames(new_table, ['three']) self.assertColumnTypes(new_table, [Text]) self.assertRows(new_table, [['a'], ['b'], [u'👍']])
def test_select_with_row_names(self): table = Table(self.rows, self.column_names, self.column_types, row_names='three') new_table = table.select(('three', )) self.assertRowNames(new_table, ['a', 'b', u'👍'])
def test_select(self): table = Table(self.rows, self.column_names, self.column_types) new_table = table.select(('two', 'three')) self.assertIsNot(new_table, table) self.assertColumnNames(new_table, ['two', 'three']) self.assertColumnTypes(new_table, [Number, Text]) self.assertRows(new_table, [[4, 'a'], [3, 'b'], [2, u'👍']])
def test_select_single(self): table = Table(self.rows, self.column_names, self.column_types) new_table = table.select('three') self.assertColumnNames(new_table, ['three']) self.assertColumnTypes(new_table, [Text]) self.assertRows(new_table, [ ['a'], ['b'], [u'👍'] ])
def test_chain_select_where(self): table = Table(self.rows, self.column_names, self.column_types) new_table = table.select(('one', 'two')).where(lambda r: r['two'] == 3) self.assertIsNot(new_table, table) self.assertColumnNames(new_table, self.column_names[:2]) self.assertColumnTypes(new_table, [Number, Number]) self.assertRows(new_table, [ self.rows[1][:2], ])
def test_chain_select_where(self): table = Table(self.rows, self.column_names, self.column_types) new_table = table.select(('one', 'two')).where(lambda r: r['two'] == 3) self.assertEqual(len(new_table.rows), 1) self.assertSequenceEqual(new_table.rows[0], (2, 3)) self.assertEqual(len(new_table.columns), 2) self.assertSequenceEqual(new_table._column_types, (self.number_type, self.number_type)) self.assertEqual(new_table._column_names, ('one', 'two')) self.assertSequenceEqual(new_table.columns['one'], (2,))
def test_chain_select_where(self): table = Table(self.rows, self.columns) new_table = table.select(('one', 'two')).where(lambda r: r['two'] == 3) self.assertEqual(len(new_table.rows), 1) self.assertSequenceEqual(new_table.rows[0], (2, 3)) self.assertEqual(len(new_table.columns), 2) self.assertSequenceEqual(new_table._column_types, (self.number_type, self.number_type)) self.assertEqual(new_table._column_names, ('one', 'two')) self.assertSequenceEqual(new_table.columns['one'], (2,))
def test_select(self): table = Table(self.rows, self.column_names, self.column_types) new_table = table.select(('two', 'three')) self.assertIsNot(new_table, table) self.assertColumnNames(new_table, ['two', 'three']) self.assertColumnTypes(new_table, [Number, Text]) self.assertRows(new_table, [ [4, 'a'], [3, 'b'], [2, u'👍'] ])
def test_select(self): table = Table(self.rows, self.column_names, self.column_types) new_table = table.select(('three',)) self.assertIsNot(new_table, table) self.assertEqual(len(new_table.rows), 3) self.assertSequenceEqual(new_table.rows[0], ('a',)) self.assertSequenceEqual(new_table.rows[1], ('b',)) self.assertSequenceEqual(new_table.rows[2], (u'👍',)) self.assertEqual(len(new_table.columns), 1) self.assertSequenceEqual(new_table._column_types, (self.text_type,)) self.assertSequenceEqual(new_table._column_names, ('three',)) self.assertSequenceEqual(new_table.columns['three'], ('a', 'b', u'👍'))
def test_select(self): table = Table(self.rows, self.columns) new_table = table.select(('three',)) self.assertIsNot(new_table, table) self.assertEqual(len(new_table.rows), 3) self.assertSequenceEqual(new_table.rows[0], ('a',)) self.assertSequenceEqual(new_table.rows[1], ('b',)) self.assertSequenceEqual(new_table.rows[2], (u'👍',)) self.assertEqual(len(new_table.columns), 1) self.assertSequenceEqual(new_table._column_types, (self.text_type,)) self.assertSequenceEqual(new_table._column_names, ('three',)) self.assertSequenceEqual(new_table.columns['three'], ('a', 'b', u'👍'))
def test_select_does_not_exist(self): table = Table(self.rows, self.column_names, self.column_types) with self.assertRaises(KeyError): table.select(('four',))
def test_select_with_row_names(self): table = Table(self.rows, self.column_names, self.column_types, row_names='three') new_table = table.select(('three',)) self.assertSequenceEqual(new_table.rows['a'], ('a',)) self.assertSequenceEqual(new_table.row_names, ('a', 'b', u'👍'))
def test_select_does_not_exist(self): table = Table(self.rows, self.column_names, self.column_types) with self.assertRaises(ValueError): table.select(('four', ))
def test_select_with_row_names(self): table = Table(self.rows, self.column_names, self.column_types, row_names='three') new_table = table.select(('three',)) self.assertRowNames(new_table, ['a', 'b', u'👍'])
def test_select_with_row_names(self): table = Table(self.rows, self.columns, row_names='three') new_table = table.select(('three',)) self.assertSequenceEqual(new_table.rows['a'], ('a',)) self.assertSequenceEqual(new_table.row_names, ('a', 'b', u'👍'))
def test_select_does_not_exist(self): table = Table(self.rows, self.columns) with self.assertRaises(KeyError): table.select(('four',))