
{% for status_code, name in {"200": "success", "401": "unauthorized", "403": "access_denied", "404": "not_found"}.items() %}
def {{name}}(function):
    """Mock {{method.url_regex}}, respond with HTTP {{status_code}}"""
    import requests_mock
    from {{method._fake_response_factory().__module__}} import {{method._fake_response_factory().__name__}}
    def mock_response(*args, **kwargs):
        with requests_mock.Mocker(real_http=True) as mock:
            mock.register_uri(
                "{{method.method | upper}}",
                r"{{method.url_regex}}",
                status_code={{status_code}},
                json={% if status_code == "200" %}{{method._fake_response_factory().__name__}}({{method.response}}){% else %}None{%endif%}
            )
            return function(*args, **kwargs)
        return mock_response
    return decorator
{% endfor %}