Skip to content

Commit 288f413

Browse files
committed
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
1 parent 87eb0fb commit 288f413

4 files changed

Lines changed: 31 additions & 7 deletions

File tree

ietf/doc/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,12 @@ def is_dochistory(self):
919919
def related_ipr(self):
920920
return self.doc.related_ipr()
921921

922+
def documenturl_set(self):
923+
return self.doc.documenturl_set
924+
925+
def filename_with_rev(self):
926+
return self.doc.filename_with_rev()
927+
922928
class Meta:
923929
verbose_name = "document history"
924930
verbose_name_plural = "document histories"

ietf/templates/base.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,12 @@
148148
{% endif %}
149149
Report a bug:
150150
<a href="https://tools.ietf.org/tools/ietfdb/newticket">Tracker:<span class="fa fa-bug"></span></a>
151+
{% if bugreport_email %}
151152
<a href="mailto:{{ bugreport_email }}">Email:<span class="fa fa-envelope"></span></a>
153+
{% endif %}
152154
<br>
153-
Python {{ python_version }} |
154-
Django {{ django_version }}
155+
{% if python_version %}Python {{ python_version }}{% endif %} |
156+
{% if django_version %}Django {{ django_version }}{% endif %}
155157
</p>
156158
</div>
157159
</div>

ietf/templates/doc/document_charter.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@
9292
{% endif %}
9393
</td>
9494
<td>
95-
<span title="{{ doc.get_state.desc }}">{{ doc.get_state.name }}</span>
95+
{% if doc.get_state %}
96+
<span title="{{ doc.get_state.desc }}">{{ doc.get_state.name }}</span>
97+
{% else %}
98+
No document state
99+
{% endif %}
96100

97101
{% if chartering == "initial" %}
98102
<span class="label label-info">Initial chartering</span>

ietf/utils/test_runner.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright The IETF Trust 2009-2019, All Rights Reserved
1+
# Copyright The IETF Trust 2009-2020, All Rights Reserved
22
# -*- coding: utf-8 -*-
33
#
44
# Portion Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
@@ -489,6 +489,12 @@ def interleaved_migrations_test(self):
489489
' please see if they can be re-ordered with all data migrations before the schema migrations:\n'
490490
+('\n'.join([' %-6s: %-12s, %s (%s)'% (op, node.key[0], node.key[1], nm) for (node, op, nm) in unreleased ])))
491491

492+
class InvalidString(str):
493+
def __mod__(self, other):
494+
from django.template.base import TemplateSyntaxError
495+
raise TemplateSyntaxError(
496+
"Undefined variable or unknown value for: \"%s\"" % other)
497+
492498
class IetfTestRunner(DiscoverRunner):
493499

494500
@classmethod
@@ -587,9 +593,15 @@ def setup_test_environment(self, **kwargs):
587593
print(" Changing SITE_ID to '1' during testing.")
588594
settings.SITE_ID = 1
589595

590-
if settings.TEMPLATES[0]['OPTIONS']['string_if_invalid'] != '':
591-
print(" Changing TEMPLATES[0]['OPTIONS']['string_if_invalid'] to '' during testing")
592-
settings.TEMPLATES[0]['OPTIONS']['string_if_invalid'] = ''
596+
if True:
597+
if settings.TEMPLATES[0]['OPTIONS']['string_if_invalid'] != '':
598+
print(" Changing TEMPLATES[0]['OPTIONS']['string_if_invalid'] to '' during testing")
599+
settings.TEMPLATES[0]['OPTIONS']['string_if_invalid'] = ''
600+
else:
601+
# Alternative code to trigger test exceptions on failure to
602+
# resolve variables in templates.
603+
print(" Changing TEMPLATES[0]['OPTIONS']['string_if_invalid'] during testing")
604+
settings.TEMPLATES[0]['OPTIONS']['string_if_invalid'] = InvalidString('%s')
593605

594606
if settings.INTERNAL_IPS:
595607
print(" Changing INTERNAL_IPS to '[]' during testing.")

0 commit comments

Comments
 (0)