def create_absence_for_user(employee: Employee,
                            time_off_type: AbsenceType = None,
                            start_date: date = None,
                            end_date: date = None,
                            half_day_start: bool = False,
                            half_day_end: bool = False,
                            comment: str = None,
                            create: bool = False) -> Absence:
    if not time_off_type:
        absence_types = personio.get_absence_types()
        time_off_type = [
            absence_type for absence_type in absence_types
            if absence_type.name == "Unpaid vacation"
        ][0]
    if not start_date:
        start_date = date(2021, 1, 1)
    if not end_date:
        end_date = date(2021, 1, 10)

    absence_to_create = Absence(start_date=start_date,
                                end_date=end_date,
                                time_off_type=time_off_type,
                                employee=employee,
                                half_day_start=half_day_start,
                                half_day_end=half_day_end,
                                comment=comment)
    if create:
        absence_to_create.create(personio)
    return absence_to_create
def test_create_absence():
    mock_absence_types()
    mock_create_absence_no_halfdays()
    personio = mock_personio()
    absence_type = personio.get_absence_types()[0]
    employee = Employee(first_name="Alan",
                        last_name='Turing',
                        email='*****@*****.**')
    absence = Absence(client=personio,
                      employee=employee,
                      start_date=date(2020, 1, 1),
                      end_date=date(2020, 1, 10),
                      half_day_start=False,
                      half_day_end=False,
                      time_off_type=absence_type)
    absence.create()
    assert absence.id_