def test_cancel_contract_positive_balance(self): """ Test that the balance is charged as the cancellation fee if the contract is cancelled while the balance is positive. """ pc = PrepaidContract(datetime.date(2000, 9, 29), 10) pc.new_month(month=10, year=2000, bill=Bill()) # make a call that costs $15 c1 = Call(src_nr="123-4567", dst_nr="987-6543", calltime=datetime.datetime(year=2000, month=10, day=31, hour=20, minute=30, second=0), duration=ceil(15 / PREPAID_MINS_COST * 60), src_loc=(-79.45188229255568, 43.62186408875219), dst_loc=(-79.36866519485261, 43.680793196449336)) pc.bill_call(c1) # since the call was very long, the balance should be positive now self.assertAlmostEqual(pc.balance, 5) cancel = pc.cancel_contract() # since the balance is positive, it should be billed, so the cost for # the month should be the balance self.assertAlmostEqual(cancel, pc.balance)
def test_cancel_contract_negative_balance(self): """ Test that $0 is charged as the cancellation fee if the contract is cancelled while the balance is negative (aka some credit exists). """ pc = PrepaidContract(datetime.date(2000, 9, 29), 25) pc.new_month(month=10, year=2000, bill=Bill()) self.assertAlmostEqual(pc.balance, -25) cancel = pc.cancel_contract() # since the balance is negative, it should be forfeited, so the cost for # the month should be $0 self.assertAlmostEqual(cancel, 0)