def test_format_api_patterns_url_import_with_routers(self):
class MockApiViewSet(ModelViewSet):
serializer_class = CommentSerializer
model = User
queryset = User.objects.all()
class AnotherMockApiViewSet(ModelViewSet):
serializer_class = CommentSerializer
model = User
queryset = User.objects.all()
router = DefaultRouter()
router.register(r'other_views', MockApiViewSet, base_name='test_base_name')
router.register(r'more_views', AnotherMockApiViewSet, base_name='test_base_name')
urls_app = patterns('', url(r'^', include(router.urls)))
urls = patterns(
'',
url(r'api/', include(urls_app)),
url(r'test/', include(urls_app))
)
apis = self.urlparser.get_apis(urls)
self.assertEqual(
4, sum(api['path'].find('api') != -1 for api in apis))
self.assertEqual(
4, sum(api['path'].find('test') != -1 for api in apis))
评论列表
文章目录