示例#1
0
 def should_compare_rows_as_tuples_of_Values(self):
     row = sql.Row([1, 2, 'foo'], ['First', 'Second', 'Third'])
     same = sql.Row([1, 2, 'foo'], ['First', 'Second', 'Third'])
     other = sql.Row([1, 3, 'foo'], ['First', 'Second', 'Third'])
     self.assertEqual(row, same)
     self.assertNotEqual(row, other)
     self.assertTrue(row == same)
     self.assertFalse(row != same)
     self.assertFalse(row == other)
     self.assertTrue(row <= same)
     self.assertFalse(row < same)
     self.assertTrue(row <= other)
     self.assertTrue(row < other)
示例#2
0
 def should_representt_row_as_string(self):
     row = sql.Row([1, 2, 'foo'], ['First', 'Second', 'Third'])
     self.assertEqual(str(row), "{'First':1, 'Second':2, 'Third':'foo'}")
     self.assertEqual(repr(row),
                      "Row((1, 2, 'foo'), ('First', 'Second', 'Third'))")
示例#3
0
 def should_access_headers(self):
     row = sql.Row([1, 2, 'foo'], ['First', 'Second', 'Third'])
     self.assertEqual(row.get_headers(), ('First', 'Second', 'Third'))
     row = sql.Row([1, 2, 'foo'])
     self.assertEqual(row.get_headers(), ('0', '1', '2'))
示例#4
0
 def should_create_sql_row_without_header(self):
     row = sql.Row([1, 2, 'foo'])
     self.assertEqual(row['0'], 1)
     self.assertEqual(row['1'], 2)
     self.assertEqual(row['2'], 'foo')
     self.assertEqual(tuple(row), (1, 2, 'foo'))
示例#5
0
 def should_create_sql_row(self):
     row = sql.Row([1, 2, 'foo'], ['First', 'Second', 'Third'])
     self.assertEqual(row['First'], 1)
     self.assertEqual(row['Second'], 2)
     self.assertEqual(row['Third'], 'foo')
     self.assertEqual(tuple(row), (1, 2, 'foo'))
示例#6
0
 def should_iterate_over_row(self):
     row = sql.Row([1, 2, 'foo'], ['First', 'Second', 'Third'])
     self.assertEqual(tuple(row), (1, 2, 'foo'))
示例#7
0
 def should_access_row_by_attr(self):
     row = sql.Row([1, 2, 'foo'], ['First', 'Second', 'Third'])
     self.assertEqual(row.First, 1)
     self.assertEqual(row.Second, 2)
     self.assertEqual(row.Third, 'foo')
示例#8
0
 def should_access_row_by_name(self):
     row = sql.Row([1, 2, 'foo'], ['First', 'Second', 'Third'])
     self.assertEqual(row['First'], 1)
     self.assertEqual(row['Second'], 2)
     self.assertEqual(row['Third'], 'foo')
示例#9
0
 def should_access_row_by_index(self):
     row = sql.Row([1, 2, 'foo'], ['First', 'Second', 'Third'])
     self.assertEqual(row[0], 1)
     self.assertEqual(row[1], 2)
     self.assertEqual(row[2], 'foo')