예제 #1
0
파일: sites.py 프로젝트: Eltoni/summum
    def get_urls(self):
        """Add dashboard view to admin urlconf."""
        urls = super(AdminMixin, self).get_urls()
        del urls[0]
        custom_url = [
            url(r'^$', self.admin_view(DashboardMainView.as_view()), name="index")
        ]

        return custom_url + urls
예제 #2
0
파일: tests.py 프로젝트: Eltoni/summum
    def test_access_user_anonymous(self):
        # Create an instance of a GET request.
        request = self.factory.get('/dashboard/')

        # Simulate an anonymous user by setting request.user to an AnonymousUser instance.
        request.user = AnonymousUser()

        # Test index() as if it were deployed at /dashboard/
        response = DashboardMainView.as_view()(request)

        self.assertEqual(response.status_code, 302)
예제 #3
0
파일: tests.py 프로젝트: Gustavosdo/summum
    def test_access_user_anonymous(self):
        # Create an instance of a GET request.
        request = self.factory.get('/dashboard/')
        
        # Simulate an anonymous user by setting request.user to an AnonymousUser instance.
        request.user = AnonymousUser()
        
        # Test index() as if it were deployed at /dashboard/
        response = DashboardMainView.as_view()(request)

        self.assertEqual(response.status_code, 302)


    # def test_access_user_authenticated(self):
    #     # Create an instance of a GET request.
    #     request = self.factory.get('/dashboard/')
        
    #     # Recall that middleware are not supported. You can simulate a logged-in user by setting request.user manually.
    #     request.user = self.user
        
    #     # Test index() as if it were deployed at /dashboard/
    #     response = DashboardMainView.as_view()(request)

    #     self.assertEqual(response.status_code, 200)