示例#1
0
    def test_authenticated(self, user: User, rf: RequestFactory):
        request = rf.get("/fake-url/")
        request.user = UserFactory()

        response = user_detail_view(request, username=user.username)

        assert response.status_code == 200
示例#2
0
    def test_not_authenticated(self, user: User, rf: RequestFactory):
        request = rf.get("/fake-url/")
        request.user = AnonymousUser()

        response = user_detail_view(request, pk=user.id)

        assert response.status_code == 302
        assert response.url == "/accounts/login/?next=/fake-url/"
示例#3
0
    def test_not_authenticated(self, user: User, rf: RequestFactory):
        request = rf.get("/fake-url/")
        request.user = AnonymousUser()

        response = user_detail_view(request, username=user.username)
        login_url = reverse(settings.LOGIN_URL)

        assert response.status_code == 302
        assert response.url == f"{login_url}?next=/fake-url/"
示例#4
0
    def test_authenticated(self, user: User, rf: RequestFactory):
        """[summary]
        Test Login user can see /users/{user.id}/ (user detail)
        """

        request = rf.get("/fake-url/")
        request.user = UserFactory()

        response = user_detail_view(request, pk=user.id)

        assert response.status_code == 200
    def test_case_sensitivity(self, rf: RequestFactory):
        request = rf.get("/fake-url/")
        request.user = UserFactory(username="******")

        with pytest.raises(Http404):
            user_detail_view(request, username="******")