Example #1
0
def test_register_over_capacity() -> None:
    """Add too many people to a room"""
    ac = Gym('Athletic Centre')
    diane = Instructor(1, 'Diane')
    assert diane.add_certificate('Cardio 1')
    assert ac.add_instructor(diane)
    assert ac.add_room('Dance Studio', 1)
    boot_camp = WorkoutClass('Boot Camp', ['Cardio 1'])
    assert ac.add_workout_class(boot_camp)
    sep_9_2019_12_00 = datetime(2019, 9, 9, 12, 0)
    assert ac.schedule_workout_class(sep_9_2019_12_00, 'Dance Studio', \
                                     boot_camp.get_name(), diane.get_id())
    assert ac.register(sep_9_2019_12_00, 'Greg', 'Boot Camp')
    assert ac.register(sep_9_2019_12_00, 'Tim', 'Boot Camp') is False
Example #2
0
def test_register_one_person() -> None:
    """Register one person to one workout class"""
    ac = Gym('Athletic Centre')
    diane = Instructor(1, 'Diane')
    assert diane.add_certificate('Cardio 1')
    assert ac.add_instructor(diane)
    assert ac.add_room('Dance Studio', 50)
    boot_camp = WorkoutClass('Boot Camp', ['Cardio 1'])
    assert ac.add_workout_class(boot_camp)
    sep_9_2019_12_00 = datetime(2019, 9, 9, 12, 0)
    assert ac.schedule_workout_class(sep_9_2019_12_00, 'Dance Studio', \
                                   boot_camp.get_name(), diane.get_id())
    assert ac.register(sep_9_2019_12_00, 'Philip', 'Boot Camp')
    assert ac.register(sep_9_2019_12_00, 'Tim', 'Boot Camp') is True
Example #3
0
def test_gym_register_everything() -> None:
    ac = Gym('Athletic Centre')
    diane = Instructor(1, 'Diane')
    dian = Instructor(2, 'Dian')
    assert diane.add_certificate('Cardio 1')
    assert dian.add_certificate('Cardio 1')
    assert ac.add_instructor(diane)
    assert ac.add_instructor(dian)

    assert ac.add_room('Dance Studio', 3)
    assert ac.add_room('Danc Studio', 3)

    boot_camp = WorkoutClass('Boot Camp', ['Cardio 1'])
    assert ac.add_workout_class(boot_camp)

    sep_9_2019_12_00 = datetime(2019, 9, 9, 12, 0)
    sep_9_2019_13_00 = datetime(2019, 9, 9, 13, 0)
    assert ac.schedule_workout_class(sep_9_2019_12_00, 'Dance Studio', \
                                     boot_camp.get_name(), diane.get_id())
    assert ac.schedule_workout_class(sep_9_2019_12_00, 'Danc Studio', \
                                     boot_camp.get_name(), dian.get_id())

    assert ac.register(sep_9_2019_12_00, 'Philip', 'Boot Camp')
    assert ac.register(datetime(2019, 9, 9, 11, 0), 'Philip', 'Boot Camp') is False
    assert ac.register(sep_9_2019_12_00, 'Philip', 'Boot Camp') is False
    assert ac.register(sep_9_2019_12_00, 'test', 'Boot Camp')
    assert ac.register(sep_9_2019_12_00, 'tes', 'Boot Camp')
    assert ac.register(sep_9_2019_12_00, 'te', 'Boot Camp')
    assert ac.register(sep_9_2019_12_00, 'tes', 'Boot Camp') is False

    assert ac._schedule == {sep_9_2019_12_00:
        {'Dance Studio': (diane, boot_camp, ['Philip', 'test', 'tes']),
         'Danc Studio': (dian, boot_camp, ['te'])}}

    assert ac.register(sep_9_2019_12_00, 'ts', 'Boot Camp')
    assert ac.register(sep_9_2019_12_00, 't', 'Boot Camp')
    assert ac.register(sep_9_2019_12_00, 'z', 'Boot Camp') is False
    assert ac._schedule == {sep_9_2019_12_00:
        {'Dance Studio': (diane, boot_camp, ['Philip', 'test', 'tes']),
         'Danc Studio': (dian, boot_camp, ['te', 'ts', 't'])}}

    assert ac.schedule_workout_class(sep_9_2019_13_00, 'Danc Studio', \
                                     boot_camp.get_name(), dian.get_id())
    assert ac.register(sep_9_2019_13_00, 'a', 'Boot Camp')

    assert ac._schedule == {sep_9_2019_12_00:
        {'Dance Studio': (diane, boot_camp, ['Philip', 'test', 'tes']),
         'Danc Studio': (dian, boot_camp, ['te', 'ts', 't'])},
          sep_9_2019_13_00: {'Danc Studio': (dian, boot_camp, ['a'])}}
Example #4
0
def test_register_two_diff_person_diff_room() -> None:
    """Register 2 diff people to same workout class, diff room, same time"""
    ac = Gym('Athletic Centre')
    diane = Instructor(1, 'Diane')
    assert diane.add_certificate('Cardio 1')
    assert ac.add_instructor(diane)
    assert ac.add_room('Dance Studio', 50)
    assert ac.add_room('Bike Studio', 5)
    boot_camp = WorkoutClass('Boot Camp', ['Cardio 1'])
    assert ac.add_workout_class(boot_camp)
    sep_9_2019_12_00 = datetime(2019, 9, 9, 12, 0)
    assert ac.schedule_workout_class(sep_9_2019_12_00, 'Dance Studio', \
                                   boot_camp.get_name(), diane.get_id())
    assert ac.schedule_workout_class(sep_9_2019_12_00, 'Bike Studio', \
                                     boot_camp.get_name(), diane.get_id())\
                                     is False
    assert ac.register(sep_9_2019_12_00, 'Greg', 'Boot Camp')
    assert ac.register(sep_9_2019_12_00, 'Greg', 'Boot Camp') is False
    assert ac.register(sep_9_2019_12_00, 'Tim', 'Boot Camp')
    assert ac.register(sep_9_2019_12_00, 'Tim', 'Boot Camp') is False
Example #5
0
def test_register_no_room_left_with_that_class_JEN() -> None:
    ac = Gym('Athletic Centre')
    instructor = Instructor(5, 'Matthew')
    instructor2 = Instructor(15, 'Jennifer')
    swimming = WorkoutClass('Swimming', ['Lifeguard'])
    crossfit = WorkoutClass('Cross Fit', ['Cross Fit'])
    jan_28_2020_11_00 = datetime(2020, 1, 29, 11, 0)
    assert instructor.add_certificate('Lifeguard')
    assert instructor2.add_certificate('Cross Fit')
    assert ac.add_workout_class(swimming)
    assert ac.add_workout_class(crossfit)
    assert ac.add_instructor(instructor)
    assert ac.add_instructor(instructor2)
    assert ac.add_room('25-yard Pool', 1)
    assert ac.add_room('Weight Room', 1)
    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.register(jan_28_2020_11_00, 'Benjamin', 'Swimming')
    assert not ac.register(jan_28_2020_11_00, 'Eric', 'Swimming')
Example #6
0
def test_gym_register_one_class() -> None:
    """Test Gym.register with a single user and class."""
    ac = Gym('Athletic Centre')
    instructor = Instructor(5, 'Matthew')
    swimming = WorkoutClass('Swimming', ['Lifeguard'])
    jan_28_2020_11_00 = datetime(2020, 1, 29, 11, 0)
    assert instructor.add_certificate('Lifeguard')
    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())
    assert ac.register(jan_28_2020_11_00, 'Benjamin', 'Swimming')
Example #7
0
def test_register() -> None:
    gc = Gym("Gold Ring")
    diane = Instructor(1, 'Diane')
    roney = Instructor(2, 'Roney')
    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)
    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())
    # Testing if we can register a new client,
    # if the instructor is not qualified
    assert gc.register(JAN_27_2020, 'Philip', 'Running') is False
    diane.add_certificate('Strength Training')
    diane.add_certificate('Interval Training')
    diane.add_certificate('Long Runs')
    diane.add_certificate('Tempo')
    diane.add_certificate('FTP Test')
    gc.schedule_workout_class(JAN_27_2020, 'Strength Room',
                              workout_class_run.get_name(), diane.get_id())
    assert gc.register(JAN_27_2020, 'Philip', 'Running') is True
    # Testing if we can register a already registered client
    assert gc.register(JAN_27_2020, 'Philip', 'Running') is False
    # Testing if we can register a already registered client to different class
    assert gc.register(JAN_27_2020, 'Philip', 'Cycling Basics') is False
    # Testing if we can register to already full class
    assert gc.register(JAN_27_2020, 'Roth', 'Running') is False
    assert gc.register(JAN_27_2020, 'Roth', 'Cycling Basics') is False