コード例 #1
0
    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
コード例 #2
0
    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
コード例 #3
0
            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
コード例 #4
0
    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
コード例 #5
0
    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
コード例 #6
0
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",
    }
コード例 #7
0
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",
    }
コード例 #8
0
            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
コード例 #9
0
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",
    }
コード例 #10
0
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",
    }