Files
Tirsvad 2b6b3bee46
CI / test (push) Successful in 50s
Implement coffee machine program and tests (MIL-002)
Add the Menu, MenuItem, CoffeeMaker and MoneyMachine classes with the
assignment's method names, and a main loop that supports drink names,
report and off. Resources are checked before payment, and payment
before the drink is made.

Move drink prices, ingredient amounts and all message text into
constants.py. Add 25 pytest tests for every class and the main loop,
and record the review against QC-PY-001 as RC-007.

Task: MIL-002#1
Task: MIL-002#2
Task: MIL-002#3
Task: MIL-002#4
Task: MIL-002#5
Task: MIL-002#6
Closes #6
Closes #7
Closes #8
Closes #9
Closes #10
Closes #11
2026-10-07 10:49:35 +08:00

29 lines
770 B
Python

"""! @file
@brief Tests for Menu and MenuItem.
"""
import pytest
from coffee_machine import constants
from coffee_machine.menu import Menu
def test_get_items_lists_all_drinks_separated() -> None:
assert Menu().get_items() == "espresso/latte/cappuccino"
def test_find_drink_returns_matching_item() -> None:
drink = Menu().find_drink("latte")
assert drink is not None
assert drink.name == "latte"
assert drink.cost == constants.DRINK_COSTS["latte"]
assert drink.ingredients == constants.DRINK_INGREDIENTS["latte"]
def test_find_drink_when_unknown_returns_none_and_prints_message(
capsys: pytest.CaptureFixture[str],
) -> None:
assert Menu().find_drink("tea") is None
assert constants.MSG_UNAVAILABLE in capsys.readouterr().out