def testDualTarifEnergyCostWithTwoYears_GetVariousDates_ExpectedValueReturnedOrRaise(self): cost = energycost.EnergyCost() energyCostHigh = 0.2 energyCostLow = 0.1 energyCostHighNextYear = 0.3 energyCostLowNextYear = 0.2 highWeekdays = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'] highTarifHours = (datetime.time(hour=7, minute=0), datetime.time(hour=18, minute=59, second=59)) cost.setDualTariffEnergyCost(energyCostHigh, highWeekdays, highTarifHours[0], highTarifHours[1], energyCostLow, self.validFrom, self.validTo) cost.setDualTariffEnergyCost(energyCostHighNextYear, highWeekdays, highTarifHours[0], highTarifHours[1], energyCostLowNextYear, self.validFromNextYear, self.validToNextYear) self.assertEqual(energyCostHigh, cost.getEnergyCost(self.validTestDate)) self.assertEqual(energyCostHighNextYear, cost.getEnergyCost(self.validTestDateNextYear))
def testConstantEnergyRefund_GetVariousDates_ExpectedValueReturnedOrRaise(self): cost = energycost.EnergyCost() energyRefund = 0.2 cost.setConstantEnergyRefundPerKWh(energyRefund, self.validFrom, self.validTo) self.assertEqual(energyRefund, cost.getEnergyRefund(self.validTestDate)) self.assertEqual(energyRefund, cost.getEnergyRefund(self.validTestDateDifferentWeekDay)) self.assertRaises(RuntimeError, cost.getEnergyRefund, self.invalidTestDateBefore) self.assertRaises(RuntimeError, cost.getEnergyRefund, self.invalidTestDateAfter) self.assertRaises(RuntimeError, cost.getEnergyRefund, self.invalidTestOnEdgeBefore) self.assertEqual(energyRefund, cost.getEnergyRefund(self.validTestOnEdge)) self.assertEqual(energyRefund, cost.getEnergyRefund(self.validTestOnEdge2))
def testDualTarifEnergyCost_GetVariousDates_ExpectedValueReturnedOrRaise(self): cost = energycost.EnergyCost() energyCostHigh = 0.2 energyCostLow = 0.1 highWeekdays = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'] highTarifHours = (datetime.time(hour=7, minute=0), datetime.time(hour=18, minute=59, second=59)) cost.setDualTariffEnergyCost(energyCostHigh, highWeekdays, highTarifHours[0], highTarifHours[1], energyCostLow, self.validFrom, self.validTo) self.assertEqual(energyCostHigh, cost.getEnergyCost(self.validTestDate)) self.assertEqual(energyCostHigh, cost.getEnergyCost(self.validTestDateDifferentWeekDay)) self.assertRaises(RuntimeError, cost.getEnergyCost, self.invalidTestDateBefore) self.assertRaises(RuntimeError, cost.getEnergyCost, self.invalidTestDateAfter) self.assertRaises(RuntimeError, cost.getEnergyCost, self.invalidTestOnEdgeBefore) self.assertEqual(energyCostLow, cost.getEnergyCost(self.validTestOnEdge)) self.assertEqual(energyCostLow, cost.getEnergyCost(self.validTestOnEdge2)) self.lowTarifStart1 = datetime.datetime(year = 2019, month = 11, day = 21, hour = 0, minute = 0, second = 0) self.assertEqual(energyCostLow, cost.getEnergyCost(self.lowTarifStart1)) self.lowTarifEnd1 = datetime.datetime(year = 2019, month = 11, day = 21, hour = 6, minute = 59, second = 59) self.assertEqual(energyCostLow, cost.getEnergyCost(self.lowTarifEnd1)) self.highTarifStart = datetime.datetime(year = 2019, month = 11, day = 21, hour = 7, minute = 0, second = 0) self.assertEqual(energyCostHigh, cost.getEnergyCost(self.highTarifStart)) self.highTarifEnd = datetime.datetime(year = 2019, month = 11, day = 21, hour = 18, minute = 59, second = 59) self.assertEqual(energyCostHigh, cost.getEnergyCost(self.highTarifEnd)) self.lowTarifStart2 = datetime.datetime(year = 2019, month = 11, day = 21, hour = 19, minute = 0, second = 0) self.assertEqual(energyCostLow, cost.getEnergyCost(self.lowTarifStart2)) self.lowTarifEnd2 = datetime.datetime(year = 2019, month = 11, day = 21, hour = 23, minute = 59, second = 59) self.assertEqual(energyCostLow, cost.getEnergyCost(self.lowTarifEnd2)) for h in range(0, 23): self.lowTarifWeekend = datetime.datetime(year = 2019, month = 11, day = 24, hour = h, minute = 0, second = 0) self.assertEqual(energyCostLow, cost.getEnergyCost(self.lowTarifWeekend))
def setUp(self): self.energyTypes = ['', '', 'FeedIn', 'Purchased'] self.energyCostHigh = 0.2526 self.energyCostLow = 0.1901 highWeekdays = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'] highTarifHours = (datetime.time(hour=7, minute=0), datetime.time(hour=18, minute=59, second=59)) validFrom = datetime.datetime(year=2019, month=1, day=1) validTo = datetime.datetime(year=2019, month=12, day=31, hour=23, minute=59, second=59) cost = energycost.EnergyCost() cost.setDualTariffEnergyCost(self.energyCostHigh, highWeekdays, highTarifHours[0], highTarifHours[1], self.energyCostLow, validFrom, validTo) self.refund = 0.093 cost.setConstantEnergyRefundPerKWh(refund=self.refund, validFrom=validFrom, validTo=validTo) self.costCalculator = energycostcalculator.EnergyCostCalculator(cost)