Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_make_column_name(self):
c = sql.make_column(table.Column(0, 'test', [u'1', u'-87', u'418000000', u'']))
self.assertEqual(c.key, 'test')
def test_column_has_nulls(self):
c = sql.make_column(table.Column(0, 'test', [u'1', u'-87', u'418000000', u'']))
self.assertEqual(c.key, 'test')
self.assertEqual(type(c.type), Integer)
self.assertEqual(c.nullable, True)
def test_table_append_duplicate_name(self):
c = table.Column(0, u'test', [u'test', u'column', u''])
c2 = table.Column(0, u'test', [u'test', u'column', u''])
c3 = table.Column(0, u'test', [u'test', u'column', u''])
t = table.Table()
t.append(c)
t.append(c2)
t.append(c3)
self.assertEqual(t[0].name, 'test')
self.assertEqual(t[1].name, 'test_2')
self.assertEqual(t[2].name, 'test_3')
def test_make_column_big_int(self):
c = sql.make_column(table.Column(0, 'test', [u'1', u'-87', u'418000000', u'2147483648']))
self.assertEqual(c.key, 'test')
self.assertEqual(type(c.type), BigInteger)
def test_table_count_rows(self):
c = table.Column(0, u'test', [u'test', u'column', u''])
c_short = table.Column(0, u'test', [u'test'])
c_long = table.Column(0, u'test', [u'', u'', u'', u''])
t = table.Table()
self.assertEqual(t.count_rows(), 0)
t.append(c)
self.assertEqual(t.count_rows(), 3)
t.append(c_short)
self.assertEqual(t.count_rows(), 3)
t.append(c_long)
self.assertEqual(t.count_rows(), 4)
def test_table_extend(self):
c = table.Column(0, u'test', [u'test', u'column', u''])
c2 = table.Column(0, u'test', [u'test', u'column', u''])
c3 = table.Column(0, u'test', [u'test', u'column', u''])
t = table.Table([c])
t.extend([c2, c3])
self.assertEqual(len(t), 3)
self.assertEqual(t[0], c)
self.assertEqual(t[1], c2)
self.assertEqual(t[2], c3)
self.assertEqual(t[0].order, 0)
self.assertEqual(t[1].order, 1)
self.assertEqual(t[2].order, 2)
def test_make_column_null(self):
c = sql.make_column(table.Column(0, 'test', [u'', u'', u'']))
self.assertEqual(type(c.type), String)
def test_table_uneven_columns(self):
c = table.Column(0, u'test', [u'test', u'column', u''])
c_short = table.Column(0, u'test', [u'test'])
c_long = table.Column(0, u'test', [u'', u'', u'', u'way out here'])
t = table.Table([c, c_short, c_long])
self.assertEqual(t.row(0), [u'test', u'test', None])
self.assertEqual(t.row(1), [u'column', None, None])
self.assertEqual(t.row(2), [None, None, None])
self.assertEqual(t.row(3), [None, None, u'way out here'])
def setUp(self):
self.csv_table = table.Table([
table.Column(0, u'text', [u'Chicago Reader', u'Chicago Sun-Times', u'Chicago Tribune', u'Row with blanks']),
table.Column(1, u'integer', [u'40', u'63', u'164', u'']),
table.Column(2, u'datetime', [u'Jan 1, 2008 at 4:40 AM', u'2010-01-27T03:45:00', u'3/1/08 16:14:45', u'']),
table.Column(3, u'empty_column', [u'', u'', u'', u''])],
name='test_table')
def test_table_remove(self):
c = table.Column(0, u'test', [u'test', u'column', u''])
c2 = table.Column(0, u'test', [u'test', u'column', u''])
c3 = table.Column(0, u'test', [u'test', u'column', u''])
t = table.Table([c, c2, c3])
t.remove(c2)
self.assertEqual(len(t), 2)
self.assertEqual(t[0], c)
self.assertEqual(t[1], c3)
self.assertEqual(t[0].order, 0)
self.assertEqual(t[1].order, 1)