Example #1
0
 def _enqueueUsersTest(self, assertMethod):
     redisMock = Mock()
     redisMock.sadd = Mock(side_effect=lambda k, v:0 if v == 'test_user2' else 1)
     userBuff = []
     redisMock.rpush = Mock()
     
     param1 = []
     for i in range(0, 3):
         user = UserModel()
         user.name = 'test_user%s' % i
         param1.append(user)
     target = RedisContext(RedisModuleMock(redisMock))
     target.enqueueUsers(param1)
     
     assertMethod(redisMock)
Example #2
0
    def _enqueueUsersTest(self, assertMethod):
        redisMock = Mock()
        redisMock.sadd = Mock(
            side_effect=lambda k, v: 0 if v == 'test_user2' else 1)
        userBuff = []
        redisMock.rpush = Mock()

        param1 = []
        for i in range(0, 3):
            user = UserModel()
            user.name = 'test_user%s' % i
            param1.append(user)
        target = RedisContext(RedisModuleMock(redisMock))
        target.enqueueUsers(param1)

        assertMethod(redisMock)
Example #3
0
 def test_existsUserReturnCorrectResult(self):
     redisMock = Mock()
     redisMock.sismember = Mock(side_effect=lambda k, v:True if v == 'test_user' else False)
     target = RedisContext(RedisModuleMock(redisMock))
     self.assertTrue(target.existsUser('test_user'))
Example #4
0
 def _dequeueUserInitialize(self):
     redisMock = Mock()
     redisMock.lpop = Mock(return_value='test_user')
     target = RedisContext(RedisModuleMock(redisMock))
     return target.dequeueUser()
Example #5
0
 def test_existsUserReturnCorrectResult(self):
     redisMock = Mock()
     redisMock.sismember = Mock(
         side_effect=lambda k, v: True if v == 'test_user' else False)
     target = RedisContext(RedisModuleMock(redisMock))
     self.assertTrue(target.existsUser('test_user'))
Example #6
0
 def _dequeueUserInitialize(self):
     redisMock = Mock()
     redisMock.lpop = Mock(return_value='test_user')
     target = RedisContext(RedisModuleMock(redisMock))
     return target.dequeueUser()