def test_add_placeholder(self):
# create page
page = create_page("Add Placeholder", "nav_playground.html", "en",
position="last-child", published=True, in_navigation=True)
page.template = 'add_placeholder.html'
page.save()
page.publish('en')
url = page.get_absolute_url()
response = self.client.get(url)
self.assertEqual(200, response.status_code)
try:
path = os.path.join(settings.TEMPLATE_DIRS[0], 'add_placeholder.html')
except IndexError:
path = os.path.join(settings.TEMPLATES[0]['DIRS'][0], 'add_placeholder.html')
with open(path, 'r') as fobj:
old = fobj.read()
try:
new = old.replace(
'<!-- SECOND_PLACEHOLDER -->',
'{% placeholder second_placeholder %}'
)
with open(path, 'w') as fobj:
fobj.write(new)
response = self.client.get(url)
self.assertEqual(200, response.status_code)
finally:
with open(path, 'w') as fobj:
fobj.write(old)
评论列表
文章目录