# Auto generated by Kolo at {{ now }}.
# Kolo version: {{ kolo_version }}
{% if django_version %}# Django version: {{ django_version }}{% endif %}
# Trace ID: {{ trace_id }}

import datetime
{% if sql_fixtures or asserts or test_client_call_pytest %}
{{ time_travel_import }}
import httpretty
import json

import pytest
from django.utils.http import urlencode
from pytest_django.asserts import assertTemplateUsed

{% for import in imports %}{{ import }}
{% endfor %}

{% if request_timestamp %}
@{{ time_travel_call }}("{{ request_timestamp }}"{{ time_travel_tick }}){% endif %}
@httpretty.activate(allow_net_connect=False)
@pytest.mark.django_db()
def {{ test_name }}(client):
    {% for fixture in sql_fixtures %}
    {%- for line in fixture.template_parts %}
    {{ line }}
    {%- endfor %}
    {% endfor %}
    {% for outbound_request in outbound_request_frames %}httpretty.register_uri(
        httpretty.{{outbound_request.request.method}},
        "{{outbound_request.request.url}}",
        status={{outbound_request.response.status_code}}{% if outbound_request.response.json_body %},
        body=json.dumps({{ outbound_request.response.json_body }}),
        content_type='application/json'{% endif %}
    )
    {% endfor %}
    {% if test_client_call_pytest %}
    response = {{ test_client_call_pytest }}

    assert response.status_code == {{ response.status_code }}

    {%- for name in template_names %}
    assertTemplateUsed(response, {{ name.__repr__() }})
    {%- endfor %}
    {% endif %}

    {% for fixture in asserts %}
    {%- for line in fixture.pytest_template_parts %}
    {{ line }}
    {%- endfor %}
    {% endfor %}
{% endif %}
