# Path: via/views/status.py
# @view.view_config(route_name="get_status", renderer="json", http_cache=0)
# def get_status(request):
#     """Status endpoint."""
# 
#     body = {"status": "okay"}
# 
#     if "include-checkmate" in request.params:
#         try:
#             request.checkmate.check_url("https://example.com/")
#         except CheckmateException:
#             body["down"] = ["checkmate"]
#         else:
#             body["okay"] = ["checkmate"]
# 
#     # If any of the components checked above were down then report the
#     # status check as a whole as being down.
#     if body.get("down"):
#         request.response.status_int = 500
#         body["status"] = "down"
# 
#     return body


import pytest
from checkmatelib import CheckmateException
from via.views.status import get_status



class TestStatusRoute:
    @pytest.mark.parametrize(
        "include_checkmate,checkmate_fails,expected_status,expected_body",
        [
            (False, False, 200, {"status": "okay"}),
            (False, True, 200, {"status": "okay"}),
            (True, False, 200, {"status": "okay", "okay": ["checkmate"]}),
            (True, True, 500, {"status": "down", "down": ["checkmate"]}),
        ],
    )
    def test_status_returns_200_response(
        self,
        pyramid_request,
        include_checkmate,
        checkmate_fails,
        expected_status,

# Path: via/views/status.py
# @view.view_config(route_name="get_status", renderer="json", http_cache=0)
# def get_status(request):
#     """Status endpoint."""
# 
#     body = {"status": "okay"}
# 
#     if "include-checkmate" in request.params:
#         try:
#             request.checkmate.check_url("https://example.com/")
#         except CheckmateException:
#             body["down"] = ["checkmate"]
#         else:
#             body["okay"] = ["checkmate"]
# 
#     # If any of the components checked above were down then report the
#     # status check as a whole as being down.
#     if body.get("down"):
#         request.response.status_int = 500
#         body["status"] = "down"
# 
#     return body


# Path: tests/unit/via/views/status_test.py
import pytest
from checkmatelib import CheckmateException
from via.views.status import get_status




class TestStatusRoute:
    @pytest.mark.parametrize(
        "include_checkmate,checkmate_fails,expected_status,expected_body",
        [
            (False, False, 200, {"status": "okay"}),
            (False, True, 200, {"status": "okay"}),
            (True, False, 200, {"status": "okay", "okay": ["checkmate"]}),
            (True, True, 500, {"status": "down", "down": ["checkmate"]}),
        ],
    )
    def test_status_returns_200_response(
        self,
        pyramid_request,
        include_checkmate,
        checkmate_fails,
        expected_status,

        expected_body,