From 6dc237f0f3c3a07abefef41b2e419f686f935688 Mon Sep 17 00:00:00 2001 From: elen Date: Sun, 10 May 2026 15:09:00 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=201?= =?UTF-8?q?=20=D0=BF=D1=80=D0=BE=D0=B5=D0=BA=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .coverage | Bin 0 -> 53248 bytes .gitignore | 12 +++++++ README.md | 30 ++++++++---------- conftest.py | 20 ++++++++++++ __init__.py => main.py | 0 praktikum/__init__.py | 0 bun.py => praktikum/bun.py | 0 burger.py => praktikum/burger.py | 0 database.py => praktikum/database.py | 0 ingredient.py => praktikum/ingredient.py | 0 .../ingredient_types.py | 0 requirements.txt | 27 ++++++++++++++++ tests/__init__.py | 0 tests/test_bun.py | 11 +++++++ tests/test_burger.py | 10 ++++++ tests/test_database.py | 18 +++++++++++ tests/test_ingredient.py | 15 +++++++++ 17 files changed, 127 insertions(+), 16 deletions(-) create mode 100644 .coverage create mode 100644 .gitignore create mode 100644 conftest.py rename __init__.py => main.py (100%) create mode 100644 praktikum/__init__.py rename bun.py => praktikum/bun.py (100%) rename burger.py => praktikum/burger.py (100%) rename database.py => praktikum/database.py (100%) rename ingredient.py => praktikum/ingredient.py (100%) rename ingredient_types.py => praktikum/ingredient_types.py (100%) create mode 100644 requirements.txt create mode 100644 tests/__init__.py create mode 100644 tests/test_bun.py create mode 100644 tests/test_burger.py create mode 100644 tests/test_database.py create mode 100644 tests/test_ingredient.py diff --git a/.coverage b/.coverage new file mode 100644 index 0000000000000000000000000000000000000000..cd506489b73ffd097aa44aecaf5a7b3a07b8afbe GIT binary patch literal 53248 zcmeI5PmCK^9mi)p;~9@V_FEEy6;{>03)-x@yJj2ImNux_B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-u!v&m2ARx%P{6n5lmmwvy6emKDuUPM|hHb_gmtd?o}om@#b z+S?T&samg-D)atT$*-gLoKTR8a~7$v%Bm>%RM7EMjdW;bb>trP#sU4v4jFOQBn8#7 z3JOL{HJmXt<;I~D$cQ*oy>IC*b*dY6yCi*HC+iz!8_(U(JCu|>scFjf``6JMOZ(R= zWWgcgpy0%#s-}cx+oxaU*p$6MP0RcLE&FAK{oa1reuKTnF1D)8uQR=Qy7k-E>#ff> ze__A-!G}3CfB*=900@8p2!H?xfB*=9fTEn%cGR-lmURE$dR!ZqmYHtXXs^@U&?n8( zl7(&R%udh#f<9@N)-r8>zx{vXoIWuRp{lTVubyv6}1qCCf8qCjWHx8#j?w^hOmo99bs~7Z1qjclB`!i9YpV6)#LPxUy*A5v61t%(x zYGLV*feQP7{Qe(iVGsZT5C8!X009sH0T2KI5C8!Xc%TVr^d|#NdH-K!|5fOL0|Y<- z1V8`;KmY_l00ck)1V8`;K;Qu+plMA@-v77Rw-xpu_7CmzX_POu3B^U?K`ywWsX@d+%nC&yky=sO-p8s z+byF;nO0RbOqn)*Su-d-rW^izy-K-H)Svj<9Z#$4GGF`N`iuy{fP>2fB*=900@8p2!H?x zfB*=900@8p2plm1xzSf`J5H=doS5}EF|0VL#-9bK4KqH|jX0@S `$ pip install -r requirements.txt` - -**Запуск автотестов и создание HTML-отчета о покрытии** - -> `$ pytest --cov=praktikum --cov-report=html` +## Написаны тесты на функциональность: +* покрытие класса `Bun` модуль test_bun.py; +* покрытие класса `Ingredient` модуль test_ingredient.py; +* покрытие класса `Database` модуль test_database.py; +* покрытие класса `Burger` модуль test_burger.py. \ No newline at end of file diff --git a/conftest.py b/conftest.py new file mode 100644 index 000000000..8f27fe49c --- /dev/null +++ b/conftest.py @@ -0,0 +1,20 @@ +import pytest +from unittest.mock import Mock +from praktikum.bun import Bun +from praktikum.ingredient import Ingredient + + +@pytest.fixture +def bun_mock(): + mock = Mock(Bun) + mock.get_name.return_value = "Флюоресцентная булка R2-D3" + mock.get_price.return_value = 988 + return mock + +@pytest.fixture +def ingredient_mock(): + mock = Mock(Ingredient) + mock.get_name.return_value = "Хрустящие минеральные кольца" + mock.get_price.return_value = 300 + mock.get_type.return_value = "FILLING" + return mock diff --git a/__init__.py b/main.py similarity index 100% rename from __init__.py rename to main.py diff --git a/praktikum/__init__.py b/praktikum/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/bun.py b/praktikum/bun.py similarity index 100% rename from bun.py rename to praktikum/bun.py diff --git a/burger.py b/praktikum/burger.py similarity index 100% rename from burger.py rename to praktikum/burger.py diff --git a/database.py b/praktikum/database.py similarity index 100% rename from database.py rename to praktikum/database.py diff --git a/ingredient.py b/praktikum/ingredient.py similarity index 100% rename from ingredient.py rename to praktikum/ingredient.py diff --git a/ingredient_types.py b/praktikum/ingredient_types.py similarity index 100% rename from ingredient_types.py rename to praktikum/ingredient_types.py diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..e366e2ba7 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,27 @@ +allure-pytest==2.15.3 +allure-python-commons==2.15.3 +attrs==25.4.0 +certifi==2026.2.25 +charset-normalizer==3.4.7 +coverage==7.13.4 +Faker==40.11.0 +h11==0.16.0 +idna==3.11 +iniconfig==2.3.0 +outcome==1.3.0.post0 +packaging==26.0 +pluggy==1.6.0 +Pygments==2.19.2 +PySocks==1.7.1 +pytest==9.0.2 +pytest-cov==7.0.0 +requests==2.33.1 +selenium==4.41.0 +sniffio==1.3.1 +sortedcontainers==2.4.0 +trio==0.33.0 +trio-websocket==0.12.2 +typing_extensions==4.15.0 +urllib3==2.6.3 +websocket-client==1.9.0 +wsproto==1.3.2 diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/test_bun.py b/tests/test_bun.py new file mode 100644 index 000000000..99d9b2dba --- /dev/null +++ b/tests/test_bun.py @@ -0,0 +1,11 @@ +from praktikum.bun import Bun + +class TestBun: + + def test_bun_get_name_returns_correct_name(self): + bun = Bun("Краторная булка Н-200и", 1255) + assert bun.get_name() == "Краторная булка Н-200и" + + def test_bun_get_price_returns_correct_price(self): + bun = Bun("Краторная булка Н-200и", 1255) + assert bun.get_price() == 1255 \ No newline at end of file diff --git a/tests/test_burger.py b/tests/test_burger.py new file mode 100644 index 000000000..deaba163c --- /dev/null +++ b/tests/test_burger.py @@ -0,0 +1,10 @@ +from praktikum.burger import Burger + +class TestBurger: + + def test_get_price_burger(self, bun_mock, ingredient_mock): + burger = Burger() + burger.set_buns(bun_mock) + burger.add_ingredient(ingredient_mock) + expected_price = (bun_mock.get_price() * 2) + ingredient_mock.get_price() + assert burger.get_price() == expected_price diff --git a/tests/test_database.py b/tests/test_database.py new file mode 100644 index 000000000..5ebce8e12 --- /dev/null +++ b/tests/test_database.py @@ -0,0 +1,18 @@ +from praktikum.database import Database +from praktikum.bun import Bun +from praktikum.ingredient import Ingredient +from praktikum.ingredient_types import INGREDIENT_TYPE_SAUCE, INGREDIENT_TYPE_FILLING + +class TestDatabase: + + def test_available_buns(self): + database = Database() + database.buns = [Bun("black bun", 100)] + list = database.available_buns() + assert list[0].get_name() == "black bun" + + def test_available_ingredients(self): + database = Database() + database.ingredient = [Ingredient(INGREDIENT_TYPE_SAUCE, "hot sauce", 100)] + list = database.available_ingredients() + assert list[0].get_name() == "hot sauce" diff --git a/tests/test_ingredient.py b/tests/test_ingredient.py new file mode 100644 index 000000000..ffb088837 --- /dev/null +++ b/tests/test_ingredient.py @@ -0,0 +1,15 @@ +from praktikum.ingredient import Ingredient + +class TestIngredient: + + def test_ingredient_get_name_returns_correct_name(self): + ingredient = Ingredient('SAUCE', 'Соус с шипами Антарианского плоскоходца', 88) + assert ingredient.get_name() == 'Соус с шипами Антарианского плоскоходца' + + def test_ingredient_get_price_returns_correct_price(self): + ingredient = Ingredient('SAUCE', 'Соус с шипами Антарианского плоскоходца', 88) + assert ingredient.get_price() == 88 + + def test_ingredient_get_type_returns_correct_type(self): + ingredient = Ingredient('SAUCE', 'Соус с шипами Антарианского плоскоходца', 88) + assert ingredient.get_type() == 'SAUCE' \ No newline at end of file