-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Отправляю повторно #768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
krikola
wants to merge
1
commit into
Yandex-Practicum:main
Choose a base branch
from
krikola:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Отправляю повторно #768
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| .venv | ||
| .pytest_cache |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| from praktikum.database import Database | ||
| from unittest.mock import Mock | ||
| from data import Data1, Data2 | ||
| import pytest | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def mock_bun(): | ||
| mock_for_bun = Mock() | ||
| mock_for_bun.get_name.return_value = Data1.bun_name | ||
| mock_for_bun.get_price.return_value = Data1.bun_price | ||
| return mock_for_bun | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def mock_bun_2(): | ||
| mock_for_bun_2 = Mock() | ||
| mock_for_bun_2.get_name.return_value = Data2.bun_name | ||
| mock_for_bun_2.get_price.return_value = Data2.bun_price | ||
| return mock_for_bun_2 | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def mock_sauce(): | ||
| mock_for_sauce = Mock() | ||
| mock_for_sauce.get_name.return_value = Data1.sauce_name | ||
| mock_for_sauce.get_price.return_value = Data1.sauce_price | ||
| mock_for_sauce.get_type.return_value = Data1.sauce_type | ||
| return mock_for_sauce | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def mock_sauce_2(): | ||
| mock_for_sauce_2 = Mock() | ||
| mock_for_sauce_2.get_name.return_value = Data2.sauce_name | ||
| mock_for_sauce_2.get_price.return_value = Data2.sauce_price | ||
| mock_for_sauce_2.get_type.return_value = Data2.sauce_type | ||
| return mock_for_sauce_2 | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def mock_filling(): | ||
| mock_for_filling = Mock() | ||
| mock_for_filling.get_name.return_value = Data1.filling_name | ||
| mock_for_filling.get_price.return_value = Data1.filling_price | ||
| mock_for_filling.get_type.return_value = Data1.filling_type | ||
| return mock_for_filling | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def mock_filling_2(): | ||
| mock_for_filling_2 = Mock() | ||
| mock_for_filling_2.get_name.return_value = Data2.filling_name | ||
| mock_for_filling_2.get_price.return_value = Data2.filling_price | ||
| mock_for_filling_2.get_type.return_value = Data2.filling_type | ||
| return mock_for_filling_2 | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def db(): | ||
| return Database() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| from praktikum.ingredient_types import INGREDIENT_TYPE_SAUCE, INGREDIENT_TYPE_FILLING | ||
|
|
||
|
|
||
| class Data1: | ||
| bun_name = 'Флюоресцентная булка R2-D3' | ||
| bun_price = 988 | ||
|
|
||
| sauce_type = INGREDIENT_TYPE_SAUCE | ||
| sauce_name = 'Соус традиционный галактический' | ||
| sauce_price = 15 | ||
|
|
||
| filling_type = INGREDIENT_TYPE_FILLING | ||
| filling_name = 'Мясо бессмертных моллюсков Protostomia' | ||
| filling_price = 1350 | ||
|
|
||
| burger_final_cost = bun_price * 2 + sauce_price + filling_price | ||
|
|
||
|
|
||
| class Data2: | ||
| bun_name = 'Краторная булка N-200i' | ||
| bun_price = 1255 | ||
|
|
||
| sauce_type = INGREDIENT_TYPE_SAUCE | ||
| sauce_name = 'Соус с шипами Антарианского плоскоходца' | ||
| sauce_price = 88 | ||
|
|
||
| filling_type = INGREDIENT_TYPE_FILLING | ||
| filling_name = 'Сыр с астероидной плесенью' | ||
| filling_price = 4142 | ||
|
|
||
| burger_final_cost = bun_price * 2 + sauce_price + filling_price | ||
|
|
||
|
|
||
| class TestDataBase: | ||
| test_data_base_buns = [ | ||
| [0, 'black bun', 100], | ||
| [1, 'white bun', 200], | ||
| [2, 'red bun', 300] | ||
| ] | ||
|
|
||
| test_data_base_ingredients = [ | ||
| [0, INGREDIENT_TYPE_SAUCE, 'hot sauce', 100], | ||
| [1, INGREDIENT_TYPE_SAUCE, 'sour cream', 200], | ||
| [2, INGREDIENT_TYPE_SAUCE, 'chili sauce', 300], | ||
| [3, INGREDIENT_TYPE_FILLING, 'cutlet', 100], | ||
| [4, INGREDIENT_TYPE_FILLING, 'dinosaur', 200], | ||
| [5, INGREDIENT_TYPE_FILLING, 'sausage', 300] | ||
|
|
||
| ] |
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| from conftest import * | ||
| import allure | ||
|
|
||
|
|
||
| class TestBun: | ||
|
|
||
| @allure.title('Проверка работы метода get_name, который получает название булки') | ||
| def test_get_name_bun_success(self, mock_bun): | ||
| assert mock_bun.get_name() == Data1.bun_name | ||
|
|
||
| @allure.title('Проверка работы метода get_price, который получает стоимость булки') | ||
| def test_get_price_bun_success(self, mock_bun_2): | ||
| assert mock_bun_2.get_price() == Data2.bun_price |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| from praktikum.burger import Burger | ||
| from conftest import * | ||
| import pytest | ||
| import allure | ||
|
|
||
|
|
||
| class TestBurger: | ||
| @allure.title('Проверка работы метода set_buns, добавляющего булочку в бургер') | ||
| def test_set_buns_success(self, mock_bun): | ||
| burger = Burger() | ||
| burger.set_buns(mock_bun) | ||
| assert burger.bun == mock_bun | ||
|
|
||
| @allure.title('Проверка работы метода add_ingredient, добавляющего ингредиенты в бургер') | ||
| @allure.description('С помощью параметризации выполняем три теста: проверяем по очереди ' | ||
| 'добавление соуса и двух разных начинок') | ||
| @pytest.mark.parametrize('ingredients, added_ingredient', [ | ||
| [Data1.sauce_name, Data1.sauce_name], | ||
| [Data1.filling_name, Data1.filling_name], | ||
| [Data2.filling_name, Data2.filling_name] | ||
| ] | ||
| ) | ||
| def test_add_ingredient_success(self, ingredients, added_ingredient): | ||
| burger = Burger() | ||
| burger.add_ingredient(ingredients) | ||
| assert burger.ingredients == [added_ingredient] and len(burger.ingredients) == 1 | ||
|
|
||
| @allure.title('Проверка работы метода remove_ingredient, удаляющего ингредиент из бургера') | ||
| @allure.description('С помощью параметризации выполняем два теста: проверяем по очереди ' | ||
| 'удаление соуса и начинки') | ||
| @pytest.mark.parametrize('ingredients, removed_ingredient', [ | ||
| [Data1.sauce_name, Data1.sauce_name], | ||
| [Data2.filling_name, Data2.filling_name] | ||
| ] | ||
| ) | ||
| def test_remove_ingredient_success(self, ingredients, removed_ingredient, mock_filling): | ||
| burger = Burger() | ||
| burger.add_ingredient(mock_filling) | ||
| burger.add_ingredient(ingredients) | ||
| burger.remove_ingredient(1) | ||
| assert removed_ingredient not in burger.ingredients and mock_filling in burger.ingredients | ||
|
|
||
| @allure.title('Проверка работы метода move_ingredient, перемещающего ингредиенты в бургере') | ||
| def test_move_ingredient_success(self, mock_sauce, mock_filling): | ||
| burger = Burger() | ||
| burger.add_ingredient(mock_sauce) | ||
| burger.add_ingredient(mock_filling) | ||
| burger.move_ingredient(0, 1) | ||
| assert len(burger.ingredients) == 2 | ||
| assert burger.ingredients[0] == mock_filling and burger.ingredients[1] == mock_sauce | ||
|
|
||
| @allure.title('Проверка работы метода get_price, высчитывающего конечную стоимость бургера') | ||
| def test_get_price_burger_success(self, mock_bun_2, mock_sauce_2, mock_filling_2): | ||
| burger = Burger() | ||
| burger.set_buns(mock_bun_2) | ||
| burger.add_ingredient(mock_sauce_2) | ||
| burger.add_ingredient(mock_filling_2) | ||
| assert burger.get_price() == Data2.burger_final_cost | ||
|
|
||
| @allure.title('Проверка работы метода get_receipt, получающего рецепт собранного бургера и его стоимость') | ||
| def test_get_receipt_success(self, mock_bun, mock_sauce, mock_filling, mock_filling_2): | ||
| burger = Burger() | ||
| burger.set_buns(mock_bun) | ||
| burger.add_ingredient(mock_sauce) | ||
| burger.add_ingredient(mock_filling) | ||
| burger.add_ingredient(mock_filling_2) | ||
| assert burger.get_receipt() == ('(==== Флюоресцентная булка R2-D3 ====)\n' | ||
| '= sauce Соус традиционный галактический =\n' | ||
| '= filling Мясо бессмертных моллюсков Protostomia =\n' | ||
| '= filling Сыр с астероидной плесенью =\n' | ||
| '(==== Флюоресцентная булка R2-D3 ====)\n' | ||
| '\n' | ||
| f'Price: {burger.get_price()}') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| from data import TestDataBase | ||
| from conftest import db | ||
| import pytest | ||
| import allure | ||
|
|
||
|
|
||
| class TestDB: | ||
| @allure.title('Проверка работы метода available_buns, получающего список доступных булок из базы') | ||
| @allure.description('С помощью параметризации выполняем три теста: проверяем по очереди ' | ||
| 'имя и стоимость каждой булки') | ||
| @pytest.mark.parametrize('index_bun, bun_name, bun_price', TestDataBase.test_data_base_buns) | ||
| def test_available_buns_db_success(self, db, index_bun, bun_name, bun_price): | ||
| data_buns = db.available_buns() | ||
| assert data_buns[index_bun].get_name() == bun_name and data_buns[index_bun].get_price() == bun_price | ||
|
|
||
| @allure.title('Проверка работы метода available_ingredients, получающего список доступных ингредиентов из базы') | ||
| @allure.description('С помощью параметризации выполняем шесть тестов: проверяем по очереди ' | ||
| 'имя, тип и стоимость каждого ингредиента') | ||
| @pytest.mark.parametrize('index_i, type_ingredient, name_ingredient, price_ingredient', | ||
| TestDataBase.test_data_base_ingredients) | ||
| def test_available_ingredients_db_success(self, db, index_i, type_ingredient, name_ingredient, price_ingredient): | ||
| data_ingredients = db.available_ingredients() | ||
| assert (data_ingredients[index_i].get_name() == name_ingredient and | ||
| data_ingredients[index_i].get_type() == type_ingredient and | ||
| data_ingredients[index_i].get_price() == price_ingredient) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| from conftest import * | ||
| import allure | ||
|
|
||
|
|
||
| class TestIngredient: | ||
| @allure.title('Проверка работы метода get_name, получающего название соуса') | ||
| def test_get_name_sauce_success(self, mock_sauce): | ||
| assert mock_sauce.get_name() == Data1.sauce_name | ||
|
|
||
| @allure.title('Проверка работы метода get_name, получающего название начинки') | ||
| def test_get_name_filling_success(self, mock_filling): | ||
| assert mock_filling.get_name() == Data1.filling_name | ||
|
|
||
| @allure.title('Проверка работы метода get_price, получающего стоимость соуса') | ||
| def test_get_price_sauce_success(self, mock_sauce_2): | ||
| assert mock_sauce_2.get_price() == Data2.sauce_price | ||
|
|
||
| @allure.title('Проверка работы метода get_price, получающего стоимость начинки') | ||
| def test_get_price_filling_success(self, mock_filling_2): | ||
| assert mock_filling_2.get_price() == Data2.filling_price | ||
|
|
||
| @allure.title('Проверка работы метода get_type, получающего тип ингредиента для соуса') | ||
| def test_get_type_sauce_success(self, mock_sauce): | ||
| assert mock_sauce.get_type() == Data1.sauce_type | ||
|
|
||
| @allure.title('Проверка работы метода get_type, получающего тип ингредиента для начинки') | ||
| def test_get_type_filling_success(self, mock_filling): | ||
| assert mock_filling.get_type() == Data1.filling_type |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Необходимо исправить: эта директория лишняя в проекте. Необходимо убрать её из ветки и добавить в .gitignore в корне проекта