Esempio n. 1
0
def test_should_find_deeply_nested_error_object():
    payload = {
        "key": {
            "key": {
                "key": {
                    "Error": "An error",
                    "Cause": "Cause"
                }
            }
        }
    }
    errors = main.get_error_objects(payload)
    assert len(errors) == 1
Esempio n. 2
0
def test_should_return_correct_format():
    payload = {
        "key": {
            "key": {
                "key": {
                    "Error": "An error",
                    "Cause": "Cause"
                }
            }
        }
    }
    errors = main.get_error_objects(payload)
    assert len(errors) == 1
    assert (len(errors[0]) == 2 and "Error" in errors[0]
            and "Cause" in errors[0])
Esempio n. 3
0
def test_should_ignore_error_object_with_invalid_types():
    payload = {"Error": 1234}
    errors = main.get_error_objects(payload)
    assert len(errors) == 0
Esempio n. 4
0
def test_should_ignore_invalid_error_object():
    payload = {"Errors": ""}
    errors = main.get_error_objects(payload)
    assert len(errors) == 0
Esempio n. 5
0
def test_should_find_error_object_without_cause():
    payload = {"Error": "An error"}
    errors = main.get_error_objects(payload)
    assert len(errors) == 1
Esempio n. 6
0
def test_should_find_error_objects_in_nested_list():
    payload = {"key": [{"Error": "An error", "Cause": "Cause"}]}
    errors = main.get_error_objects(payload)
    assert len(errors) == 1
Esempio n. 7
0
def test_should_find_multiple_error_objects_in_list():
    payload = [{"Error": "An error", "Cause": "Cause"}, {"Error": "hello"}]
    errors = main.get_error_objects(payload)
    assert len(errors) == len(payload)