def moved_redirect_effect(connection, command_name, **options): def ok_response(connection, command_name, **options): assert connection.host == "127.0.0.1" assert connection.port == 7002 return "MOCK_OK" m.side_effect = ok_response resp = ResponseError() resp.message = "MOVED 12182 127.0.0.1:7002" raise resp
def ask_redirect_effect(connection, command_name, **options): def ok_response(connection, command_name, **options): assert connection.host == "127.0.0.1" assert connection.port == 7001 return "MOCK_OK" m.side_effect = ok_response resp = ResponseError() resp.message = "ASK 1337 127.0.0.1:7001" raise resp
def side_effect(self, *args, **kwargs): def ok_call(self, *args, **kwargs): assert self.port == 7007 return "OK" parse_response_mock.side_effect = ok_call resp = ResponseError() resp.args = ('CLUSTERDOWN The cluster is down. Use CLUSTER INFO for more information',) resp.message = 'CLUSTERDOWN The cluster is down. Use CLUSTER INFO for more information' raise resp
def moved_redirect_effect(connection, command_name, **options): def ok_response(connection, command_name, **options): assert connection.host == "127.0.0.1" assert connection.port == 7002 return "MOCK_OK" m.side_effect = ok_response resp = ResponseError() resp.message = "MOVED 12182 127.0.0.1:7002" raise resp
def ask_redirect_effect(connection, command_name, **options): def ok_response(connection, command_name, **options): assert connection.host == "127.0.0.1" assert connection.port == 7001 return "MOCK_OK" m.side_effect = ok_response resp = ResponseError() resp.message = "ASK 1337 127.0.0.1:7001" raise resp
def test_ask_exception_handling(r): """ Test that `handle_cluster_command_exception` deals with ASK error correctly. """ resp = ResponseError() resp.message = "ASK 1337 127.0.0.1:7000" assert r.handle_cluster_command_exception(resp) == { "name": "127.0.0.1:7000", "method": "ask", }
def test_ask_exception_handling(r): """ Test that `handle_cluster_command_exception` deals with ASK error correctly. """ resp = ResponseError() resp.message = "ASK 1337 127.0.0.1:7000" assert r.handle_cluster_command_exception(resp) == { "name": "127.0.0.1:7000", "method": "ask", }
def side_effect(self, *args, **kwargs): def ok_call(self, *args, **kwargs): assert self.port == 7007 return "OK" parse_response_mock.side_effect = ok_call resp = ResponseError() resp.args = ( 'CLUSTERDOWN The cluster is down. Use CLUSTER INFO for more information', ) resp.message = 'CLUSTERDOWN The cluster is down. Use CLUSTER INFO for more information' raise resp
def test_moved_exception_handling(r): """ Test that `handle_cluster_command_exception` deals with MOVED error correctly. """ resp = ResponseError() resp.message = "MOVED 1337 127.0.0.1:7000" r.handle_cluster_command_exception(resp) assert r.refresh_table_asap is True assert r.connection_pool.nodes.slots[1337] == { "host": "127.0.0.1", "port": 7000, "name": "127.0.0.1:7000", "server_type": "master", }
def test_moved_exception_handling(r): """ Test that `handle_cluster_command_exception` deals with MOVED error correctly. """ resp = ResponseError() resp.message = "MOVED 1337 127.0.0.1:7000" r.handle_cluster_command_exception(resp) assert r.refresh_table_asap is True assert r.connection_pool.nodes.slots[1337] == { "host": "127.0.0.1", "port": 7000, "name": "127.0.0.1:7000", "server_type": "master", }