def payload_normal_user(): return json.dumps({ "full_name": random_lower_string(), "email": random_email(), "password": random_lower_string(), "cpf": random_cpf(), })
def payload_new_order(): return { "code": random_lower_string(), "value": "100", "date": "2020-04-18", "cpf": random_cpf(), }
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)
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)
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")
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
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