def testcalcPriceWithWrongDetourTime(self):
     try:
         r0 = Rider("R0", 0, 8, 24, 7.75, 20, -87.6333, 41.8996, -87.6764,
                    41.9012)
         r0.calcPrice(4)
         self.fail("Expected exception here.")
     except:
         pass
    def testCalcSatSuccess(self):
        #without detour time
        r0 = Rider("R0", 0, 8, 24, 7.75, 20, -87.6333, 41.8996, -87.6764,
                   41.9012)
        r0.calcDetourTime(1)
        r0.calcPrice(1)
        r0.calcSat()
        self.assertAlmostEqual(1.592, r0.getSat(), delta=0.01)

        #with detour time
        r0 = Rider("R0", 0, 8, 24, 7.75, 20, -87.6333, 41.8996, -87.6764,
                   41.9012)
        r0.calcDetourTime(2)
        r0.calcPrice(1)
        r0.calcSat()
        self.assertAlmostEqual(1.518, r0.getSat(), delta=0.01)
 def testCalcTripProfitSuccess(self):
     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)
     d1.calcTripRoute()
     d1.calcTripEffort()
     r1.calcPrice(4)
     r2.calcPrice(4)
     r3.calcPrice(4)
     r4.calcPrice(4)
     d1.calcTripProfit()
     self.assertAlmostEqual(26.0883, d1.getTripProfit(), delta=0.01)
    def testCalcPriceSuccess(self):
        r0 = Rider("R0", 0, 8, 24, 7.75, 20, -87.6333, 41.8996, -87.6764,
                   41.9012)
        r0.calcDetourTime(5)
        r0.calcPrice(1)
        self.assertAlmostEqual(6.0914, r0.getPrice(), delta=0.01)

        r0 = Rider("R0", 0, 8, 24, 7.75, 20, -87.6333, 41.8996, -87.6764,
                   41.9012)
        r0.calcDetourTime(5)
        r0.calcPrice(2)
        self.assertAlmostEqual(5.901, r0.getPrice(), delta=0.01)

        r0 = Rider("R0", 0, 8, 24, 7.75, 20, -87.6333, 41.8996, -87.6764,
                   41.9012)
        r0.calcDetourTime(5)
        r0.calcPrice(3)
        self.assertAlmostEqual(5.7107, r0.getPrice(), delta=0.01)

        r0 = Rider("R0", 0, 8, 24, 7.75, 20, -87.6333, 41.8996, -87.6764,
                   41.9012)
        r0.calcDetourTime(5)
        r0.calcPrice(4)
        self.assertAlmostEqual(5.52, r0.getPrice(), delta=0.01)