Coverage for pages.urlconf_registry

# Coverage for pages.urlconf_registry : 78%

## 27 statements 21 run 0 excluded 6 missing

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | __all__ = ('register_urlconf',) from django.utils.translation import ugettext as _ class UrlconfAlreadyRegistered(Exception): """ An attempt was made to register a widget for Django page CMS more than once. """ pass class UrlconfNotFound(Exception): """ The requested widget was not found """ pass registry = [] def get_choices(): choices = [('', 'No delegation')] for reg in registry: if reg[2]: label = reg[2] else: label = reg[0] choices.append((reg[0], label)) return choices def register_urlconf(name, urlconf, label=None): for urlconf_tuple in registry: if urlconf_tuple[0] == name: raise urlconfAlreadyRegistered( _('The urlconf %s has already been registered.') % name) urlconf_tuple = (name, urlconf, label, urlconf) registry.append(urlconf_tuple) def get_urlconf(name): for urlconf_tuple in registry: if urlconf_tuple[0] == name: return urlconf_tuple[1] raise urlconfNotFound( _('The urlconf %s has not been registered.') % name)