File: test_timers_errors.py

package info (click to toggle)
python-globus-sdk 4.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,172 kB
  • sloc: python: 35,227; sh: 44; makefile: 35
file content (43 lines) | stat: -rw-r--r-- 1,230 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from globus_sdk import TimersAPIError
from globus_sdk.testing import construct_error


def test_timer_error_load_simple():
    err = construct_error(
        error_class=TimersAPIError,
        body={"error": {"code": "ERROR", "detail": "Request failed", "status": 500}},
        http_status=500,
    )

    assert err.code == "ERROR"
    assert err.message == "Request failed"


def test_timer_error_load_nested():
    err = construct_error(
        error_class=TimersAPIError,
        body={
            "detail": [
                {
                    "loc": ["body", "start"],
                    "msg": "field required",
                    "type": "value_error.missing",
                },
                {
                    "loc": ["body", "end"],
                    "msg": "field required",
                    "type": "value_error.missing",
                },
            ]
        },
        http_status=422,
    )

    assert err.code is None
    assert err.message == "field required: body.start; field required: body.end"


def test_timer_error_load_unrecognized_format():
    err = construct_error(error_class=TimersAPIError, body={}, http_status=400)
    assert err.code is None
    assert err.message is None