Python django.core.urlresolvers.RegexURLPattern() Examples

The following are 4 code examples of django.core.urlresolvers.RegexURLPattern(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module django.core.urlresolvers , or try the search function .
Example #1
Source File: test_route.py    From baobab with GNU General Public License v3.0 6 votes vote down vote up
def test_01_nb_of_route(self):
        urls = ApiUrls.get_urls()
        # check the nb of defined ressources should be the same as the
        # number of route + 1 done by tastypie
        self.assertEqual(len(urls), self.nb_route + 1)
        self.assertTrue(isinstance(urls.pop(0), RegexURLPattern))

        event_url = urls.pop(0)
        self.assertTrue(isinstance(event_url, RegexURLResolver))
        # XXX depend on the version of tastypie: only use one or both method:
        #     prepend_urls/override_urls
        self.assertIn(len(event_url.url_patterns),
                      [self.nb_route_for_event, self.nb_route_for_event + 2])

        for url in urls:
            self.assertTrue(isinstance(url, RegexURLResolver))
            self.assertEqual(len(url.url_patterns),
                             self.nb_default_route_by_ressource) 
Example #2
Source File: api_docs.py    From django-rest-framework-docs with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def get_all_view_names(self, urlpatterns, parent_regex=''):
        for pattern in urlpatterns:
            if isinstance(pattern, RegexURLResolver):
                regex = '' if pattern._regex == "^" else pattern._regex
                self.get_all_view_names(urlpatterns=pattern.url_patterns, parent_regex=parent_regex + regex)
            elif isinstance(pattern, RegexURLPattern) and self._is_drf_view(pattern) and not self._is_format_endpoint(pattern):
                api_endpoint = ApiEndpoint(pattern, parent_regex, self.drf_router)
                self.endpoints.append(api_endpoint) 
Example #3
Source File: tests.py    From Poco with Apache License 2.0 5 votes vote down vote up
def test_urls(self):
        self.assertTrue(isinstance(api.urls, list))
        for api_url in api.urls:
            self.assertTrue(isinstance(api_url, RegexURLPattern)) 
Example #4
Source File: django-import-finder.py    From ConTroll_Remote_Access_Trojan with Apache License 2.0 5 votes vote down vote up
def find_url_callbacks(urls_module):
    urlpatterns = urls_module.urlpatterns
    hid_list = [urls_module.__name__]
    for pattern in urlpatterns:
        if isinstance(pattern, RegexURLPattern):
            hid_list.append(pattern.callback.__module__)
        elif isinstance(pattern, RegexURLResolver):
            hid_list += find_url_callbacks(pattern.urlconf_module)
    return hid_list