tests: don't run multiple render() on the same context
This commit is contained in:
parent
86e2b10aa4
commit
c5d8ae8c74
|
@ -10,6 +10,7 @@ import urlparse
|
|||
import os
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.cache import cache
|
||||
from django.test.client import RequestFactory
|
||||
from django.template import Context
|
||||
|
||||
|
@ -284,6 +285,7 @@ def test_current_forms_cell_render(context):
|
|||
context['request'].user = MockUser()
|
||||
|
||||
# query should fail as nothing is cached
|
||||
cache.clear()
|
||||
with pytest.raises(NothingInCacheException):
|
||||
result = cell.render(context)
|
||||
|
||||
|
@ -296,9 +298,27 @@ def test_current_forms_cell_render(context):
|
|||
assert 'http://127.0.0.2:8999/form-title/1/' in result
|
||||
assert 'http://127.0.0.2:8999/form-title/22/' in result
|
||||
|
||||
# check specificy a single wcs site
|
||||
@wcsctl_present
|
||||
def test_current_forms_cell_render_single_site(context):
|
||||
page = Page(title='xxx', slug='test_current_forms_cell_render', template_name='standard')
|
||||
page.save()
|
||||
cell = WcsCurrentFormsCell(page=page, placeholder='content', order=0)
|
||||
cell.wcs_site = 'default'
|
||||
cell.save()
|
||||
|
||||
class MockUser(object):
|
||||
email = 'foo@example.net'
|
||||
def is_authenticated(self):
|
||||
return True
|
||||
context['request'].user = MockUser()
|
||||
|
||||
# query should fail as nothing is cached
|
||||
cache.clear()
|
||||
with pytest.raises(NothingInCacheException):
|
||||
result = cell.render(context)
|
||||
|
||||
context['synchronous'] = True # to get fresh content
|
||||
|
||||
result = cell.render(context)
|
||||
assert 'http://127.0.0.1:8999/form-title/1/' in result
|
||||
assert 'http://127.0.0.1:8999/form-title/22/' in result
|
||||
|
@ -359,7 +379,7 @@ def test_forms_of_category_cell_render(context):
|
|||
assert 'form title' in result and 'a second form title' in result
|
||||
|
||||
@wcsctl_present
|
||||
def test_current_drafts_cell_render(context):
|
||||
def test_current_drafts_cell_render_unlogged(context):
|
||||
page = Page(title='xxx', slug='test_current_drafts_cell_render', template_name='standard')
|
||||
page.save()
|
||||
cell = WcsCurrentDraftsCell(page=page, placeholder='content', order=0)
|
||||
|
@ -367,6 +387,15 @@ def test_current_drafts_cell_render(context):
|
|||
context['synchronous'] = True # to get fresh content
|
||||
result = cell.render(context)
|
||||
assert not 'http://127.0.0.1:8999/third-form-title' in result # no form
|
||||
|
||||
@wcsctl_present
|
||||
def test_current_drafts_cell_render_logged_in(context):
|
||||
page = Page(title='xxx', slug='test_current_drafts_cell_render', template_name='standard')
|
||||
page.save()
|
||||
cell = WcsCurrentDraftsCell(page=page, placeholder='content', order=0)
|
||||
cell.save()
|
||||
context['synchronous'] = True # to get fresh content
|
||||
|
||||
class MockUser(object):
|
||||
email = 'foo@example.net'
|
||||
def is_authenticated(self):
|
||||
|
|
Loading…
Reference in New Issue