示例#1
0
def payload_normal_user():
    return json.dumps({
        "full_name": random_lower_string(),
        "email": random_email(),
        "password": random_lower_string(),
        "cpf": random_cpf(),
    })
示例#2
0
def payload_new_order():
    return {
        "code": random_lower_string(),
        "value": "100",
        "date": "2020-04-18",
        "cpf": random_cpf(),
    }
示例#3
0
    def test_error_create_order_without_reseller(self):
        code = random_lower_string()
        date = datetime.date.today()
        value = 343.11
        cpf = random_cpf()

        order_in = OrderCreate(code=code, date=date, value=value, cpf=cpf)
        with pytest.raises(IntegrityError):
            crud.order.create_with_reseller(db_session, obj_in=order_in)
示例#4
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)
示例#5
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")
示例#6
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
示例#7
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