# 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 %}
{{ time_travel_import }}
import httpretty
import json

{% if base_test_case == "TestCase" %}from django.test import TestCase{% endif %}
from django.utils.http import urlencode

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

{% if request_timestamp %}
@{{ time_travel_call }}("{{ request_timestamp }}"{{ time_travel_tick }}){% endif %}
class {{ test_class }}({{base_test_case}}):
    {% if custom_unittest_setup %}
    {# Jinja does weird stuff with multiline strings, so we need the filter to guarantee we get our desired indent #}
    {% filter indent(4, true) %}
{{ custom_unittest_setup }}
    {% endfilter %}
    {% endif %}
    @httpretty.activate(allow_net_connect=False)
    def {{ test_name }}(self):
        {% 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 %}
        response = {{ test_client_call }}

        self.assertEqual(response.status_code, {{ response.status_code }})

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

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