Exemplo n.º 1
0
def test_price_calculation_4_hours_6_22():
    now = datetime.datetime.now()
    start = now.replace(hour=16, minute=56, second=0)
    end = start + datetime.timedelta(hours=4)

    price = calculate_price(start, end)

    assert price == standing_charge + (4 * 60 * charge_6_22)
Exemplo n.º 2
0
def test_price_calculation_less_1_minutes_6_22():
    now = datetime.datetime.now()
    start = now.replace(hour=15, minute=35, second=20)
    end = start + datetime.timedelta(seconds=46)

    price = calculate_price(start, end)

    assert price == standing_charge
Exemplo n.º 3
0
def test_price_calculation_05_59_to_06_01():
    now = datetime.datetime.now()
    start = now.replace(hour=5, minute=59, second=0)
    end = start + datetime.timedelta(minutes=2)

    price = calculate_price(start, end)

    assert price == standing_charge + charge_22_6 + charge_6_22
Exemplo n.º 4
0
def test_price_calculation_various_days():
    now = datetime.datetime.now()
    start = now.replace(hour=0, minute=0, second=0)
    end = start + datetime.timedelta(days=2, hours=10, minutes=6)

    price = calculate_price(start, end)

    assert price == standing_charge + (2 * 8 * 60 * charge_22_6) + (
        2 * 16 * 60 * charge_6_22) + (6 * 60 * charge_22_6) + (
            4 * 60 * charge_6_22) + (6 * charge_6_22)
Exemplo n.º 5
0
 def save(self, *args, **kwargs):
     self.price = calculate_price(self.start, self.end)
     self.full_clean()
     super(BillInformation, self).save(*args, **kwargs)