Ejemplo n.º 1
0
def test_task3_term() -> None:
    contract = TermContract(datetime.date(2017, 1, 1),
                            datetime.date(2018, 1, 1))
    bill = Bill()
    contract.new_month(1, 2017, bill)
    assert bill.get_cost() == pytest.approx(320)
    contract.bill_call(gen_call(20 * 60))
    assert bill.get_cost() == pytest.approx(320)
    contract.bill_call(gen_call(20 * 60))
    assert bill.get_cost() == pytest.approx(320)
    contract.bill_call(gen_call(70 * 60))
    assert bill.get_cost() == pytest.approx(321)
    contract.bill_call(gen_call(100 * 60))
    assert bill.get_cost() == pytest.approx(331)

    bill = Bill()
    contract.new_month(2, 2017, bill)
    assert bill.get_cost() == pytest.approx(20)
    contract.bill_call(gen_call(150 * 60))
    assert bill.get_cost() == pytest.approx(25)

    assert contract.cancel_contract() == pytest.approx(25)

    contract = TermContract(datetime.date(2017, 1, 1),
                            datetime.date(2017, 2, 1))
    contract.new_month(1, 2017, Bill())
    contract.new_month(2, 2017, Bill())
    assert contract.cancel_contract() == pytest.approx(-280)
Ejemplo n.º 2
0
 def test_cancel_contract_after_end(self):
     """ Test that if a contract is cancelled after its end date, the
     deposit is returned.
     """
     tc = TermContract(datetime.date(2000, 9, 29),
                       datetime.date(2007, 9, 29))
     # go to first month after contract
     tc.new_month(month=10, year=2007, bill=Bill())
     cancel = tc.cancel_contract()
     # check that the deposit has been returned
     self.assertAlmostEqual(cancel, TERM_MONTHLY_FEE - TERM_DEPOSIT)
Ejemplo n.º 3
0
 def test_cancel_contract_before_end(self):
     """ Test that if a contract is cancelled before its end date, the
     deposit is forfeited.
     """
     tc = TermContract(datetime.date(2000, 9, 29),
                       datetime.date(2007, 9, 29))
     # go to last month of contract (contract not over, but almost!)
     tc.new_month(month=9, year=2007, bill=Bill())
     cancel = tc.cancel_contract()
     # check that the deposit has been forfeited
     self.assertAlmostEqual(cancel, TERM_MONTHLY_FEE)