コード例 #1
0
ファイル: tests.py プロジェクト: agiliq/django-subdomain
 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
ファイル: tests.py プロジェクト: agiliq/django-subdomain
 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
ファイル: tests.py プロジェクト: agiliq/django-subdomain
 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
ファイル: tests.py プロジェクト: 50c10/Tunasoft-Tiendas
 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
ファイル: tests.py プロジェクト: agiliq/django-subdomain
 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
ファイル: tests.py プロジェクト: agiliq/django-subdomain
 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
ファイル: tests.py プロジェクト: agiliq/django-subdomain
 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
ファイル: tests.py プロジェクト: 50c10/Tunasoft-Tiendas
 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
ファイル: tests.py プロジェクト: agiliq/django-subdomain
 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)