test_validate_response   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 49
dl 0
loc 80
rs 10
c 0
b 0
f 0
wmc 3

1 Function

Rating   Name   Duplication   Size   Complexity  
A test_validate_response() 0 7 3
1
from yfrake.client.validators import validate_response
2
from yfrake.client.exceptions import BadRequestError
3
import pytest
4
5
6
tests = [
7
    (
8
        {
9
            "endpoint": {
10
                "result": [
11
                    {"key": "value"}
12
                ],
13
                "error": False
14
            }
15
        },
16
        True
17
    ), (
18
        {
19
            "key": "value",
20
            "news": [
21
                {"key": "value"}
22
            ]
23
        },
24
        True
25
    ), (
26
        {
27
            "endpoint": {
28
                "result": [
29
                    {}
30
                ],
31
                "error": False
32
            }
33
        },
34
        False
35
    ), (
36
        {
37
            "endpoint": {
38
                "result": [],
39
                "error": False
40
            }
41
        },
42
        False
43
    ), (
44
        {
45
            "endpoint": {
46
                "result": [
47
                    {"key": "value"}
48
                ],
49
                "error": True
50
            }
51
        },
52
        False
53
    ), (
54
        {
55
            "endpoint": {
56
                "result": [{}],
57
                "error": True
58
            }
59
        },
60
        False
61
    ), (
62
        {
63
            "endpoint": {
64
                "result": [],
65
                "error": True
66
            }
67
        },
68
        False
69
    )
70
]
71
72
73
@pytest.mark.parametrize('arg,result', tests)
74
async def test_validate_response(arg, result):
75
    if result is False:
76
        with pytest.raises(BadRequestError):
77
            await validate_response(arg)
78
    else:
79
        await validate_response(arg)
80