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)
else: if _serve_gzip(request): resp = serve(request, path + '.gz', document_root, show_indexes) resp['Content-Encoding'] = 'gzip' else: resp = serve(request, path, document_root, show_indexes) resp['Cache-Control'] = 'public, max-age=%d' % (3600 * 24 * 365) resp['Vary'] = 'Accept-Encoding' return resp # back-end URL urlpatterns = patterns( '', url(r'^admin/', include(admin.site.urls)), url(r'^admin', include(admin.site.urls)), url(r'', include(ApiRestApiUrls.get_urls())), ) # static content URL urlpatterns += patterns( '', url(r'^static/(?P<path>.*)$', baobab_serve, {'document_root': settings.MEDIA_ROOT}), url(r'^(favicon.ico)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), ) # RSS site URL urlpatterns += patterns( '',