コード例 #1
0
 def test_db_set(self):
     db = DataBase(store)
     with self.assertRaises(DataBaseError):
         db.db_set('a', 'b')
     db = DataBase(store, beansdb=beansdb)
     db.db_set('a', 'b')
     self.assertEqual(db.db_get('a'), 'b')
コード例 #2
0
 def test_do_beansdb_commands(self):
     db = DataBase(store)
     with db.transaction():
         with self.assertRaises(DataBaseError):
             db.db_set('a', 'xixi')
     db = DataBase(store, beansdb=beansdb)
     oa = db.db_get('a')
     ob = db.db_get('b')
     try:
         with db.transaction():
             db.db_set('a', 'xixi')
             db.db_set('b', 'haha')
             raise AE
     except AE:
         pass
     self.assertEqual(db.db_get('a'), oa)
     self.assertEqual(db.db_get('b'), ob)
     with db.transaction():
         db.db_set('a', 'xixi')
         db.db_set('b', 'haha')
     self.assertEqual(db.db_get('a'), 'xixi')
     self.assertEqual(db.db_get('b'), 'haha')
     db._local.append_beansdb_commands(('error', (), {}))
     db._do_beansdb_commands()