Esempio n. 1
0
def test_task3_MTM() -> None:
    # MTM Contracts
    contract = MTMContract(datetime.date(2017, 2, 15))
    bill = Bill()
    contract.new_month(3, 2017, bill)
    assert bill.get_cost() == pytest.approx(50.0)
    contract.bill_call(gen_call(10))
    assert bill.get_cost() == pytest.approx(50.05)
    contract.bill_call(gen_call(50))
    assert bill.get_cost() == pytest.approx(50.1)
    bill = Bill()
    contract.new_month(4, 2017, bill)
    assert bill.get_cost() == pytest.approx(50.0)
    assert contract.cancel_contract() == pytest.approx(50.0)
Esempio n. 2
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)