import json


def mocked_request_bad_response(*args, **kwargs):
    """
    Mocks a bad response from a request.
    """
    class MockResponse:
        def __init__(self, json_data, status_code):
            self.json_data = json_data
            self.status_code = status_code

            if json_data:
                self.content = json.dumps(json_data).encode()
            else:
                self.content = b''

        def json(self):
            return self.json_data

        @property
        def ok(self):
            if self.status_code < 400:
                return True
            return False

    return MockResponse(None, 401)