Code Duplication    Length = 16-18 lines in 2 locations

tests/unit/test_core/test_rest_api_routes.py 2 locations

@@ 64-81 (lines=18) @@
61
    assert KytosConfig().options["daemon"].api_traceback_on_500
62
63
64
async def test_get_json_or_400(controller, api_client) -> None:
65
    """Test get_json_or_400."""
66
67
    controller.loop = asyncio.get_running_loop()
68
69
    def handler(request: Request) -> JSONResponse:
70
        body = get_json_or_400(request, controller.loop)
71
        return JSONResponse(body)
72
73
    endpoint = "prefix/resource"
74
    controller.api_server.register_core_endpoint(endpoint, handler,
75
                                                 methods=["POST"])
76
    response = await api_client.post(f"kytos/core/{endpoint}")
77
    assert response.status_code == 400
78
    body = {"some_key": "some_value"}
79
    response = await api_client.post(f"kytos/core/{endpoint}", json=body)
80
    assert response.status_code == 200
81
    assert response.json() == body
82
83
84
async def test_error_msg():
@@ 41-56 (lines=16) @@
38
    assert response.json() == "response"
39
40
41
async def test_aget_json_or_400(controller, api_client) -> None:
42
    """Test aget_json_or_400."""
43
44
    async def handler(request: Request) -> JSONResponse:
45
        body = await aget_json_or_400(request)
46
        return JSONResponse(body)
47
48
    endpoint = "prefix/resource"
49
    controller.api_server.register_core_endpoint(endpoint, handler,
50
                                                 methods=["POST"])
51
    response = await api_client.post(f"kytos/core/{endpoint}")
52
    assert response.status_code == 400
53
    body = {"some_key": "some_value"}
54
    response = await api_client.post(f"kytos/core/{endpoint}", json=body)
55
    assert response.status_code == 200
56
    assert response.json() == body
57
58
59
def test_api_500_traceback_by_default() -> None: