|
3 | 3 | from django.shortcuts import render
|
4 | 4 |
|
5 | 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'\bcsrfToken: "TOKEN"', result.content.decode()) |
| 10 | + |
| 11 | + |
6 | 12 | def test_base_template_with_no_context():
|
7 | 13 | # base.html should be renderable with no context,
|
8 | 14 | # so it can be easily extended.
|
9 | 15 | result = render({}, 'rest_framework/base.html')
|
10 | 16 | # note that this response will not include a valid CSRF token
|
11 | 17 | assert re.search(r'\bcsrfToken: ""', result.content.decode())
|
12 |
| - |
13 |
| - |
14 |
| -def test_base_template_with_simple_context(): |
15 |
| - context = {'request': True, 'csrf_token': 'TOKEN'} |
16 |
| - result = render({}, 'rest_framework/base.html', context=context) |
17 |
| - # note that response will STILL not include a CSRF token |
18 |
| - assert re.search(r'\bcsrfToken: ""', result.content.decode()) |
19 |
| - |
20 |
| - |
21 |
| -def test_base_template_with_editing_context(): |
22 |
| - context = {'request': True, 'post_form': object(), 'csrf_token': 'TOKEN'} |
23 |
| - result = render({}, 'rest_framework/base.html', context=context) |
24 |
| - # response includes a CSRF token in support of the POST form |
25 |
| - assert re.search(r'\bcsrfToken: "TOKEN"', result.content.decode()) |
0 commit comments