Пример #1
0
 def testGetSubdomainMiddleware5(self):
     "Test GetSubdomainMiddleware.process_request populates the variables we need correctly"
     rf = RequestFactory(domain = 'boox.notfoo.tld')
     request = rf.request()
     middleware = GetSubdomainMiddleware()
     middleware.process_request(request)
     self.assertEqual(request.META['domain'], 'boox.notfoo.tld')
Пример #2
0
 def testGetSubdomainMiddleware2(self):
     "Test GetSubdomainMiddleware.process_request populates the variables we need correctly"
     rf = RequestFactory(subdomain = 'www')
     request = rf.request()
     middleware = GetSubdomainMiddleware()
     middleware.process_request(request)
     self.assertEqual(request.META['subdomain'], 'www')
     self.assertEqual(request.subdomain, None)
Пример #3
0
 def testGetSubdomainMiddleware3(self):
     "Test GetSubdomainMiddleware.process_request populates the variables we need correctly"
     user = User.objects.create_user(username = '******', password = '******', email = '*****@*****.**')
     subdomain = Subdomain.objects.register_new_subdomain(subdomain_text = 'foo4', name='Foo, the subdomain', description = 'Foo has not description', user = user)
     rf = RequestFactory(subdomain = 'foo4')
     request = rf.request()
     middleware = GetSubdomainMiddleware()
     middleware.process_request(request)
     self.assertEqual(request.META['subdomain'], 'foo4')
Пример #4
0
 def testGetSubdomainMiddleware5(self):
     "Test GetSubdomainMiddleware.process_request populates the variables we need correctly"
     rf = RequestFactory(domain = 'boox.notfoo.tld')
     request = rf.request()
     middleware = GetSubdomainMiddleware()
     middleware.process_request(request)
     self.assertEqual(request.subdomain_text, 'boox.notfoo.tld')
     self.assertEqual(request.main_site, False)
     self.assertEqual(request.subdomain, None)
Пример #5
0
 def testpopulate_subdomain(self):
     user = User.objects.create_user(username = '******', password = '******', email = '*****@*****.**')
     subdomain = Subdomain.objects.register_new_subdomain(subdomain_text = 'foo5', name='Foo, the subdomain', description = 'Foo has not description', user = user)
     rf = RequestFactory(subdomain = 'foo5', main_site = False)
     request = rf.request()
     middleware = GetSubdomainMiddleware()
     middleware.process_request(request)
     context = populate_subdomain(request)
     self.assertEqual(context['subdomain_text'], 'testserver')
     self.assertEqual(context['main_site'], False)
     self.assertEqual(context['subdomain'], None)
Пример #6
0
 def testensure_is_main_subdomain2(self):
     def view_func(request):
         "Dummy view function to decorate"
         return HttpResponse('hello')
     view_func = ensure_is_main_subdomain(view_func)
     rf = RequestFactory(subdomain = 'bar')
     request = rf.request()
     middleware = GetSubdomainMiddleware()
     middleware.process_request(request)
     response = view_func(request)
     self.assertEqual(HttpResponseRedirect, response.__class__)
Пример #7
0
 def testensure_has_subdomain2(self):
     def view_func(request):
         "Dummy view function to decorate"
         return HttpResponse('hello')
     view_func = ensure_has_subdomain(view_func)
     user = User.objects.create_user(username = '******', password = '******', email = '*****@*****.**')
     subdomain = Subdomain.objects.register_new_subdomain(subdomain_text = 'foo7', name='Foo, the subdomain', description = 'Foo has not description', user = user)
     rf = RequestFactory(subdomain = 'doesnotexistxx')
     request = rf.request()
     middleware = GetSubdomainMiddleware()
     middleware.process_request(request)
     response = view_func(request)
     self.assertEqual(HttpResponseRedirect, response.__class__)
Пример #8
0
 def testGetSubdomainMiddleware4(self):
     "Test GetSubdomainMiddleware.process_request populates the variables we need correctly"
     user = User.objects.create_user(username = '******', password = '******', email = '*****@*****.**')
     subdomain = Subdomain.objects.register_new_subdomain(subdomain_text = 'fooa1', name='Foo, the subdomain', description = 'Foo has not description', user = user, subdomain_callback = create_subdomain_settings)
     subdomain.domain = 'bax.notfoo.tld'
     subdomain.save()
     rf = RequestFactory(domain = 'bax.notfoo.tld')
     request = rf.request()
     middleware = GetSubdomainMiddleware()
     middleware.process_request(request)
     self.assertEqual(request.subdomain_text, 'bax.notfoo.tld')
     self.assertEqual(request.main_site, False)
     self.assertEqual(request.subdomain, subdomain)
Пример #9
0
 def testGetSubdomainMiddleware1(self):
     "Test GetSubdomainMiddleware.process_request succeds without exceptions on a request."
     rf = RequestFactory(subdomain = 'foo')
     request = rf.request()
     middleware = GetSubdomainMiddleware()
     middleware.process_request(request)