Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Virtual environment
.venv/

# Python cache
__pycache__/
*.pyc

# Pytest
.pytest_cache/

# Coverage
.coverage
htmlcov/
Empty file added praktikum/__init__.py
Empty file.
1 change: 1 addition & 0 deletions praktikum/bun.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from bun import Bun
1 change: 1 addition & 0 deletions praktikum/database.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from database import Database
1 change: 1 addition & 0 deletions praktikum/ingredient.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from ingredient import Ingredient
1 change: 1 addition & 0 deletions praktikum/ingredient_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from ingredient_types import *
File renamed without changes.
8 changes: 8 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
colorama==0.4.6
coverage==7.13.1
iniconfig==2.3.0
packaging==25.0
pluggy==1.6.0
Pygments==2.19.2
pytest==9.0.2
pytest-cov==7.0.0
Empty file added tests/__init__.py
Empty file.
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# tests/conftest.py
import sys
from pathlib import Path

PROJECT_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(PROJECT_ROOT))

26 changes: 26 additions & 0 deletions tests/test_bun.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import pytest
from bun import Bun


def test_bun_has_name():
bun = Bun(name="black bun", price=100)
assert bun.name == "black bun"


def test_bun_has_price():
bun = Bun(name="black bun", price=100)
assert bun.price == 100


@pytest.mark.parametrize(
"name, price",
[
("white bun", 50),
("black bun", 100),
("alien bun", 999),
]
)
def test_bun_parametrized(name, price):
bun = Bun(name=name, price=price)
assert bun.name == name
assert bun.price == price
31 changes: 31 additions & 0 deletions tests/test_burger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from unittest.mock import Mock
from burger import Burger


def test_add_ingredient_increases_ingredients_count():
burger = Burger()
ingredient = Mock()

burger.add_ingredient(ingredient)

assert len(burger.ingredients) == 1


def test_remove_ingredient_decreases_ingredients_count():
burger = Burger()
ingredient = Mock()
burger.add_ingredient(ingredient)

burger.remove_ingredient(0)

assert len(burger.ingredients) == 0


def test_set_buns_sets_top_and_bottom():
burger = Burger()
bun = Mock()
bun.price = 100

burger.set_buns(bun)

assert burger.bun == bun
17 changes: 17 additions & 0 deletions tests/test_database.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from database import Database


def test_database_returns_buns():
database = Database()
buns = database.available_buns()

assert isinstance(buns, list)
assert len(buns) > 0


def test_database_returns_ingredients():
database = Database()
ingredients = database.available_ingredients()

assert isinstance(ingredients, list)
assert len(ingredients) > 0
22 changes: 22 additions & 0 deletions tests/test_ingredient.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pytest
from ingredient import Ingredient
from ingredient_types import INGREDIENT_TYPE_SAUCE, INGREDIENT_TYPE_FILLING


@pytest.mark.parametrize(
"name, ingredient_type, price",
[
("sauce", INGREDIENT_TYPE_SAUCE, 50),
("filling", INGREDIENT_TYPE_FILLING, 100),
]
)
def test_ingredient_fields(name, ingredient_type, price):
ingredient = Ingredient(
name=name,
ingredient_type=ingredient_type,
price=price
)

assert ingredient.name == name
assert ingredient.type == ingredient_type
assert ingredient.price == price