Example #1
0
def confirm_update_system_time_works_for_CheckInServer():
    # initialize the system with system_time=10.00
    mySim = tam.Simulation
    mySim.system_time = 10.00
    # create a new passenger, and add him to the queue. make sure this works.
    new_passenger = tam.Passenger(10.00, "commuter", "coach", 1, 10.00)
    my_checkin_server = tam.CheckInServer()
    my_checkin_server.add_customer(new_passenger)
    # artificially set the service time to 0.01 to make testing easier
    my_checkin_server.service_time = 0.01
    # now update the service time --> and we should be NOT busy, with service time = 0.0
    for i in range(1, 50):
        my_checkin_server.update_service_time()

    # start out true, and if any test fails... we know this doesn't work
    update_service_time_works = True

    # check that the boolean flag gets set properly
    if my_checkin_server.is_busy():
        is_busy = my_checkin_server.is_busy()
        update_service_time_works = False
    if not str(my_checkin_server.service_time) == str(0):
        service_time_after_50_ticks = my_checkin_server.service_time
        service_time_after_50_ticks_as_string = str(
            service_time_after_50_ticks)
        update_service_time_works = False

    return update_service_time_works
Example #2
0
def confirm_add_customer_to_checkin_server_works():
    # initialize the system with system_time=10.00
    mySim = tam.Simulation
    mySim.system_time = 10.00
    # create a new passenger, and add him to the queue. make sure this works.
    new_passenger = tam.Passenger(10.00, "commuter", "coach", 1, 10.00)
    my_checkin_server = tam.CheckInServer()
    my_checkin_server.add_customer(new_passenger)
    # confirm it works
    test_works = True
    if not my_checkin_server.customers_added == 1:
        test_works = False
    return test_works
Example #3
0
def confirm_add_passenger_to_security_queue_works():
    # initialize the system with system_time=10.00
    mySim = tam.Simulation
    mySim.system_time = 10.00
    # create a new passenger, and add him to the queue. make sure this works.
    new_passenger = tam.Passenger(10.00, "commuter", "coach", 1, 10.00)
    my_checkin_queue = tam.SecurityQueue()
    my_checkin_queue.add_passenger(new_passenger)

    confirm_add_works = True

    if not my_checkin_queue.customers_added == 1:
        confirm_add_works = False
    return confirm_add_works
Example #4
0
def confirm_get_passenger_from_security_queue_works():
    # initialize the system with system_time=10.00
    mySim = tam.Simulation
    mySim.system_time = 10.00
    # create a new passenger, and add him to the queue. make sure this works.
    new_passenger = tam.Passenger(10.00, "commuter", "coach", 1, 10.00)
    my_checkin_queue = tam.SecurityQueue()
    my_checkin_queue.add_passenger(new_passenger)
    # confirm we get the right passenger
    confirm_remove_works = True
    next_passenger_in_line = my_checkin_queue.get_next_passenger_in_line()
    if not next_passenger_in_line.__eq__(new_passenger):
        confirm_remove_works = False
    # confirm we DON'T get duplicates of a passenger
    should_be_NONE = my_checkin_queue.get_next_passenger_in_line()
    if not should_be_NONE is None:
        confirm_remove_works = False
    return confirm_remove_works
Example #5
0
def confirm_remove_customer_from_checkin_server_works():
    # initialize the system with system_time=10.00
    mySim = tam.Simulation
    mySim.system_time = 10.00
    # create a new passenger, and add him to the queue. make sure this works.
    new_passenger = tam.Passenger(10.00, "commuter", "coach", 1, 10.00)
    my_checkin_SERVER = tam.CheckInServer()
    my_checkin_SERVER.add_customer(new_passenger)
    # confirm we get the right passenger on removal
    confirm_remove_works = True

    # first we confirm that you CAN'T remove someone from the queue if they are still being served
    next_passenger_in_line = my_checkin_SERVER.complete_service()
    if not next_passenger_in_line is None:
        return False

    # then we confirm that you CAN remove someone from the queue if they are DONE being served
    my_checkin_SERVER.service_time = 0.01
    my_checkin_SERVER.update_service_time()
    next_passenger_in_line = my_checkin_SERVER.complete_service()
    # first make sure we didn't get a done
    if next_passenger_in_line is None:
        return False
    # then make sure we have the right passenger
    if not next_passenger_in_line.__eq__(new_passenger):
        confirm_remove_works = False

    # Finally, confirm we DON'T get duplicates of a passenger
    should_be_NONE = my_checkin_SERVER.complete_service()
    # try and pull an invalid user 20 times. approximate what may happen in the system
    for i in range(0, 10):
        if not should_be_NONE is None:
            confirm_remove_works = False

    # and return the final results of our test
    return confirm_remove_works