mport requests # oh noes


{% for request in requests -%}

###############################################################################
# request number: {{ loop.index }}

url = '{{ request.url.split('?')[0] }}'
{%- if request.headers %}
headers = {
    {%- for (key, value) in request.headers %}
    '{{ key }}': '{{ value }}',
    {%- endfor %}
}
{%- endif %}
{%- if request.cookies %}
cookies = {
    {%- for (key, value) in request.cookies %}
    '{{ key }}': '{{ value }}',
    {%- endfor %}
}
{%- endif %}
{%- if request.params %}
params = [
    {%- for (key, value) in request.params %}
    ('{{ key }}', '{{ value }}'),
    {%- endfor %}
]
{%- endif %}
rc = s.{{ request.method }}(url
{%- if request.headers -%}, headers=headers{%- endif -%}
{%- if request.cookies -%}, cookies=cookies{%- endif -%}
{%- if request.params -%}, params=params{%- endif -%})

{% set response = responses[loop.index0] %}
# response status code: {{ response.status }}
{%- if response.headers %}
# response headers:
{%- for (key, value) in response.headers %}
#   - {{ key }}: {{ value }}
{%- endfor -%}
{%- endif %}
{%- if response.cookies %}
# response cookies:
{%- for (key, value) in response.cookies %}
#   - {{ key }}: {{ value }}
{%- endfor -%}
{%- endif %}
###############################################################################

{% endfor %}
