Exemplo n.º 1
0
def test_can_handle_json_error_from_post():
    new_node_resource = Resource("http://localhost:7474/db/data/node")
    try:
        new_node_resource.post(["foo"])
    except GraphError:
        assert True
    else:
        assert False
Exemplo n.º 2
0
def test_can_handle_other_error_from_post():
    with patch.object(_Resource, "post") as mocked:
        mocked.side_effect = DodgyServerError
        resource = Resource("http://localhost:7474/db/data/node/spam")
        try:
            resource.post()
        except GraphError as error:
            assert isinstance(error.__cause__, DodgyServerError)
        else:
            assert False
Exemplo n.º 3
0
def test_can_handle_other_error_from_post():
    with patch.object(_Resource, "post") as mocked:
        mocked.side_effect = DodgyServerError
        resource = Resource("http://localhost:7474/db/data/node/spam")
        try:
            resource.post()
        except GraphError as error:
            assert isinstance(error.__cause__, DodgyServerError)
        else:
            assert False
Exemplo n.º 4
0
def test_can_handle_400():
    resource = Resource("http://localhost:7474/db/data/cypher")
    try:
        resource.post()
    except GraphError as error:
        assert_error(
            error, (GraphError,), "org.neo4j.server.rest.repr.BadInputException",
            (_ClientError, _Response), 400)
    else:
        assert False
Exemplo n.º 5
0
def test_can_handle_json_error_from_post():
    new_node_resource = Resource("http://localhost:7474/db/data/node")
    try:
        new_node_resource.post(["foo"])
    except GraphError as error:
        cause = error.__cause__
        assert isinstance(cause, _ClientError)
        assert isinstance(cause, _Response)
        assert cause.status_code == 400
    else:
        assert False
Exemplo n.º 6
0
def test_can_handle_json_error_from_post():
    new_node_resource = Resource("http://localhost:7474/db/data/node")
    try:
        new_node_resource.post(["foo"])
    except GraphError as error:
        cause = error.__cause__
        assert isinstance(cause, _ClientError)
        assert isinstance(cause, _Response)
        assert cause.status_code == 400
    else:
        assert False