Exemple #1
0
 def test_not_authenticate_user(self):
     email = random_email()
     password = random_lower_string()
     user = crud.user.authenticate(db_session,
                                   email=email,
                                   password=password)
     assert user is None
Exemple #2
0
def payload_normal_user():
    return json.dumps({
        "full_name": random_lower_string(),
        "email": random_email(),
        "password": random_lower_string(),
        "cpf": random_cpf(),
    })
Exemple #3
0
def user_in():
    email = random_email()
    password = random_lower_string()
    full_name = random_lower_string()
    cpf = random_cpf()

    return UserCreate(email=email,
                      password=password,
                      full_name=full_name,
                      cpf=cpf)
Exemple #4
0
    def test_create_user(self):
        email = random_email()
        password = random_lower_string()
        full_name = random_lower_string()
        cpf = random_cpf()

        user_in = UserCreate(email=email,
                             password=password,
                             full_name=full_name,
                             cpf=cpf)
        user = crud.user.create(db_session, obj_in=user_in)
        assert user.email == email
        assert hasattr(user, "hashed_password")
Exemple #5
0
    def test_check_if_user_is_superuser(self):
        email = random_email()
        password = random_lower_string()
        full_name = random_lower_string()
        cpf = random_cpf()

        user_in = UserCreate(
            email=email,
            password=password,
            full_name=full_name,
            cpf=cpf,
            is_superuser=True,
        )
        user = crud.user.create(db_session, obj_in=user_in)
        assert user.is_superuser
Exemple #6
0
    def test_authenticate_user(self):
        email = random_email()
        password = random_lower_string()
        full_name = random_lower_string()
        cpf = random_cpf()

        user_in = UserCreate(email=email,
                             password=password,
                             full_name=full_name,
                             cpf=cpf)
        user = crud.user.create(db_session, obj_in=user_in)
        authenticated_user = crud.user.authenticate(db_session,
                                                    email=email,
                                                    password=password)
        assert authenticated_user
        assert user.id == authenticated_user.id
Exemple #7
0
def payload_admin_user():
    return json.dumps({
        "full_name": random_lower_string(),
        "email": random_email(),
        "password": random_lower_string(),
    })