예제 #1
0
파일: test.py 프로젝트: 29n/beansdb
 def testRange(self):
     self.store.close()
     t = HStore(self.store.path, 1, 0, 8)
     for i in range(200):
         t.set('/test/test%d.jpg'%i, 'value%d'%i)
     s = t.get('@')
     n = sum(int(l.split(' ')[2]) for l in s.split('\n') if l)
     t.close()
     self.assertEqual(n, 110)
예제 #2
0
파일: test.py 프로젝트: mvmap/mvptest
 def testRange(self):
     self.store.close()
     t = HStore(self.store.path, 1, 0, 8)
     for i in range(200):
         t.set('/test/test%d.jpg' % i, 'value%d' % i)
     s = t.get('@')
     n = sum(int(l.split(' ')[2]) for l in s.split('\n') if l)
     t.close()
     self.assertEqual(n, 110)
예제 #3
0
파일: test.py 프로젝트: 29n/beansdb
class TestHStore(unittest.TestCase):
    height = 0
    def setUp(self):
        self.store = HStore("/tmp/tmpdb2", self.height)
        self.store.clear()

    def tearDown(self):
        self.store.clear()
        self.store.close()

    def testSetGet(self):
        self.assertEqual(self.store.get('test'), None)
        self.store.set('test', 'value')
        self.assertEqual(self.store.get('test'), 'value')
        self.store.delete('test')
        self.assertEqual(self.store.get('test'), None)

    def testVersion(self):
        self.store.delete('test')
        self.assertEqual(self.store.get('test'), None)

        self.store.set('test', 'value1', 0)
        self.assertEqual(self.store.get('test'), 'value1')
        #self.assertEqual(self.store.get('@'), 'test 1984411239 1\n')

        self.store.set('test', 'value2', 0)
        self.assertEqual(self.store.get('test'), 'value2')

        self.store.set('test', 'value3', 2)
        self.assertEqual(self.store.get('test'), 'value2')

        self.store.set('test', 'value4', 4)
        self.assertEqual(self.store.get('test'), 'value4')

        self.store.delete('test')
        self.assertEqual(self.store.get('test'), None)

    def testHash(self):
        for i in range(200):
            self.store.set('/test/test%d.jpg'%i, 'value%d'%i)
        s = self.store.get('@')
        n = sum(int(l.split(' ')[2]) for l in s.split('\n') if l)
        self.assertEqual(n, 200)
        s = self.store.get('@0')
        n = sum(1 for l in s.split('\n') if l)
        if n == 16:
            n = sum(int(l.split(' ')[2]) for l in s.split('\n') if l)
        self.assertEqual(n, 10)

    def testScan(self):
        self.testHash()
        self.store.close()
        
        os.unlink(self.store.path + '/.0.index')
        t = HStore(self.store.path, self.store.height)
        t.check()
        try:
            s = t.get('@')
            n = sum(int(l.split(' ')[2]) for l in s.split('\n') if l)
            self.assertEqual(n, 200)
            s = t.get('@0')
            n = sum(1 for l in s.split('\n') if l)
            if n == 16:
                n = sum(int(l.split(' ')[2]) for l in s.split('\n') if l)
            self.assertEqual(n, 10)
        finally:
            t.close()

    def testRange(self):
        self.store.close()
        t = HStore(self.store.path, 1, 0, 8)
        for i in range(200):
            t.set('/test/test%d.jpg'%i, 'value%d'%i)
        s = t.get('@')
        n = sum(int(l.split(' ')[2]) for l in s.split('\n') if l)
        t.close()
        self.assertEqual(n, 110)
예제 #4
0
파일: test.py 프로젝트: mvmap/mvptest
class TestHStore(unittest.TestCase):
    height = 0

    def setUp(self):
        self.store = HStore("/tmp/tmpdb2", self.height)
        self.store.clear()

    def tearDown(self):
        self.store.clear()
        self.store.close()

    def testSetGet(self):
        self.assertEqual(self.store.get('test'), None)
        self.store.set('test', 'value')
        self.assertEqual(self.store.get('test'), 'value')
        self.store.delete('test')
        self.assertEqual(self.store.get('test'), None)

    def testVersion(self):
        self.store.delete('test')
        self.assertEqual(self.store.get('test'), None)

        self.store.set('test', 'value1', 0)
        self.assertEqual(self.store.get('test'), 'value1')
        #self.assertEqual(self.store.get('@'), 'test 1984411239 1\n')

        self.store.set('test', 'value2', 0)
        self.assertEqual(self.store.get('test'), 'value2')

        self.store.set('test', 'value3', 2)
        self.assertEqual(self.store.get('test'), 'value2')

        self.store.set('test', 'value4', 4)
        self.assertEqual(self.store.get('test'), 'value4')

        self.store.delete('test')
        self.assertEqual(self.store.get('test'), None)

    def testHash(self):
        for i in range(200):
            self.store.set('/test/test%d.jpg' % i, 'value%d' % i)
        s = self.store.get('@')
        n = sum(int(l.split(' ')[2]) for l in s.split('\n') if l)
        self.assertEqual(n, 200)
        s = self.store.get('@0')
        n = sum(1 for l in s.split('\n') if l)
        if n == 16:
            n = sum(int(l.split(' ')[2]) for l in s.split('\n') if l)
        self.assertEqual(n, 10)

    def testScan(self):
        self.testHash()
        self.store.close()

        os.unlink(self.store.path + '/.0.index')
        t = HStore(self.store.path, self.store.height)
        t.check()
        try:
            s = t.get('@')
            n = sum(int(l.split(' ')[2]) for l in s.split('\n') if l)
            self.assertEqual(n, 200)
            s = t.get('@0')
            n = sum(1 for l in s.split('\n') if l)
            if n == 16:
                n = sum(int(l.split(' ')[2]) for l in s.split('\n') if l)
            self.assertEqual(n, 10)
        finally:
            t.close()

    def testRange(self):
        self.store.close()
        t = HStore(self.store.path, 1, 0, 8)
        for i in range(200):
            t.set('/test/test%d.jpg' % i, 'value%d' % i)
        s = t.get('@')
        n = sum(int(l.split(' ')[2]) for l in s.split('\n') if l)
        t.close()
        self.assertEqual(n, 110)