Exemple #1
0
def test_rest_exception_error_code_and_no_message():
    exc = RestException(
        {"error_code": ErrorCode.Name(RESOURCE_DOES_NOT_EXIST), "messages": "something important."}
    )
    assert "something important." in str(exc)
    assert "RESOURCE_DOES_NOT_EXIST" in str(exc)
    json.loads(exc.serialize_as_json())
Exemple #2
0
def test_rest_exception_error_code_is_not_none():
    error_string = "something important."
    exc = RestException({"message": error_string})
    assert "None" not in error_string
    assert "None" not in str(exc)
    json.loads(exc.serialize_as_json())
Exemple #3
0
def test_rest_exception_without_message():
    exc = RestException({"my_property": "something important."})
    assert "something important." in str(exc)
    json.loads(exc.serialize_as_json())
Exemple #4
0
def test_rest_exception_error_code_and_no_message():
    exc = RestException({"error_code": 2, "messages": "something important."})
    assert "something important." in str(exc)
    assert "2" in str(exc)
    json.loads(exc.serialize_as_json())