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')
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)
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()
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'))