# Auto generated by Kolo at {{ now }}.
# Kolo version: {{ kolo_version }}
{% if django_version %}# Django version: {{ django_version }}{% endif %}
# Trace ID: {{ trace_id }}
{% if sql_fixtures or asserts or request %}
import freezegun
import httpretty
import json

from django.test import TestCase
from django.utils.http import urlencode

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

{% if request_timestamp %}
@freezegun.freeze_time("{{ request_timestamp }}", tick=True){% endif %}
class {{ test_class }}(TestCase):
    @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 request %}
        response = self.client.{{ request.method.lower() }}(
            "{{ request.path_info }}",
            {{ query_params }}
            {{ prettified_request_body }},
            {% for header, value in request_headers.items() %}
            {{ header }}={{ value.__repr__() }},
            {% endfor %}
        )

        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 %}
