Exemple #1
0
 def test_records_with_string(self):
     RecordManager.insert('ggg', '<idi4s', (1, 2.0, 3, 'temps'))
     # todo: check the length of string in the given attributes ?
     self.assertEqual(
         RecordManager.select('ggg',
                              '<idi4s',
                              with_index=True,
                              record_offset=0), (1, 2.0, 3, 'temp'))
     RecordManager.insert('ggg', '<idi4s',
                          (1, 2.0, 3, 'no'))  # less than maximum length
     self.assertEqual(
         RecordManager.select('ggg',
                              '<idi4s',
                              with_index=True,
                              record_offset=1), (1, 2.0, 3, 'no'))
     RecordManager.update('ggg',
                          '<idi4s', (1, 2.0, 3, 'nono'),
                          with_index=True,
                          record_offset=1)
     self.assertEqual(
         RecordManager.select('ggg',
                              '<idi4s',
                              with_index=True,
                              record_offset=1), (1, 2.0, 3, 'nono'))
     RecordManager.delete('ggg', '<idi4s', with_index=True, record_offset=1)
     RecordManager.delete('ggg', '<idi4s', with_index=True, record_offset=0)
     with self.assertRaises(RuntimeError):
         RecordManager.select('ggg',
                              '<idi4s',
                              with_index=True,
                              record_offset=0)
         RecordManager.update('ggg',
                              '<idi4s', (1, 2.0, 3, 'nono'),
                              with_index=True,
                              record_offset=1)
Exemple #2
0
 def test_record_manager(self):
     RecordManager.insert('gg', '<idi', (1, 3.0, 4))
     RecordManager.insert('gg', '<idi', (-1, 3.5, -1))
     self.assertEqual(
         RecordManager.select('gg',
                              '<idi',
                              with_index=True,
                              record_offset=1), (-1, 3.5, -1))
     RecordManager.update('gg',
                          '<idi', (1, 3.0, 4),
                          with_index=True,
                          record_offset=1)
     self.assertEqual(
         RecordManager.select('gg',
                              '<idi',
                              with_index=True,
                              record_offset=1), (1, 3.0, 4))
     RecordManager.delete('gg', '<idi', with_index=True, record_offset=1)
     with self.assertRaises(RuntimeError):
         RecordManager.select('gg',
                              '<idi',
                              with_index=True,
                              record_offset=1)
         RecordManager.update('gg',
                              '<idi', (1, 2.0, 3),
                              with_index=True,
                              record_offset=1)
Exemple #3
0
 def test_without_index(self):
     RecordManager.insert('foo3', 'i4sd', (1, 'abcd', 1.0))
     RecordManager.insert('foo3', 'i4sd', (1, 'bcde', 1.0))
     conditions = dict()
     conditions[0] = {'=': 1}
     self.assertEqual(
         RecordManager.select('foo3',
                              'i4sd',
                              with_index=False,
                              conditions=conditions), [(1, 'abcd', 1.0),
                                                       (1, 'bcde', 1.0)])
     RecordManager.delete('foo3',
                          'i4sd',
                          with_index=False,
                          conditions=conditions)
     self.assertEqual(
         RecordManager.select('foo3',
                              'i4sd',
                              with_index=False,
                              conditions=conditions), [])
     RecordManager.insert('foo3', 'i4sd', (1, 'abcd', 1.0))
     RecordManager.insert('foo3', 'i4sd', (1, 'bcde', 1.0))
     del conditions[0]
     conditions[1] = {'=': 'abcd'}
     RecordManager.update('foo3',
                          'i4sd', (2, 'cccc', 1.0),
                          with_index=False,
                          conditions=conditions)
     del conditions[1]
     conditions[2] = {'=': 1.0}
     self.assertEqual(
         RecordManager.select('foo3',
                              'i4sd',
                              with_index=False,
                              conditions=conditions), [(1, 'bcde', 1.0),
                                                       (2, 'cccc', 1.0)])