# Path: rest_framework_extensions/routers.py
# class ExtendedSimpleRouter(ExtendedRouterMixin, SimpleRouter):
#     pass
# 
# Path: rest_framework_extensions/utils.py
# def compose_parent_pk_kwarg_name(value):
#     return '{0}{1}'.format(
#         extensions_api_settings.DEFAULT_PARENT_LOOKUP_KWARG_NAME_PREFIX,
#         value
#     )
# 
# Path: tests_app/tests/unit/routers/nested_router_mixin/views.py
# class UserViewSet(ModelViewSet):
#     model = UserModel
# 
# class GroupViewSet(ModelViewSet):
#     model = GroupModel
# 
# class PermissionViewSet(ModelViewSet):
#     model = PermissionModel
# 
# class CustomRegexUserViewSet(ModelViewSet):
#     lookup_value_regex = 'a'
#     model = UserModel
# 
# class CustomRegexGroupViewSet(ModelViewSet):
#     lookup_value_regex = 'b'
#     model = GroupModel
# 
# class CustomRegexPermissionViewSet(ModelViewSet):
#     lookup_value_regex = 'c'
#     model = PermissionModel


from rest_framework.test import APITestCase
from rest_framework_extensions.routers import ExtendedSimpleRouter
from rest_framework_extensions.utils import compose_parent_pk_kwarg_name
from .views import (
    UserViewSet,
    GroupViewSet,
    PermissionViewSet,
    CustomRegexUserViewSet,
    CustomRegexGroupViewSet,
    CustomRegexPermissionViewSet,
)

        # test users groups permission detail
        self.assertEqual(router.urls[5].name, 'users-groups-permission-detail')
        self.assertEqual(get_regex_pattern(router.urls[5]), r'^users/{0}/groups/{1}/permissions/{2}/$'.format(
                self.get_parent_lookup_regex('group__user'),
                self.get_parent_lookup_regex('group'),
                self.get_lookup_regex('pk')
            ),
        )

    def test_nested_route_depth_3_custom_regex(self):
        """
        Nested routes with over two level of depth should respect all parents'
        `lookup_value_regex` attribute.
        """
        router = ExtendedSimpleRouter()
        (
            router.register(r'users', CustomRegexUserViewSet, 'user')
                  .register(r'groups', CustomRegexGroupViewSet, 'users-group',
                            parents_query_lookups=['user'])
                  .register(r'permissions', CustomRegexPermissionViewSet,
                            'users-groups-permission', parents_query_lookups=[
                               'group__user',
                               'group',
                            ]
                  )
        )

        # custom regex configuration
        user_viewset_regex = CustomRegexUserViewSet.lookup_value_regex

# Path: rest_framework_extensions/routers.py
# class ExtendedSimpleRouter(ExtendedRouterMixin, SimpleRouter):
#     pass
# 
# Path: rest_framework_extensions/utils.py
# def compose_parent_pk_kwarg_name(value):
#     return '{0}{1}'.format(
#         extensions_api_settings.DEFAULT_PARENT_LOOKUP_KWARG_NAME_PREFIX,
#         value
#     )
# 
# Path: tests_app/tests/unit/routers/nested_router_mixin/views.py
# class UserViewSet(ModelViewSet):
#     model = UserModel
# 
# class GroupViewSet(ModelViewSet):
#     model = GroupModel
# 
# class PermissionViewSet(ModelViewSet):
#     model = PermissionModel
# 
# class CustomRegexUserViewSet(ModelViewSet):
#     lookup_value_regex = 'a'
#     model = UserModel
# 
# class CustomRegexGroupViewSet(ModelViewSet):
#     lookup_value_regex = 'b'
#     model = GroupModel
# 
# class CustomRegexPermissionViewSet(ModelViewSet):
#     lookup_value_regex = 'c'
#     model = PermissionModel


# Path: tests_app/tests/unit/routers/nested_router_mixin/tests.py
from rest_framework.test import APITestCase
from rest_framework_extensions.routers import ExtendedSimpleRouter
from rest_framework_extensions.utils import compose_parent_pk_kwarg_name
from .views import (
    UserViewSet,
    GroupViewSet,
    PermissionViewSet,
    CustomRegexUserViewSet,
    CustomRegexGroupViewSet,
    CustomRegexPermissionViewSet,
)


        # test users groups permission detail
        self.assertEqual(router.urls[5].name, 'users-groups-permission-detail')
        self.assertEqual(get_regex_pattern(router.urls[5]), r'^users/{0}/groups/{1}/permissions/{2}/$'.format(
                self.get_parent_lookup_regex('group__user'),
                self.get_parent_lookup_regex('group'),
                self.get_lookup_regex('pk')
            ),
        )

    def test_nested_route_depth_3_custom_regex(self):
        """
        Nested routes with over two level of depth should respect all parents'
        `lookup_value_regex` attribute.
        """
        router = ExtendedSimpleRouter()
        (
            router.register(r'users', CustomRegexUserViewSet, 'user')
                  .register(r'groups', CustomRegexGroupViewSet, 'users-group',
                            parents_query_lookups=['user'])
                  .register(r'permissions', CustomRegexPermissionViewSet,
                            'users-groups-permission', parents_query_lookups=[
                               'group__user',
                               'group',
                            ]
                  )
        )

        # custom regex configuration
        user_viewset_regex = CustomRegexUserViewSet.lookup_value_regex

        group_viewset_regex = CustomRegexGroupViewSet.lookup_value_regex