예제 #1
0
 def setUp(self):
     self.memory = Memory()
예제 #2
0
 def setUp(self):
     self.memory = Memory()
예제 #3
0
class MemoryBackendTestCase(unittest.TestCase):
    def setUp(self):
        self.memory = Memory()

    def init_test(self):
        self.assertIsInstance(self.memory, mimicdb.backends.Backend)

    def keys_test(self):
        self.memory.sadd('mimicdb-tests', 'test-keys')

        assert 'mimicdb-tests' in self.memory.keys('mimicdb*')

    def delete_test(self):
        self.memory.sadd('mimicdb-tests', 'test-delete')
        self.memory.delete('mimicdb-tests')

        assert 'mimicdb-tests' not in self.memory.keys('mimicdb*')

    def sadd_test(self):
        self.memory.sadd('mimicdb-tests', 'test-keys')
        self.memory.sadd('mimicdb-tests', 'test-keys-2')

        assert 'test-keys' in self.memory.smembers('mimicdb-tests')
        assert 'test-keys-2' in self.memory.smembers('mimicdb-tests')

    def srem_test(self):
        self.memory.sadd('mimicdb-tests', 'test-keys')
        self.memory.srem('mimicdb-tests', 'test-keys')

        assert 'test-keys' not in self.memory.smembers('mimicdb-tests')

    def sismember_test(self):
        self.memory.sadd('mimicdb-tests', 'test-keys')

        assert self.memory.sismember('mimicdb-tests', 'test-keys')

    def sisntmember_test(self):
        self.memory.sadd('mimicdb-tests', 'test-keys')

        assert self.memory.sismember('mimicdb', 'test-keys') == False

    def smembers_test(self):
        self.memory.sadd('mimicdb-tests', 'test-keys')

        assert 'test-keys' in self.memory.smembers('mimicdb-tests')

    def hmset_test(self):
        self.memory.hmset('mimicdb-tests', dict(size='3', md5='md5'))

        assert self.memory.hgetall('mimicdb-tests') == dict(size='3',
                                                            md5='md5')

    def hgetall_test(self):
        self.memory.hmset('mimicdb-tests', dict(size='3', md5='md5'))

        assert self.memory.hgetall('mimicdb-tests') == dict(size='3',
                                                            md5='md5')
예제 #4
0
class MemoryBackendTestCase(unittest.TestCase):
    def setUp(self):
        self.memory = Memory()

    def init_test(self):
        self.assertIsInstance(self.memory, mimicdb.backends.Backend)

    def keys_test(self):
        self.memory.sadd('mimicdb-tests', 'test-keys')

        assert 'mimicdb-tests' in self.memory.keys('mimicdb*')

    def delete_test(self):
        self.memory.sadd('mimicdb-tests', 'test-delete')
        self.memory.delete('mimicdb-tests')

        assert 'mimicdb-tests' not in self.memory.keys('mimicdb*')

    def sadd_test(self):
        self.memory.sadd('mimicdb-tests', 'test-keys')
        self.memory.sadd('mimicdb-tests', 'test-keys-2')

        assert 'test-keys' in self.memory.smembers('mimicdb-tests')
        assert 'test-keys-2' in self.memory.smembers('mimicdb-tests')

    def srem_test(self):
        self.memory.sadd('mimicdb-tests', 'test-keys')
        self.memory.srem('mimicdb-tests', 'test-keys')

        assert 'test-keys' not in self.memory.smembers('mimicdb-tests')

    def sismember_test(self):
        self.memory.sadd('mimicdb-tests', 'test-keys')

        assert self.memory.sismember('mimicdb-tests', 'test-keys')

    def sisntmember_test(self):
        self.memory.sadd('mimicdb-tests', 'test-keys')

        assert self.memory.sismember('mimicdb', 'test-keys') == False

    def smembers_test(self):
        self.memory.sadd('mimicdb-tests', 'test-keys')

        assert 'test-keys' in self.memory.smembers('mimicdb-tests')

    def hmset_test(self):
        self.memory.hmset('mimicdb-tests', dict(size='3', md5='md5'))
        
        assert self.memory.hgetall('mimicdb-tests') == dict(size='3', md5='md5')

    def hgetall_test(self):
        self.memory.hmset('mimicdb-tests', dict(size='3', md5='md5'))
        
        assert self.memory.hgetall('mimicdb-tests') == dict(size='3', md5='md5')