Exemple #1
0
def test_attendee_wait_time():
    att_1 = Attendee(.5, 0.3, .25, .5, 1)
    att_2 = Attendee(.5, 0.3, .25, .5, 2, time_entered=5)
    att_3 = Attendee(.5, 0.3, .25, .5, 3, time_entered=25)

    assert att_1.calc_total_wait(15) == 15
    assert att_2.calc_total_wait(35) == 30
    assert att_3.calc_total_wait(70) == 45
Exemple #2
0
def test_to_dict():
    """
    test to make sure attendee object is getting converted to dict properly
    :return: None
    """
    a = Attendee(.5, 0.3, .25, .5, 1)
    a.calc_total_wait(550)
    d = a.to_dict()
    assert isinstance(d, dict)
    assert isinstance(a, Attendee)
    assert d['total_wait'] == a.total_wait
    assert d['has_bag'] == a.has_bag
Exemple #3
0
def test_attendee_is_at_checkpoint():
    att_1 = Attendee(.5, 0.3, .25, .5, 1)
    check_1 = Checkpoint([], location=(6, 8))
    att_1.find_checkpoint([check_1], 0)
    print("Time it takes attendee to make it to checkpoint: "\
         + str(att_1.get_time_step_to_enqueue()))
    att_1.update(att_1.get_time_step_to_enqueue(),
                 att_1.get_time_step_to_enqueue)
    assert att_1.current_location == check_1.get_location()
    assert check_1.get_line_length() == 1
Exemple #4
0
def get_test_attendees():
    """
    test attendees for bag_check testing
    :return: list of Attendees with bags
    """
    attendees = [Attendee(.5, 0.3, .25, .5, i) for i in range(10)]
    for attendee in attendees:
        attendee.has_bag = True
    return attendees
def get_test_attendees_with_bags():
    """
    get 10 ten test attendees every other has a bag
    :return: list of Attendees
    """
    attendees = [Attendee(.5, 0.3, .25, .5, i) for i in range(10)]
    for i in range(0, len(attendees), 2):
        attendees[i].has_bag = True
    return attendees
Exemple #6
0
 def spawn_attendee(self, current_time_step, current_id_num,
                    current_num_attendees, current_time):
     """
     Called at each timestep at a Spawnpoint to spawn between 0 and self.max_spawn attendees. 
     If an attendee is spawned, there is another chance that more than one will be spawned.
     :param current_time_step: The current timestep of the simulation. This will be the simulation 
                               time for all attendees spawned in this call of the method
     :param current_id_num:passed in most current attendee id being used 
     :param current_num_attendees:passed in most current number of attendees 
     :param current_time:passed in the current time step                         
     """
     num_to_spawn = 0
     spawned_attendies = []
     if (current_time < self.max_time / 2):
         self.first_half()
     elif (current_time > self.max_time / 2):
         self.second_half()
     if rand.random() < self.spawn_chance:
         if rand.random() < self.spawn_more_than_one_chance:
             num_to_spawn = rand.randint(2, self.max_spawn)
         else:
             num_to_spawn = 1
         print("num spawned =", num_to_spawn)
         if num_to_spawn + current_num_attendees > self.total_attendees:
             num_to_spawn = self.total_attendees - current_num_attendees
         for i in range(num_to_spawn):
             current_id_num = current_id_num + 1
             enter_ye = Attendee(
                 self.attendee_gender_per,
                 self.attendee_metal_mean,
                 self.attendee_metal_std_dev,
                 self.attendee_coop_chance,
                 attendee_id=current_id_num,
                 current_location=self.location,
                 time_entered=current_time_step,
                 has_bag=rand.randint(0, 2),
             )
             print("attendee_id =", current_id_num)
             spawned_attendies.append(enter_ye)
     return spawned_attendies, num_to_spawn, current_id_num
def test_attendee_assignment():
    attendee = Attendee(.5, 0.3, .25, .5, 10)
    agent = SecurityAgent('BAG_CHECK', gender='F')
    assert agent.assigned_attendee is None
    agent.set_attendee(attendee)
    assert agent.get_attendee() is attendee
def get_test_attendees():
    attendees = [Attendee(.5, 0.3, .25, .5, i) for i in range(5)]

    return attendees
def get_test_attendees():
    """
    test attendees for checkpoint testing
    :return: list of Attendees
    """
    return [Attendee(.5, 0.3, .25, .5, i) for i in range(10)]
Exemple #10
0
def test_attendee_find_checkpoint():
    att_1 = Attendee(.5, 0.3, .25, .5, 1)
    att_2 = Attendee(.5, 0.3, .25, .5, 2, current_location=(0, 5))
    att_3 = Attendee(.5, 0.3, .25, .5, 3, current_location=(5, 7))

    check_1 = Checkpoint([])
    check_2 = Checkpoint([], location=(0, 6))
    check_3 = Checkpoint([], location=(4, 7))

    checkpoints = [check_1, check_2, check_3]
    att_1.find_checkpoint(checkpoints, 0)
    att_2.find_checkpoint(checkpoints, 0)
    att_3.find_checkpoint(checkpoints, 0)

    assert att_1.checkpoint_target is check_1
    assert att_2.checkpoint_target is check_2
    assert att_3.checkpoint_target is check_3