예제 #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_db_set_multi(self):
     db = DataBase(store)
     with self.assertRaises(DataBaseError):
         db.db_set_multi({'a': 1, 'b': 2})
     db = DataBase(store, beansdb=beansdb)
     db.db_set_multi({'a': 1, 'b': 2})
     self.assertEqual(db.db_get('a'), 1)
     self.assertEqual(db.db_get('b'), 2)
예제 #3
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()
예제 #4
0
 def test_db_delete_multi(self):
     db = DataBase(store, beansdb=beansdb)
     db.db_delete_multi(['a', 'b'])
     self.assertIsNone(db.db_get('a'))
     self.assertIsNone(db.db_get('b'))