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)
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)
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'))
def _dequeueUserInitialize(self): redisMock = Mock() redisMock.lpop = Mock(return_value='test_user') target = RedisContext(RedisModuleMock(redisMock)) return target.dequeueUser()
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'))