Beispiel #1
0
 def test_multivalued_pk(self):
     x = _DBRow(parent_schema=None, table=None, pk='a b',
         value_dict={'a':'a1', 'b':'b1', 'c':'c1'}
     )
     self.assertEqual(x.a.value, 'a1')
     self.assertEqual(x.b.value, 'b1')
     self.assertEqual(x.c.value, 'c1')
Beispiel #2
0
 def test_repr(self):
     x = _DBRow(parent_schema=None, table=None, pk='a b',
         value_dict={'a':1, 'b':'1', 'c':'c1'}
     )
     self.assertEqual(repr(x),
         "_DBRow(None, 'a b', {"
         "'a': _DBValue(None, 1), "
         "'c': _DBValue(None, 'c1'), "
         "'b': _DBValue(None, '1')"
         "})"
     )
Beispiel #3
0
 def test_column_values(self):
     x = _DBRow(parent_schema=None, table=None,
                 pk=('k'),
                 value_dict={'k':'a1', 'b':'b1', 'c': 'c1', 'd': 'd1'}
             )
     # Specify columns by different types:
     self.assertEqual(x.column_values(('b', 'c')), ('b1', 'c1')) # tuple
     self.assertEqual(x.column_values(('b', 'c')), ('b1', 'c1')) # list
     self.assertEqual(x.column_values('b c'), ('b1', 'c1')) # string
     # Change column order:
     self.assertEqual(x.column_values('k b c d'), ('a1', 'b1', 'c1', 'd1'))
     self.assertEqual(x.column_values('b k c d'), ('b1', 'a1', 'c1', 'd1'))
     self.assertEqual(x.column_values('d b c k'), ('d1', 'b1', 'c1', 'a1'))
     self.assertEqual(x.column_values('d c b k'), ('d1', 'c1', 'b1', 'a1'))
     # Repeat columns:
     self.assertEqual(x.column_values('d d d'), ('d1', 'd1', 'd1'))
     self.assertEqual(x.column_values('b c b'), ('b1', 'c1', 'b1'))
Beispiel #4
0
 def test_getattr(self):
     x = _DBRow(parent_schema=None, table=None, pk='k', value_dict={'k':'a1', 'b':'b1'})
     self.assertEqual(x.k.value, 'a1')
     self.assertEqual(x.b.value, 'b1')