Exemplo n.º 1
0
    def test_instance_is_set_returns_itself(self):
        request = self.factory.get('/')
        request.instance = self.instance
        middleware = DDAHSiteMiddleware()

        middleware.process_request(request)
        self.assertEquals(request.instance, self.instance)
Exemplo n.º 2
0
    def test_site_is_set_and_related_to_an_instance(self):
        request = self.factory.get('/')
        request.META['SERVER_NAME'] = self.the_site.domain
        middleware = DDAHSiteMiddleware()

        middleware.process_request(request)
        self.assertEquals(request.instance, self.instance)
Exemplo n.º 3
0
    def test_instance_is_none_and_domain_is_set(self):
        request = self.factory.get('/')
        request.META['SERVER_NAME'] = self.the_site.domain
        request.instance = None
        # django-subdomain-instances
        # sets urlconf in the request
        request.urlconf = 'urlconf, something'
        middleware = DDAHSiteMiddleware()

        middleware.process_request(request)
        self.assertEquals(request.instance, self.instance)
        self.assertFalse(hasattr(request, 'urlconf'))
Exemplo n.º 4
0
 def test_it_doesnt_break_anything(self):
     request = self.factory.get('/')
     middleware = DDAHSiteMiddleware()
     middleware.process_request(request)
     self.assertIsInstance(request, HttpRequest)