def get_redis_link_wrapper(*args, **kwargs): link = StrictRedis(host="127.0.0.1", port=7000, decode_responses=True) orig_exec_method = link.execute_command async def patch_execute_command(*args, **kwargs): if args == ('CLUSTER SLOTS',): # Missing slot 5460 return { (0, 5459): [{'host': '127.0.0.1', 'port': 7000, 'node_id': str(uuid.uuid4()), 'server_type': 'master'}, {'host': '127.0.0.1', 'port': 7003, 'node_id': str(uuid.uuid4()), 'server_type': 'slave'}], (5461, 10922): [{'host': '127.0.0.1', 'port': 7001, 'node_id': str(uuid.uuid4()), 'server_type': 'master'}, {'host': '127.0.0.1', 'port': 7004, 'node_id': str(uuid.uuid4()), 'server_type': 'slave'}], (10923, 16383): [{'host': '127.0.0.1', 'port': 7002, 'node_id': str(uuid.uuid4()), 'server_type': 'master'}, {'host': '127.0.0.1', 'port': 7005, 'node_id': str(uuid.uuid4()), 'server_type': 'slave'}], } elif args == ('CONFIG GET', 'cluster-require-full-coverage'): return {'cluster-require-full-coverage': 'no'} else: return await orig_exec_method(*args, **kwargs) # Missing slot 5460 link.execute_command = patch_execute_command return link
def get_redis_link_wrapper(*args, **kwargs): link = StrictRedis(host="127.0.0.1", port=7000) orig_exec_method = link.execute_command async def patch_execute_command(*args, **kwargs): if args == ('CLUSTER SLOTS', ): # Missing slot 5460 return [ [0, 5459, [b'127.0.0.1', 7000], [b'127.0.0.1', 7003]], [5461, 10922, [b'127.0.0.1', 7001], [b'127.0.0.1', 7004]], [10923, 16383, [b'127.0.0.1', 7002], [b'127.0.0.1', 7005]], ] return await orig_exec_method(*args, **kwargs) # Missing slot 5460 link.execute_command = patch_execute_command return link
def get_redis_link_wrapper(*args, **kwargs): link = StrictRedis(host="127.0.0.1", port=7000, decode_responses=True) orig_exec_method = link.execute_command def patch_execute_command(*args, **kwargs): if args == ('cluster', 'slots'): # Missing slot 5460 return [ [0, 5459, [b'127.0.0.1', 7000], [b'127.0.0.1', 7003]], [5461, 10922, [b'127.0.0.1', 7001], [b'127.0.0.1', 7004]], [10923, 16383, [b'127.0.0.1', 7002], [b'127.0.0.1', 7005]], ] elif args == ('CONFIG GET', 'cluster-require-full-coverage'): return {'cluster-require-full-coverage': 'no'} else: return orig_exec_method(*args, **kwargs) # Missing slot 5460 link.execute_command = patch_execute_command return link