コード例 #1
0
 def test_commit(self):
     self.db.set('key', {'hello': 'world'})
     db = MeuhDb(self.filename)  # reload
     self.assertFalse(db.exists("key"))
     self.db.commit()
     db = MeuhDb(self.filename)  # reload
     self.assertTrue(db.exists("key"))
     self.assertEquals(db.get('key'), {'hello': 'world'})
コード例 #2
0
 def test_autocommit_after(self):
     self.db.set('key', {'name': 'Alice'})
     db = MeuhDb(self.filename)  # reload
     self.assertFalse(db.exists('key'))
     self.db.set('key', {'name': 'Alice 2'})
     db = MeuhDb(self.filename)  # reload
     self.assertFalse(db.exists('key'))
     self.db.set('key', {'name': 'Alice 3'})
     db = MeuhDb(self.filename)  # reload
     self.assertTrue(db.exists('key'))
コード例 #3
0
 def test_autocommit_after_other_command(self):
     self.db.set('key1', {'name': 'Alice'})
     self.db.set('key2', {'name': 'Alice'})
     self.db.set('key3', {'name': 'Alice'})
     # Should be committed
     self.db.delete('key3')
     db = MeuhDb(self.filename)  # reload
     self.assertTrue(db.exists('key3'))
コード例 #4
0
 def test_create_index(self):
     self.db.set('1', {'name': 'Alice'})
     self.db.set('2', {'name': 'Bob'})
     self.db.create_index('name')
     db = MeuhDb(self.filename)  # reload
     self.assertTrue(db.exists('1'))
     self.assertTrue(db.exists('2'))
     self.assertTrue('name' in db.indexes)
     index = db.indexes['name']
     self.assertEquals(index['Alice'], set(['1']))
     self.assertEquals(index['Bob'], set(['2']))
コード例 #5
0
 def test_delete(self):
     self.db.set('key', {'hello': 'world'})
     self.db.delete('key')
     db = MeuhDb(self.filename)  # reload
     self.assertFalse(db.exists('key'))