Beispiel #1
0
    def _test_compress(self, overflow):
        store = MCStore(self.db.addr)
        value = string.letters
        compressed_value = zlib.compress(value, 0)
        key = 'k' * (256 - len(compressed_value) - 24 + (1 if overflow else 0))

        value_easy_compress = 'v' * len(compressed_value)
        self.assertTrue(store.set(key, value_easy_compress))
        self.assertEqual(store.get(key), value_easy_compress)
        self.update_pos(256)
        self.assertEqual(self.get_meta(store, key), (1, 0, self.last_pos))

        self.assertTrue(store.set_raw(key, compressed_value, flag=0x00000010))
        self.assertEqual(store.get(key), value)
        self.update_pos(512 if overflow else 256)
        self.assertEqual(self.get_meta(store, key), (2, 0, self.last_pos))

        self.assertTrue(store.set(key, 'aaa'))
        self.update_pos(256)
        self.assertEqual(self.get_meta(store, key), (3, 0, self.last_pos))
        self.checkCounterZero()
Beispiel #2
0
    def test_set_version(self):
        store = MCStore(self.proxy.addr)
        key = 'key1'
        store.set(key, 'aaa')
        self.update_pos(256)

        self.assertEqual(store.get(key), 'aaa')
        self.assertEqual(self.get_meta(store, key), (1, 0, self.last_pos))

        store.set_raw(key, 'bbb', rev=3)
        self.update_pos(256)
        self.assertEqual(self.get_meta(store, key), (3, 0, self.last_pos))

        store.set_raw(key, 'bbb', rev=4)
        self.assertEqual(self.get_meta(store, key), (4, 0, self.last_pos))

        store.set_raw(key, 'ccc', rev=2)
        self.assertEqual(store.get(key), 'bbb')
        self.assertEqual(self.get_meta(store, key), (4, 0, self.last_pos))

        self.checkCounterZero()