Example #1
0
    def test_get_redirect_url(self, user: User, rf: RequestFactory):
        view = UserRedirectView()
        request = rf.get("/fake-url")
        request.user = user

        view.request = request

        assert view.get_redirect_url() == f"/users/{user.username}/"
    def test_get_redirect_url(self, user: settings.AUTH_USER_MODEL,
                              request_factory: RequestFactory):
        view = UserRedirectView()
        request = request_factory.get("/fake-url")
        request.user = user

        view.request = request

        assert view.get_redirect_url() == f"/users/{user.username}/"
Example #3
0
 def test_get_redirect_url(self):
     # Instantiate the view directly. Never do this outside a test!
     view = UserRedirectView()
     # Generate a fake request
     request = self.factory.get('/fake-url')
     # Attach the user to the request
     request.user = self.user
     # Attach the request to the view
     view.request = request
     # Expect: '/users/testuser/', as that is the default username for
     #   self.make_user()
     self.assertEqual(view.get_redirect_url(), '/users/testuser/')