| 1 |
import re |
| 2 |
|
| 3 |
from django.shortcuts import render |
| 4 |
|
| 5 |
|
| 6 |
def test_base_template_with_context(): |
| 7 |
context = {'request': True, 'csrf_token': 'TOKEN'} |
| 8 |
result = render({}, 'rest_framework/base.html', context=context) |
| 9 |
assert re.search(r'"csrfToken": "TOKEN"', result.content.decode()) |
| 10 |
|
| 11 |
|
| 12 |
def test_base_template_with_no_context(): |
| 13 |
# base.html should be renderable with no context, |
| 14 |
# so it can be easily extended. |
| 15 |
result = render({}, 'rest_framework/base.html') |
| 16 |
# note that this response will not include a valid CSRF token |
| 17 |
assert re.search(r'"csrfToken": ""', result.content.decode()) |