Added (currently inactive) code to trigger exceptions on failure to resolve template variables during tests, and added fixes for a couple of places that triggered such exceptions.

- Legacy-Id: 17226
This commit is contained in:
Henrik Levkowetz 2020-01-13 17:16:43 +00:00
parent 87eb0fb640
commit 288f4135e3
4 changed files with 31 additions and 7 deletions

View file

@ -919,6 +919,12 @@ class DocHistory(DocumentInfo):
def related_ipr(self):
return self.doc.related_ipr()
def documenturl_set(self):
return self.doc.documenturl_set
def filename_with_rev(self):
return self.doc.filename_with_rev()
class Meta:
verbose_name = "document history"
verbose_name_plural = "document histories"

View file

@ -148,10 +148,12 @@
{% endif %}
Report a bug:
<a href="https://tools.ietf.org/tools/ietfdb/newticket">Tracker:<span class="fa fa-bug"></span></a>
{% if bugreport_email %}
<a href="mailto:{{ bugreport_email }}">Email:<span class="fa fa-envelope"></span></a>
{% endif %}
<br>
Python {{ python_version }} |
Django {{ django_version }}
{% if python_version %}Python {{ python_version }}{% endif %} |
{% if django_version %}Django {{ django_version }}{% endif %}
</p>
</div>
</div>

View file

@ -92,7 +92,11 @@
{% endif %}
</td>
<td>
<span title="{{ doc.get_state.desc }}">{{ doc.get_state.name }}</span>
{% if doc.get_state %}
<span title="{{ doc.get_state.desc }}">{{ doc.get_state.name }}</span>
{% else %}
No document state
{% endif %}
{% if chartering == "initial" %}
<span class="label label-info">Initial chartering</span>

View file

@ -1,4 +1,4 @@
# Copyright The IETF Trust 2009-2019, All Rights Reserved
# Copyright The IETF Trust 2009-2020, All Rights Reserved
# -*- coding: utf-8 -*-
#
# Portion Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
@ -489,6 +489,12 @@ class CoverageTest(unittest.TestCase):
' please see if they can be re-ordered with all data migrations before the schema migrations:\n'
+('\n'.join([' %-6s: %-12s, %s (%s)'% (op, node.key[0], node.key[1], nm) for (node, op, nm) in unreleased ])))
class InvalidString(str):
def __mod__(self, other):
from django.template.base import TemplateSyntaxError
raise TemplateSyntaxError(
"Undefined variable or unknown value for: \"%s\"" % other)
class IetfTestRunner(DiscoverRunner):
@classmethod
@ -587,9 +593,15 @@ class IetfTestRunner(DiscoverRunner):
print(" Changing SITE_ID to '1' during testing.")
settings.SITE_ID = 1
if settings.TEMPLATES[0]['OPTIONS']['string_if_invalid'] != '':
print(" Changing TEMPLATES[0]['OPTIONS']['string_if_invalid'] to '' during testing")
settings.TEMPLATES[0]['OPTIONS']['string_if_invalid'] = ''
if True:
if settings.TEMPLATES[0]['OPTIONS']['string_if_invalid'] != '':
print(" Changing TEMPLATES[0]['OPTIONS']['string_if_invalid'] to '' during testing")
settings.TEMPLATES[0]['OPTIONS']['string_if_invalid'] = ''
else:
# Alternative code to trigger test exceptions on failure to
# resolve variables in templates.
print(" Changing TEMPLATES[0]['OPTIONS']['string_if_invalid'] during testing")
settings.TEMPLATES[0]['OPTIONS']['string_if_invalid'] = InvalidString('%s')
if settings.INTERNAL_IPS:
print(" Changing INTERNAL_IPS to '[]' during testing.")