예제 #1
0
def test_gym_payroll_everything() -> None:
    ac = Gym('Athletic Centre')
    diane = Instructor(1, 'Diane')
    david = Instructor(2, 'David')

    assert diane.add_certificate('Cardio 1')
    assert diane.add_certificate('test')
    assert david.add_certificate('Cardio 1')
    assert ac.add_instructor(diane)
    assert ac.add_instructor(david)

    assert ac.add_room('Dance Studio', 50)
    assert ac.add_room('Danc Studio', 50)
    boot_camp = WorkoutClass('Boot Camp', ['Cardio 1'])
    assert ac.add_workout_class(boot_camp)
    t1 = datetime(2019, 9, 9, 12, 0)
    t2 = datetime(2019, 9, 10, 12, 0)
    t3 = datetime(2019, 9, 8, 12, 0)
    t4 = datetime(2019, 9, 11, 12, 0)

    assert ac.payroll(t1, t2, 25.0) == [(1, 'Diane', 0, 0.0),
                                        (2, 'David', 0, 0.0)]

    assert ac.instructor_hours(t1, t2) == {1: 0, 2: 0}
    assert ac.schedule_workout_class(t1, 'Dance Studio', boot_camp.get_name(), 1)
    assert ac.instructor_hours(t1, t2) == {1: 1, 2: 0}
    assert ac.schedule_workout_class(t2, 'Dance Studio', boot_camp.get_name(), 2)
    assert ac.instructor_hours(t1, t2) == {1: 1, 2: 1}
    assert ac.schedule_workout_class(t3, 'Dance Studio', boot_camp.get_name(), 1)
    assert ac.schedule_workout_class(t4, 'Dance Studio', boot_camp.get_name(), 1)
    assert ac.instructor_hours(t1, t2) == {1: 1, 2: 1}

    assert ac.payroll(t1, t2, 25.0) == [(1, 'Diane', 1, 28.0),
                                        (2, 'David', 1, 26.5)]
    assert diane.add_certificate('tst')
    assert diane.add_certificate('tet')
    assert ac.payroll(t1, t2, 25.0) == [(1, 'Diane', 1, 31.0),
                                        (2, 'David', 1, 26.5)]

    d = Instructor(5, 'Davi')
    assert d.add_certificate('Cardio 1')
    assert ac.add_instructor(d)
    assert ac.schedule_workout_class(t3, 'Danc Studio', boot_camp.get_name(), 5)
    assert ac.instructor_hours(t3, t4) == {1: 3, 2: 1, 5: 1}
    assert ac.payroll(t3, t4, 25.0) == [(1, 'Diane', 3, 93.0),
                                        (2, 'David', 1, 26.5),
                                        (5, 'Davi', 1, 26.5)]
    e = Instructor(4, 'Dav')
    assert e.add_certificate('Cardio 1')
    assert e.add_certificate('Cardio')
    assert ac.add_instructor(e)
    assert ac.schedule_workout_class(t4, 'Danc Studio', boot_camp.get_name(), 4)
    assert ac.payroll(t3, t4, 25.0) == [(1, 'Diane', 3, 93.0),
                                        (2, 'David', 1, 26.5),
                                        (4, 'Dav', 1, 28.0),
                                        (5, 'Davi', 1, 26.5)]
예제 #2
0
def test_gym_many_instructors_mixed_hours_mixed_certificates_JEN() -> None:
    ac = Gym('Athletic Centre')
    instructor = Instructor(5, 'Matthew')
    instructor2 = Instructor(12, 'Jennifer')
    swimming = WorkoutClass('Swimming', [])
    crossfit = WorkoutClass('Cross Fit', ['Cross Fit'])
    jan_28_2020_11_00 = datetime(2020, 1, 29, 11, 0)
    jan_28_2020_12_00 = datetime(2020, 1, 29, 12, 0)
    assert ac.add_workout_class(swimming)
    assert ac.add_workout_class(crossfit)
    assert ac.add_instructor(instructor)
    assert ac.add_instructor(instructor2)
    assert instructor2.add_certificate('Cross Fit')
    assert ac.add_room('25-yard Pool', 100)
    assert ac.add_room('Weight Room', 50)
    assert ac.schedule_workout_class(jan_28_2020_11_00, '25-yard Pool',
                                     swimming.get_name(), instructor.get_id())
    assert ac.schedule_workout_class(jan_28_2020_11_00, 'Weight Room',
                                     crossfit.get_name(), instructor2.get_id())
    assert ac.schedule_workout_class(jan_28_2020_12_00, 'Weight Room',
                                     crossfit.get_name(), instructor2.get_id())
    t1 = datetime(2020, 1, 17, 11, 0)
    t2 = datetime(2020, 1, 29, 13, 0)
    assert ac.payroll(t1, t2, 22.0) == [(5, 'Matthew', 1, 22.0),
                                        (12, 'Jennifer', 2, 47.0)]
예제 #3
0
def test_gym_one_instructor_one_hour_pay_no_certificates() -> None:
    ac = Gym('Athletic Centre')
    instructor = Instructor(5, 'Matthew')
    swimming = WorkoutClass('Swimming', [])
    jan_28_2020_11_00 = datetime(2020, 1, 29, 11, 0)
    assert ac.add_workout_class(swimming)
    assert ac.add_instructor(instructor)
    assert ac.add_room('25-yard Pool', 100)
    assert ac.schedule_workout_class(jan_28_2020_11_00, '25-yard Pool',
                                     swimming.get_name(), instructor.get_id())
    t1 = datetime(2020, 1, 17, 11, 0)
    t2 = datetime(2020, 1, 29, 13, 0)
    assert ac.payroll(t1, t2, 22.0) == [(5, 'Matthew', 1, 22)]
예제 #4
0
def test_payroll():
    gc = Gym("Gold Ring")
    diane = Instructor(1, 'Diane')
    roney = Instructor(2, 'Roney')
    diane.add_certificate('Strength Training')
    diane.add_certificate('Interval Training')
    diane.add_certificate('Long Runs')
    diane.add_certificate('Tempo')
    diane.add_certificate('FTP Test')
    roney.add_certificate('Strength Training')
    roney.add_certificate('Interval Training')
    roney.add_certificate('Tempo')
    workout_class_run = WorkoutClass('Running', [
        'Strength Training', 'Interval Training', 'Long Runs', 'Tempo',
        'FTP Test'
    ])
    workout_class_cycling = WorkoutClass(
        'Cycling Basics', ['Strength Training', 'Interval Training', 'Tempo'])
    gc.add_workout_class(workout_class_run)
    gc.add_workout_class(workout_class_cycling)
    gc.add_instructor(diane)
    gc.add_instructor(roney)
    JAN_27_2020 = datetime(2020, 1, 27, 12, 0)
    JAN_28_2020 = datetime(2020, 1, 28, 12, 0)
    assert gc.instructor_hours(JAN_27_2020, JAN_28_2020) == {1: 0, 2: 0}
    gc.add_room('Cycling Room', 1)
    gc.add_room('Strength Room', 1)
    gc.schedule_workout_class(JAN_27_2020, 'Strength Room',
                              workout_class_run.get_name(), diane.get_id())
    gc.schedule_workout_class(JAN_27_2020, 'Cycling Room',
                              workout_class_cycling.get_name(), roney.get_id())
    assert gc.instructor_hours(JAN_27_2020, JAN_28_2020) == {1: 1, 2: 1}
    gc.schedule_workout_class(JAN_28_2020, 'Strength Room',
                              workout_class_run.get_name(), diane.get_id())
    assert gc.instructor_hours(JAN_27_2020, JAN_28_2020) == {1: 2, 2: 1}
    assert (1, 'Diane', 2, 65.0) in gc.payroll(JAN_27_2020, JAN_28_2020, 25.0)
    assert (2, 'Roney', 1, 29.5) in gc.payroll(JAN_27_2020, JAN_28_2020, 25.0)