예제 #1
0
    def test_id_increments(self):
        sample_bank = b.Bank()
        cust = c.Customer(sample_bank)
        arrival1 = e.CustomerArrivalEvent(1, cust)
        arrival2 = e.CustomerArrivalEvent(1, cust)

        assert arrival2.get_id() == arrival1.get_id() + 1
예제 #2
0
    def test_filter_by_type_returns_none(self):
        bank = b.Bank()
        cust = c.Customer(bank)

        e1 = e.CustomerArrivalEvent(1, cust)
        e2 = e.CustomerArrivalEvent(1, cust)
        e_list = [e1, e2]

        rec = er.EventRecord(e_list)

        filtered_rec = rec.filter_by_type(e.CustomerServiceEvent)
        assert filtered_rec.get_event_list() == []
예제 #3
0
    def test_filter_by_type_with_mixed_events(self):
        bank = b.Bank()
        cust = c.Customer(bank)

        e1 = e.CustomerArrivalEvent(1, cust)
        e2 = e.CustomerArrivalEvent(1, cust)
        e3 = e.CustomerDepartureEvent(3, cust)
        e_list = [e1, e2, e3]

        rec = er.EventRecord(e_list)

        filtered_rec = rec.filter_by_type(e.CustomerArrivalEvent)
        assert filtered_rec.get_event_list() == [e1, e2]
예제 #4
0
    def __init__(self, bank, service_time=1):
        """Constructing the customer should send the bank an Event"""
        # Most of these assignments are null
        self._id = self.__class__.current_id
        self.__class__.current_id += 1

        self._service_time = service_time

        self._bank = bank
        self._arrival_time = self._time()

        self._time_reached_teller = None
        self._departure_time = None
        self._time_at_teller = 0

        self._teller = None

        arrival_event = e.CustomerArrivalEvent(self, self._arrival_time)
        self._bank.save_event(arrival_event)