Skip to content

Commit 5a2a255

Browse files
committed
Added django urlconfig namespace support in ietf.utils.test.get_callbacks() (needed when testing the reverse lookups in templates for oidc_provider).
- Legacy-Id: 17917
1 parent cd186fa commit 5a2a255

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

ietf/utils/tests.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
from django.template.loader import get_template
3131
from django.templatetags.static import StaticNode
3232
from django.urls import reverse as urlreverse
33-
from django.utils.encoding import force_text
3433

3534
import debug # pyflakes:ignore
3635

@@ -154,19 +153,23 @@ def send_complex_mail(to):
154153
self.assertEqual(len(outbox),len_before+2)
155154

156155

157-
def get_callbacks(urllist):
156+
def get_callbacks(urllist, namespace=None):
158157
callbacks = set()
158+
def qualified(name):
159+
return '%s:%s' % (namespace, name) if namespace else name
159160
for entry in urllist:
160161
if hasattr(entry, 'url_patterns'):
161-
callbacks.update(get_callbacks(entry.url_patterns))
162+
callbacks.update(get_callbacks(entry.url_patterns, entry.namespace))
162163
else:
163164
if hasattr(entry, '_callback_str'):
164-
callbacks.add(force_text(entry._callback_str))
165-
if (hasattr(entry, 'callback') and entry.callback
166-
and type(entry.callback) in [types.FunctionType, types.MethodType ]):
167-
callbacks.add("%s.%s" % (entry.callback.__module__, entry.callback.__name__))
165+
callbacks.add(qualified(entry._callback_str))
166+
if (hasattr(entry, 'callback') and entry.callback and
167+
type(entry.callback) in [types.FunctionType, types.MethodType ]):
168+
callbacks.add(qualified("%s.%s" % (entry.callback.__module__, entry.callback.__name__)))
168169
if hasattr(entry, 'name') and entry.name:
169-
callbacks.add(force_text(entry.name))
170+
callbacks.add(qualified(entry.name))
171+
if hasattr(entry, 'lookup_str') and entry.lookup_str:
172+
callbacks.add(qualified(entry.lookup_str))
170173
# There are some entries we don't handle here, mostly clases
171174
# (such as Feed subclasses)
172175

0 commit comments

Comments
 (0)