def test_deposit_always_logs_a_message(self, deposit: Decimal, caplog):

        deposit = money.to_money(deposit)
        machine = VendingMachine()

        machine.deposit(deposit)
        self.logs_one_message(caplog)
        # Resetting the log capturing utility because hypothesis won't reset it
        caplog.clear()
    def test_deposit_0_or_less_logs_error_to_user(self, caplog):

        deposit = money.to_money(Decimal("-5"))

        machine = VendingMachine()
        machine.deposit(deposit)

        self.logs_one_message(caplog)
        assert "ERROR" in caplog.text
        assert "negative or 0" in caplog.text
    def test_deposit_money_logs_success_to_user(self, caplog):

        deposit = money.to_money(Decimal("30"))

        machine = VendingMachine()
        machine.deposit(deposit)

        self.logs_one_message(caplog)

        assert "SUCCESS" in caplog.text
        assert "Successfully deposited" in caplog.text
    def test_resets_balance(self, machine: VendingMachine, deposit: Decimal):
        """
        Test case to ensure that no leftover balance
        is retained after someone requests their change,
        regardless of size of previous deposits
        """

        machine.deposit(deposit)
        machine.deposit(deposit)

        change = machine.dispense_change()
        assert change == money.add(deposit, deposit)
        assert machine.balance == Decimal(0)
    def test_deposit_money_accepts_positive_amounts(self, deposit: Decimal):
        """
        Test case ensures that any positive amount rounded to the
        nearest cent can be accepted by the vending machine.
        """

        deposit = money.to_money(deposit)

        machine = VendingMachine()

        machine.deposit(deposit)
        machine.deposit(deposit)

        assert machine.balance == money.add(deposit, deposit)