Beispiel #1
0
 def test_process_request_no_mappings(self):
     settings = {
     }
     request = self.factory.get('/appnameoriginal/viewnameoriginal', **{
         'HTTP_REFERER': 'http://www.referer.com/refererpath/?id=/viewparams/moreparams'
     })
     expected_path_info = '/appnameoriginal/viewnameoriginal'
     with patch_settings(**settings):
         middleware = IframedMiddleware()
         middleware.process_request(request)
         
         self.assertEqual(request.path_info, expected_path_info)
Beispiel #2
0
 def test_process_request_match(self):
     settings = {
         'IFRAMED_MAPPINGS': [
             ('/appname/viewname', '/refererpath'),
         ]
     }
     request = self.factory.get('/appnameignored/viewnameignored', **{
         'HTTP_REFERER': 'http://www.referer.com/refererpath/?id=/viewparams/moreparams'
     })
     expected_path_info = '/appname/viewname/viewparams/moreparams'
     with patch_settings(**settings):
         middleware = IframedMiddleware()
         middleware.process_request(request)
         
         self.assertEqual(request.path_info, expected_path_info)
Beispiel #3
0
 def test_process_request_aliased(self):
     settings = {
         'IFRAMED_ALIASES': {
             '/alternative_location': '/refererpath',
         },
         'IFRAMED_MAPPINGS': [
             ('/appname/viewname', '/refererpath'),
         ]
     }
     request = self.factory.get('/appnamehonoured/viewnamehonoured', **{
         'HTTP_REFERER': 'http://www.referer.com/alternative_location/?id=/viewparamsignored/moreparamsignored'
     })
     expected_path_info = '/appnamehonoured/viewnamehonoured'
     with patch_settings(**settings):
         middleware = IframedMiddleware()
         middleware.process_request(request)
         
         self.assertEqual(request.path_info, expected_path_info)
Beispiel #4
0
 def test_reverse_with_referer(self):
     settings = {
         'ROOT_URLCONF': 'iframed.tests',
         'IFRAMED_MAPPINGS': [
             ('/appname/viewname', '/refererpath'),
         ]
     }
     
     request = self.factory.get('/appnameignored/viewnameignored', **{
         'HTTP_REFERER': 'http://www.referer.com/refererpath/?id=/viewparams/moreparams'
     })
     expected_result = 'http://www.referer.com/refererpath?id=/param'
     
     with patch_settings(**settings):
         reload(urlresolvers)
         middleware = IframedMiddleware()
         middleware.process_request(request)
         result = urlresolvers.reverse('test', request=request,  args=['param'])
         self.assertEqual(result, expected_result)