Ejemplo n.º 1
0
    def test_process_request(self):

        with modify_settings(
            MIDDLEWARE_CLASSES={'append': [
                'django.contrib.sites.middleware.CurrentSiteMiddleware',
                'hacs.middleware.DynamicRouteMiddleware',
                'hacs.middleware.FirewallMiddleware'
            ]}
        ):
            browser = Client()
            response = browser.get('/admin/')
            # AS anonymous user so urlconf module should default site
            expected_module = get_generated_urlconf_module(get_generated_urlconf_file(TEST_ROUTE_NAME))
            self.assertEqual(expected_module, response.wsgi_request.urlconf)
            # As anonymous user, so no direct access, should be redirected to login page
            self.assertEqual(302, response.status_code)

            browser.login(username=TEST_USER_NAME, password=TEST_USER_PASSWORD)
            response = browser.get('/admin/')
            # Authenticated admin user should have access
            self.assertEqual(200, response.status_code)

            # User has dedicated urlconf module, so it should be assigned
            expected_module = get_generated_urlconf_module(get_generated_urlconf_file(TEST_USER_ROUTE_NAME))
            self.assertEqual(expected_module, response.wsgi_request.urlconf)

            ContentTypeRoutingTable.objects.filter(content_type=ContentType.objects.get_for_model(UserModel),
                                                   object_id=response.wsgi_request.user.id).delete()

            # Make Session works, as we remove user's route but still should same
            response = browser.get('/admin/')
            self.assertEqual(expected_module, response.wsgi_request.urlconf)
            self.assertEqual(expected_module, response.wsgi_request.session['settings']['urlconf'])

            # Make sure caching works
            browser.logout()
            browser.login(username=TEST_USER_NAME, password=TEST_USER_PASSWORD)
            response = browser.get('/admin/')
            self.assertEqual(expected_module, response.wsgi_request.urlconf)

            # Now we are cleaning session and cache as well, so we expect urlconf should come group
            browser.logout()
            self.cache.clear()
            browser.login(username=TEST_USER_NAME, password=TEST_USER_PASSWORD)
            response = browser.get('/admin/')

            expected_module = get_generated_urlconf_module(get_generated_urlconf_file(TEST_GROUP_ROUTE_NAME))
            self.assertEqual(expected_module, response.wsgi_request.urlconf)

            ContentTypeRoutingTable.objects.filter(content_type=ContentType.objects.get_for_model(Group)).delete()

            # Now we are cleaning session and cache as well, group's route also clened
            # so we expect urlconf should be like site urlconf
            browser.logout()
            self.cache.clear()
            browser.login(username=TEST_USER_NAME, password=TEST_USER_PASSWORD)
            response = browser.get('/admin/')

            expected_module = get_generated_urlconf_module(get_generated_urlconf_file(TEST_ROUTE_NAME))
            self.assertEqual(expected_module, response.wsgi_request.urlconf)
    def test_process_request(self):

        with self.modify_settings(MIDDLEWARE_CLASSES={'append': [
            'django.contrib.sites.middleware.CurrentSiteMiddleware',
            'hacs.middleware.DynamicRouteMiddleware'

        ]}):
            browser = Client()
            response = browser.get('/admin/')
            expected_module = get_generated_urlconf_module(get_generated_urlconf_file(TEST_ROUTE_NAME))

            # Status code should be 302 as anonymous user
            self.assertEqual(302, response.status_code)
            # Make sure correct urlconf module
            self.assertEqual(expected_module, response.wsgi_request.urlconf)

            # Multi Site Testing
            browser = Client(SERVER_NAME='localhost')
            response = browser.get('/admin/')
            expected_module = get_generated_urlconf_module(get_generated_urlconf_file('localhost-route'))

            # Make sure another site with same settings
            self.assertEqual('localhost', response.wsgi_request.get_host())
            # Make sure correct urlconf
            self.assertEqual(expected_module, response.wsgi_request.urlconf)

            # Make sure cache also updated
            self.assertEqual(2, len(HACS_SITE_CACHE))
Ejemplo n.º 3
0
    def test_process_request(self):

        with self.modify_settings(MIDDLEWARE_CLASSES={'append': [
            'django.contrib.sites.middleware.CurrentSiteMiddleware',
            'hacs.middleware.DynamicRouteMiddleware'

        ]}):
            browser = Client()
            response = browser.get('/admin/')
            expected_module = get_generated_urlconf_module(get_generated_urlconf_file(TEST_ROUTE_NAME))

            # Status code should be 302 as anonymous user
            self.assertEqual(302, response.status_code)
            # Make sure correct urlconf module
            self.assertEqual(expected_module, response.wsgi_request.urlconf)

            # Multi Site Testing
            browser = Client(SERVER_NAME='localhost')
            response = browser.get('/admin/')
            expected_module = get_generated_urlconf_module(get_generated_urlconf_file('localhost-route'))

            # Make sure another site with same settings
            self.assertEqual('localhost', response.wsgi_request.get_host())
            # Make sure correct urlconf
            self.assertEqual(expected_module, response.wsgi_request.urlconf)

            # Make sure cache also updated
            self.assertEqual(2, len(HACS_SITE_CACHE))
Ejemplo n.º 4
0
    def test_set_user_urlconf(self):

        request = self.request_factory.request()
        request.path_info = u'/admin/'
        request.site = get_current_site(request)
        session = request.session = self.SessionStore(hashlib.md5('hacs').hexdigest())
        user = request.user = UserModel.objects.get(username=TEST_USER_NAME)

        middleware = FirewallMiddleware()
        request.session['settings'] = dict()
        middleware._set_user_urlconf(request)
        user_urlconf_module = get_generated_urlconf_module(get_generated_urlconf_file(TEST_USER_ROUTE_NAME))

        # We Make sure session is updated
        try:
            self.assertEqual(session['settings']['urlconf'], user_urlconf_module)
        except KeyError:
            raise AssertionError("Code should not come here")

        # Make sure cache is also updated
        user_cache_key = get_user_key(request)
        self.assertEqual(self.cache.get(user_cache_key)['urlconf'], user_urlconf_module)

        ContentTypeRoutingTable.objects.filter(content_type=ContentType.objects.get_for_model(UserModel),
                                               object_id=user.id).delete()
        request.session.clear()
        request.session['settings'] = dict()
        self.cache.clear()
        middleware._set_user_urlconf(request)

        # Make sure session updated and urlconf changed to Group Routing specific
        user_urlconf_module = get_generated_urlconf_module(get_generated_urlconf_file(TEST_GROUP_ROUTE_NAME))
        try:
            # user's urlconf should be instance of tuple, because use could be member of several groups
            self.assertEqual(session['settings']['urlconf'][0], user_urlconf_module)
        except KeyError:
            raise AssertionError("Code should not come here")

        # Make sure cache also be updated and Group specific routing
        self.assertEqual(self.cache.get(user_cache_key)['urlconf'][0], user_urlconf_module)

        ContentTypeRoutingTable.objects.filter(content_type=ContentType.objects.get_for_model(Group)).delete()

        request.session.clear()
        request.session['settings'] = dict()
        self.cache.clear()
        middleware._set_user_urlconf(request)

        # Make sure fallback urlconf is None, because request has no urlconf attribute either set by DynamicMiddleware
        # or from django settings
        try:
            # user's urlconf should be none, because either user or groups have no urlconf
            self.assertIsNone(session['settings']['urlconf'])
        except KeyError:
            raise AssertionError("Code should not come here")
    def test_calculate_user_urlconf(self):
        """
        :return:
        """
        middleware = FirewallMiddleware()
        request = self.request_factory.request()
        test_user = self.user_model_cls.objects.get(**{self.user_model_cls.USERNAME_FIELD: TEST_USER_NAME})
        test_site = Site.objects.get(domain=TEST_HOST_NAME)
        request.site = test_site
        user_rules = ContentTypeRoutingRules.objects.get(
            content_type=ContentType.objects.get_for_model(self.user_model_cls),
            object_id=test_user.pk,
            site=test_site
        )
        request.user = test_user
        request.path_info = '/admin/'
        user_settings = {
            'urlconf': get_generated_urlconf_module(get_generated_urlconf_file(user_rules.route.slug), False),
            'allowed_http_methods': user_rules.allowed_method,
            'blacklisted_uri': None,
            'whitelisted_uri': None,
            'has_own_rules': True
        }

        result = middleware._calculate_user_urlconf(request, user_settings)
        expected_urlconf = get_generated_urlconf_module(get_generated_urlconf_file(TEST_USER_ROUTE_NAME), False)

        self.assertEqual(result, expected_urlconf)
        # we remove user's rules so should come from groups
        ContentTypeRoutingRules.objects.filter(
            content_type=ContentType.objects.get_for_model(self.user_model_cls),
            object_id=test_user.pk,
            site=test_site
        ).delete()
        user_settings['has_own_rules'] = False
        user_settings['urlconf'] = None
        user_settings['allowed_http_methods'] = None
        user_settings['groups'] = []

        for group in test_user.groups.unrestricted():
            user_settings['groups'].append((get_group_key(request, group), group.natural_key()))
            # We will trigger auth group settings from here
            middleware.set_auth_group_settings(request, group, False)

        result = middleware._calculate_user_urlconf(request, user_settings)
        expected_urlconf = get_generated_urlconf_module(get_generated_urlconf_file(TEST_GROUP_ROUTE_NAME), False)

        self.assertEqual(result, expected_urlconf)
        # Make sure user settings is updated
        self.assertEqual(len( user_settings['allowed_http_methods']), 2)
        self.assertEqual(tuple(user_settings['allowed_http_methods']), ('GET', 'POST', ))
    def test_set_site_settings(self):

        request = self.request_factory.request()
        request.site = get_current_site(request)
        urlconf_filename = get_generated_urlconf_file(TEST_ROUTE_NAME)
        if os.path.exists(urlconf_filename):
            os.unlink(urlconf_filename)
        set_site_settings(site=request.site)
        # urlconf module created
        self.assertTrue(os.path.exists(urlconf_filename))

        urlconf_file_creation_time = datetime.datetime.fromtimestamp(os.path.getmtime(urlconf_filename))
        set_site_settings(site=request.site)

        # Make sure urlconf file is not recreated
        self.assertEqual(urlconf_file_creation_time, datetime.datetime.fromtimestamp(os.path.getmtime(urlconf_filename)))

        site_route = SiteRoutingRules.objects.get(site=request.site)
        site_route.route.modified_on = timezone.now()
        site_route.route.description = 'catch'
        site_route.route.save()
        set_site_settings(site=request.site)

        # Make sure urlconf file recreated, after route modification
        self.assertNotEqual(urlconf_file_creation_time,
                            datetime.datetime.fromtimestamp(os.path.getmtime(urlconf_filename)))
Ejemplo n.º 7
0
    def test_set_site_urlconf(self):

        request = self.request_factory.request()
        request.site = get_current_site(request)
        urlconf_filename = get_generated_urlconf_file(TEST_ROUTE_NAME)
        if os.path.exists(urlconf_filename):
            os.unlink(urlconf_filename)
        set_site_urlconf(site=request.site)
        # urlconf module created
        self.assertTrue(os.path.exists(urlconf_filename))

        urlconf_file_creation_time = datetime.datetime.fromtimestamp(os.path.getmtime(urlconf_filename))
        set_site_urlconf(site=request.site)

        # Make sure urlconf file is not recreated
        self.assertEqual(urlconf_file_creation_time, datetime.datetime.fromtimestamp(os.path.getmtime(urlconf_filename)))

        site_route = SiteRoutingTable.objects.get(site=request.site)
        site_route.route.updated_on = timezone.now()
        site_route.route.save()
        set_site_urlconf(site=request.site)

        # Make sure urlconf file recreated, after route modification
        self.assertNotEqual(urlconf_file_creation_time,
                            datetime.datetime.fromtimestamp(os.path.getmtime(urlconf_filename)))
    def test_get_site_urlconf(self):

        request = self.request_factory.request()
        request.site = get_current_site(request)
        urlconf_filename = get_generated_urlconf_file(TEST_ROUTE_NAME)

        urlconf_module = get_site_urlconf(request.site)
        import importlib
        try:
            importlib.import_module(urlconf_module)
        except ImportError:
            raise AssertionError("Code should not come here. `%s` is not valid module or not is sys path")

        # Make sure Site Cache is updated
        self.assertEqual(1, len(HACS_SITE_CACHE))
        # We will make sure that again call will server from cache
        urlconf_file_creation_time = datetime.datetime.fromtimestamp(os.path.getmtime(urlconf_filename))

        site_route = SiteRoutingRules.objects.get(site=request.site)
        site_route.route.modified_on = timezone.now()
        site_route.route.save()
        get_site_urlconf(request.site)

        # Make sure serve from cache!
        # How can we make sure?
        # We forcefully changed the updated date of route, so if `set_site_settings` method is called, then urlconf
        # module file must be recreated.
        self.assertEqual(urlconf_file_creation_time, datetime.datetime.fromtimestamp(os.path.getmtime(urlconf_filename)))
Ejemplo n.º 9
0
    def test_process_request(self):

        request = self.request_factory.request()
        request.site = get_current_site(request)
        request.urlconf = None
        urlconf_filename = get_generated_urlconf_file(TEST_ROUTE_NAME)
        middleware = DynamicRouteMiddleware()
        # Make sure not from cache
        self.assertEqual(0, len(HACS_SITE_CACHE))
        # Let's clear the lru cache, as this function wrapped by lru_cache decorator
        get_site_urlconf.cache_clear()

        middleware.process_request(request)
        self.assertEqual(request.urlconf, get_generated_urlconf_module(urlconf_filename))

        # Make sure served from lru cache
        middleware.process_request(request)
        self.assertEqual(1, get_site_urlconf.cache_info().hits)

        # Even serve from Global Site Cache
        get_site_urlconf.cache_clear()
        os.unlink(urlconf_filename)
        middleware.process_request(request)

        # Make sure serve from Global Cache although lru cache is cleared
        # As set_site_urlconf function is not called, new urlrconf file is generated although it is not exist.
        self.assertFalse(os.path.exists(urlconf_filename))
Ejemplo n.º 10
0
    def test_get_site_urlconf(self):

        request = self.request_factory.request()
        request.site = get_current_site(request)
        urlconf_filename = get_generated_urlconf_file(TEST_ROUTE_NAME)

        urlconf_module = get_site_urlconf(request.site)
        import importlib
        try:
            importlib.import_module(urlconf_module)
        except ImportError:
            raise AssertionError("Code should not come here. `%s` is not valid module or not is sys path")

        # Make sure Site Cache is updated
        self.assertEqual(1, len(HACS_SITE_CACHE))
        # We will make sure that again call will server from cache
        urlconf_file_creation_time = datetime.datetime.fromtimestamp(os.path.getmtime(urlconf_filename))

        site_route = SiteRoutingTable.objects.get(site=request.site)
        site_route.route.updated_on = timezone.now()
        site_route.route.save()
        get_site_urlconf(request.site)

        # Make sure serve from cache!
        # How can we make sure?
        # We forcefully changed the updated date of route, so if `set_site_urlconf` method is called, then urlconf
        # module file must be recreated.
        self.assertEqual(urlconf_file_creation_time, datetime.datetime.fromtimestamp(os.path.getmtime(urlconf_filename)))
    def test_process_request(self):

        request = self.request_factory.request()
        request.site = get_current_site(request)
        request.urlconf = None
        urlconf_filename = get_generated_urlconf_file(TEST_ROUTE_NAME)
        middleware = DynamicRouteMiddleware()
        # Make sure not from cache
        self.assertEqual(0, len(HACS_SITE_CACHE))
        # Let's clear the lru cache, as this function wrapped by lru_cache decorator
        get_site_urlconf.cache_clear()

        middleware.process_request(request)
        self.assertEqual(request.urlconf, get_generated_urlconf_module(urlconf_filename))

        # Make sure served from lru cache
        middleware.process_request(request)
        self.assertEqual(1, get_site_urlconf.cache_info().hits)

        # Even serve from Global Site Cache
        get_site_urlconf.cache_clear()
        os.unlink(urlconf_filename)
        middleware.process_request(request)

        # Make sure serve from Global Cache although lru cache is cleared
        # As set_site_settings function is not called, new urlrconf file is generated although it is not exist.
        self.assertFalse(os.path.exists(urlconf_filename))
Ejemplo n.º 12
0
    def test_calculate_user_urlconf(self):
        """
        :return:
        """
        urls_confs = []
        for route in RoutingTable.objects.all().order_by('-id'):
            if not os.path.exists(get_generated_urlconf_file(route.route_name)):
                generate_urlconf_file(get_generated_urlconf_file(route.route_name), route)
            urls_confs.append(get_generated_urlconf_module(get_generated_urlconf_file(route.route_name)))

        middleware = FirewallMiddleware()
        result = middleware._calculate_user_urlconf('/admin/', urls_confs)
        expected_urlconf = get_generated_urlconf_module(
            get_generated_urlconf_file(TEST_GROUP_ROUTE_NAME),
            RoutingTable.objects.get(route_name=TEST_GROUP_ROUTE_NAME))

        self.assertEqual(result, expected_urlconf)
    def test_process_request(self):

        request = self.request_factory.request()
        request.urlconf = None
        request.path_info = '/admin/'
        request.site = get_current_site(request)
        user = request.user = self.user_model_cls.objects.get(**{self.user_model_cls.USERNAME_FIELD: TEST_USER_NAME})
        request.session = self.SessionStore(hashlib.md5(smart_bytes(getattr(user, user.USERNAME_FIELD))).hexdigest())
        middleware = FirewallMiddleware()
        middleware.process_request(request)

        user_urlconf_module = get_generated_urlconf_module(get_generated_urlconf_file(TEST_USER_ROUTE_NAME))
        # Make sure user's urlconf module is assigned
        self.assertEqual(user_urlconf_module, request.urlconf)

        # Let's Try for Anonymous User
        request.urlconf = None
        request.user = AnonymousUser()
        self.cache.clear()
        request.session.clear()
        middleware.process_request(request)
        # Should be Fallback urlconf module
        self.assertEqual(request.urlconf, HACS_FALLBACK_URLCONF)

        ContentTypeRoutingRules.objects.filter(content_type=ContentType.objects.get_for_model(self.user_model_cls),
                                               object_id=user.id).delete()
        user_urlconf_module = get_generated_urlconf_module(get_generated_urlconf_file(TEST_GROUP_ROUTE_NAME), validation=False)
        self.cache.clear()
        request.session.clear()
        # Restore original user
        request.user = user
        middleware.process_request(request)
        # Make sure user's group's urlconf is assigned as user's routing is not available
        self.assertEqual(user_urlconf_module, request.urlconf)

        ContentTypeRoutingRules.objects.filter(content_type=ContentType.objects.get_for_model(HacsGroupModel)).delete()
        self.cache.clear()
        request.session.clear()
        request.urlconf = None

        middleware.process_request(request)
        # As urlconf is unavailable for user as well as groups and request urlconf attribute has None value
        # So showing warning and assign fallback urlconf
        self.assertEqual(request.urlconf, HACS_FALLBACK_URLCONF)
Ejemplo n.º 14
0
    def test_set_group_urlconf(self):

        request = self.request_factory.request()
        request.site = get_current_site(request)
        user = request.user = UserModel.objects.get(username=TEST_USER_NAME)
        middleware = FirewallMiddleware()

        middleware._set_group_urlconf(request, user.groups.get(name='administrator'))
        group_key = get_group_key(request, user.groups.get(name='administrator'))
        group_urlconf_module = get_generated_urlconf_module(get_generated_urlconf_file(TEST_GROUP_ROUTE_NAME))

        # We make sure cache is updated and right values are assigned
        self.assertEqual(group_urlconf_module, self.cache.get(group_key)['urlconf'])
        self.assertEqual(RoutingTable.objects.get(route_name=TEST_GROUP_ROUTE_NAME),
                         RoutingTable.objects.get(pk=self.cache.get(group_key)['route_id']))
    def test_set_auth_group_settings(self):
        """"""
        request = self.request_factory.request()
        request.site = get_current_site(request)
        user = request.user = self.user_model_cls.objects.get(**{self.user_model_cls.USERNAME_FIELD: TEST_USER_NAME})
        middleware = FirewallMiddleware()

        group = user.groups.unrestricted().first()
        middleware.set_auth_group_settings(request, group)

        group_key = get_group_key(request, group)
        group_urlconf_module = get_generated_urlconf_module(get_generated_urlconf_file(TEST_GROUP_ROUTE_NAME))

        # We make sure cache is updated and right values are assigned
        self.assertEqual(group_urlconf_module, self.cache.get(group_key)['urlconf'])
        self.assertEqual(RoutingTable.objects.get_by_natural_key(TEST_GROUP_ROUTE_NAME),
                         RoutingTable.objects.get(pk=self.cache.get(group_key)['route_id']))
    def test_set_auth_user_settings(self):
        """"""
        request = self.request_factory.request()
        request.path_info = '/admin/'
        request.site = get_current_site(request)
        user = request.user = self.user_model_cls.objects.get(**{self.user_model_cls.USERNAME_FIELD: TEST_USER_NAME})

        middleware = FirewallMiddleware()
        middleware.set_auth_user_settings(request)

        user_urlconf_module = get_generated_urlconf_module(get_generated_urlconf_file(TEST_USER_ROUTE_NAME))

        # Make sure cache is updated
        user_cache_key = get_user_key(request)
        self.assertEqual(self.cache.get(user_cache_key)['urlconf'], user_urlconf_module)

        ContentTypeRoutingRules.objects.filter(content_type=ContentType.objects.get_for_model(self.user_model_cls),
                                               object_id=user.id).delete()
        self.cache.clear()
        middleware.set_auth_user_settings(request)
        # Make sure cache be updated and should be None
        self.assertIsNone(self.cache.get(user_cache_key)['urlconf'])
    def test_process_request(self):

        with modify_settings(
            MIDDLEWARE_CLASSES={'append': [
                'django.contrib.sites.middleware.CurrentSiteMiddleware',
                'hacs.middleware.DynamicRouteMiddleware',
                'hacs.middleware.FirewallMiddleware',
                'hacs.middleware.AccessControlMiddleware'
            ]}
        ):
            browser = Client()
            response = browser.get('/tests/content-manager-view/')
            fake_request = RequestFactory().request()
            fake_request.urlconf = None
            fake_request.user = self.user_model_cls.objects.get(**{self.user_model_cls.USERNAME_FIELD: TEST_USER_NAME})
            fake_request.site = Site.objects.get(domain=TEST_HOST_NAME)

            user_key = get_user_key(fake_request)
            # AS anonymous user so urlconf module should default site
            expected_module = get_generated_urlconf_module(get_generated_urlconf_file(TEST_ROUTE_NAME))
            self.assertEqual(expected_module, response.wsgi_request.urlconf)
            # As anonymous user, so forbidden!, @todo: should be redirected to login page?
            self.assertEqual(403, response.status_code)

            browser.login(username=TEST_USER_NAME, password=TEST_USER_PASSWORD)
            response = browser.get('/tests/content-manager-view/')
            # Authenticated Editor user should have access
            self.assertEqual(200, response.status_code)

            # User has dedicated urlconf module, so it should be assigned
            expected_module = get_generated_urlconf_module(get_generated_urlconf_file(TEST_USER_ROUTE_NAME))
            self.assertEqual(expected_module, response.wsgi_request.urlconf)

            ContentTypeRoutingRules.objects.filter(content_type=ContentType.objects.get_for_model(self.user_model_cls),
                                                   object_id=response.wsgi_request.user.id).delete()

            # Make Session works, as we remove user's route but still should same
            response = browser.get('/tests/content-manager-view/')
            self.assertEqual(expected_module, response.wsgi_request.urlconf)
            self.assertEqual(expected_module, self.cache.get(user_key)['urlconf'])

            # Make sure caching works
            browser.logout()
            browser.login(username=TEST_USER_NAME, password=TEST_USER_PASSWORD)
            response = browser.get('/tests/content-manager-view/')
            self.assertEqual(expected_module, response.wsgi_request.urlconf)

            # Now we are cleaning session and cache as well, so we expect urlconf should come group
            browser.logout()
            self.cache.clear()
            browser.login(username=TEST_USER_NAME, password=TEST_USER_PASSWORD)
            response = browser.get('/tests/content-manager-view/')

            expected_module = get_generated_urlconf_module(get_generated_urlconf_file(TEST_GROUP_ROUTE_NAME))
            self.assertEqual(expected_module, response.wsgi_request.urlconf)

            ContentTypeRoutingRules.objects.filter(content_type=ContentType.objects.get_for_model(HacsGroupModel)).delete()

            # Now we are cleaning session and cache as well, group's route also cleaned
            # so we expect urlconf should be like site urlconf
            browser.logout()
            self.cache.clear()
            browser.login(username=TEST_USER_NAME, password=TEST_USER_PASSWORD)
            response = browser.get('/tests/content-manager-view/')

            expected_module = get_generated_urlconf_module(get_generated_urlconf_file(TEST_ROUTE_NAME))
            self.assertEqual(expected_module, response.wsgi_request.urlconf)