コード例 #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
ファイル: test_forms.py プロジェクト: hkang106/collectdata
    def test_clean_username(self):
        # A user with proto_user params does not exist yet.
        proto_user = UserFactory.build()

        form = UserCreationForm(
            {
                "username": proto_user.username,
                "password1": proto_user._password,
                "password2": proto_user._password,
            }
        )

        assert form.is_valid()
        assert form.clean_username() == proto_user.username

        # Creating a user.
        form.save()

        # The user with proto_user params already exists,
        # hence cannot be created.
        form = UserCreationForm(
            {
                "username": proto_user.username,
                "password1": proto_user._password,
                "password2": proto_user._password,
            }
        )

        assert not form.is_valid()
        assert len(form.errors) == 1
        assert "username" in form.errors
コード例 #3
0
    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="******")
コード例 #4
0
def user() -> User:
    return UserFactory()
コード例 #5
0
ファイル: conftest.py プロジェクト: hkang106/collectdata
def user() -> settings.AUTH_USER_MODEL:
    return UserFactory()
コード例 #6
0
    def test_raise_not_found_error(self, url, client):
        user = UserFactory()
        client.force_authenticate(user)
        response = client.get(url)

        assert response.status_code == 404
コード例 #7
0
def user():
    return UserFactory()