def testAddRidersIntoVehicle(self):
     try:
         d1 = Driver("V0", 23)
         r1 = Rider("R1", 0, 7, 1, 10, 20, 1, 1, 2, 1)  # 0
         r2 = Rider("R2", 0, 7, 3, 10, 20, 1, 1, 2, 1)
         r3 = Rider("R3", 0, 7, 77, 10, 20, 1, 1, 2, 1)
         r4 = Rider("R4", 0, 7, 6, 10, 20, 1, 1, 2, 1)
         riders = {"R1": r1, "R2": r2, "R3": r3, "R4": r4}
         d1.setRiders(riders)
         self.assertEqual(r1, d1.getRider("R1"))
         self.assertEqual(r2, d1.getRider("R2"))
         self.assertEqual(r3, d1.getRider("R3"))
         self.assertEqual(r4, d1.getRider("R4"))
         d1.getRider("R5")
         self.fail("Expected exception here.")
     except:
         pass
    def testCalcTripEffortSuccess(self):
        d1 = Driver("V0", 23)
        Driver.timestamp = 20
        r1 = Rider("R1", 0, 7, 1, 10, 20, 1, 1, 2, 1)  # 0
        r2 = Rider("R2", 0, 7, 3, 10, 20, 1, 1, 2, 1)
        r3 = Rider("R3", 0, 7, 77, 10, 20, 1, 1, 2, 1)
        r4 = Rider("R4", 0, 7, 6, 10, 20, 1, 1, 2, 1)
        riders = {"R1": r1, "R2": r2, "R3": r3, "R4": r4}
        d1.setRiders(riders)
        d1.calcTripRoute()
        d1.calcTripEffort()

        elem1 = d1.popTripRoute()
        self.assertEqual(22, elem1.getEventTime())

        elem2 = d1.popTripRoute()
        self.assertEqual(23, elem2.getEventTime())
        rider1 = d1.getRider(elem2.getRiderID())
        self.assertEqual(23, rider1.getArrivalTimestamp())
        self.assertEqual(2, rider1.getDetourTime())

        elem3 = d1.popTripRoute()
        self.assertEqual(24, elem3.getEventTime())
        rider2 = d1.getRider(elem3.getRiderID())
        self.assertEqual(24, rider2.getArrivalTimestamp())
        self.assertEqual(2, rider2.getDetourTime())

        elem4 = d1.popTripRoute()
        self.assertEqual(25, elem4.getEventTime())
        rider3 = d1.getRider(elem4.getRiderID())
        self.assertEqual(25, rider3.getArrivalTimestamp())
        self.assertEqual(2, rider3.getDetourTime())

        elem5 = d1.popTripRoute()
        self.assertEqual(26, elem5.getEventTime())
        rider4 = d1.getRider(elem5.getRiderID())
        self.assertEqual(26, rider4.getArrivalTimestamp())
        self.assertEqual(2, rider4.getDetourTime())

        self.assertEqual(6, d1.getTripEffort())