from jar import Jar


def main():
    test_capacity()
    test_size()
    test_deposit()
    test_withdraw()


def test_capacity():
    j = Jar(capacity=3)
    assert j.capacity == 3


def test_size():
    j = Jar(capacity=5)
    assert j.size == 0
    j.deposit(3)
    j.withdraw(1)
    assert j.size == 2


def test_deposit():
    j = Jar(capacity=5)
    j.deposit(3)
    try:
        j.deposit(3)
        raise Exception("Deposit n > capacity did not raise ValueError")
    except Exception as e:
        assert isinstance(e, ValueError)


def test_withdraw():
    j = Jar(capacity=5)
    j.deposit(3)
    j.withdraw(2)
    try:
        j.withdraw(2)
        raise Exception("Withdraw n > size did not raise ValueError")
    except Exception as e:
        assert isinstance(e, ValueError)


if __name__ == '__main__':
    main()
