-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Добавлено первое дипломное задание #864
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
elizabeth-af
wants to merge
1
commit into
Yandex-Practicum:main
Choose a base branch
from
elizabeth-af:develop1
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
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
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.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,12 @@ | ||
| from praktikum.bun import Bun | ||
|
|
||
|
|
||
| class TestBun: | ||
|
|
||
| def test_return_bun_name(self): | ||
| bun = Bun("black bun", 100) | ||
| assert bun.get_name() == "black bun" | ||
|
|
||
| def test_return_bun_price(self): | ||
| bun = Bun("black bun", 100) | ||
| assert bun.get_price() == 100 |
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,69 @@ | ||
| from unittest.mock import Mock | ||
| from praktikum.burger import Burger | ||
| from praktikum.bun import Bun | ||
| from praktikum.ingredient import Ingredient | ||
| from praktikum.ingredient_types import INGREDIENT_TYPE_SAUCE, INGREDIENT_TYPE_FILLING | ||
|
|
||
| class TestBurger: | ||
|
|
||
| def test_set_buns(self): | ||
| burger = Burger() | ||
| bun = Bun("black bun", 100) | ||
| burger.set_buns(bun) | ||
| assert burger.bun == bun | ||
|
|
||
| def test_add_ingredient_to_list(self): | ||
| burger = Burger() | ||
| ingredient = Ingredient(INGREDIENT_TYPE_SAUCE,"hot sauce",100) | ||
| burger.add_ingredient(ingredient) | ||
| assert burger.ingredients == [ingredient] | ||
|
|
||
| def test_remove_ingredient_from_list(self): | ||
| burger = Burger() | ||
| ingredient_1 = Ingredient(INGREDIENT_TYPE_SAUCE,"hot sauce",100) | ||
| ingredient_2 = Ingredient(INGREDIENT_TYPE_FILLING,"cutlet",200) | ||
| burger.add_ingredient(ingredient_1) | ||
| burger.add_ingredient(ingredient_2) | ||
| burger.remove_ingredient(0) | ||
| assert burger.ingredients == [ingredient_2] | ||
|
|
||
| def test_move_ingredient(self): | ||
| burger = Burger() | ||
| ingredient_1 = Ingredient(INGREDIENT_TYPE_SAUCE,"hot sauce",100) | ||
| ingredient_2 = Ingredient(INGREDIENT_TYPE_FILLING,"cutlet",200) | ||
| burger.add_ingredient(ingredient_1) | ||
| burger.add_ingredient(ingredient_2) | ||
| burger.move_ingredient(0, 1) | ||
| assert burger.ingredients == [ingredient_2, ingredient_1] | ||
|
|
||
| def test_get_total_price(self): | ||
| burger = Burger() | ||
| bun = Mock() | ||
| bun.get_price.return_value = 100 | ||
| ingredient_1 = Mock() | ||
| ingredient_1.get_price.return_value = 100 | ||
| ingredient_2 = Mock() | ||
| ingredient_2.get_price.return_value = 200 | ||
| burger.set_buns(bun) | ||
| burger.add_ingredient(ingredient_1) | ||
| burger.add_ingredient(ingredient_2) | ||
| assert burger.get_price() == 500 | ||
|
|
||
| def test_get_receipt(self): | ||
| burger = Burger() | ||
| bun = Mock() | ||
| bun.get_name.return_value = "black bun" | ||
| bun.get_price.return_value = 100 | ||
| ingredient = Mock() | ||
| ingredient.get_name.return_value = "hot sauce" | ||
| ingredient.get_type.return_value = "SAUCE" | ||
| ingredient.get_price.return_value = 100 | ||
| burger.set_buns(bun) | ||
| burger.add_ingredient(ingredient) | ||
| expected_receipt = ( | ||
| "(==== black bun ====)\n" | ||
| "= sauce hot sauce =\n" | ||
| "(==== black bun ====)\n\n" | ||
| "Price: 300" | ||
| ) | ||
| assert burger.get_receipt() == expected_receipt |
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,26 @@ | ||
| from praktikum.database import Database | ||
|
|
||
| class TestDatabase: | ||
|
|
||
| def test_available_buns_returns_all_buns(self): | ||
| database = Database() | ||
| buns = database.available_buns() | ||
| bun_names = [bun.get_name() for bun in buns] | ||
| assert bun_names == [ | ||
| "black bun", | ||
| "white bun", | ||
| "red bun" | ||
| ] | ||
|
|
||
| def test_available_ingredients_returns_all_ingredients(self): | ||
| database = Database() | ||
| ingredients = database.available_ingredients() | ||
| ingredient_names = [ingredient.get_name()for ingredient in ingredients] | ||
| assert ingredient_names == [ | ||
| "hot sauce", | ||
| "sour cream", | ||
| "chili sauce", | ||
| "cutlet", | ||
| "dinosaur", | ||
| "sausage" | ||
| ] |
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 @@ | ||
| import pytest | ||
|
|
||
| from praktikum.ingredient import Ingredient | ||
| from praktikum.ingredient_types import INGREDIENT_TYPE_SAUCE, INGREDIENT_TYPE_FILLING | ||
|
|
||
|
|
||
| class TestIngredient: | ||
|
|
||
| @pytest.mark.parametrize( | ||
| "ingredient_type", | ||
| [ | ||
| INGREDIENT_TYPE_SAUCE, | ||
| INGREDIENT_TYPE_FILLING | ||
| ] | ||
| ) | ||
| def test_get_type_returns_ingredient_type(self, ingredient_type): | ||
| ingredient = Ingredient(ingredient_type, "ketchup", 50) | ||
| assert ingredient.get_type() == ingredient_type | ||
|
|
||
|
|
||
| def test_get_name_returns_ingredient_name(self): | ||
| ingredient = Ingredient(INGREDIENT_TYPE_SAUCE,"ketchup",50) | ||
| assert ingredient.get_name() == "ketchup" | ||
|
|
||
|
|
||
| def test_get_price_returns_ingredient_price(self): | ||
| ingredient = Ingredient(INGREDIENT_TYPE_SAUCE,"ketchup",50) | ||
| assert ingredient.get_price() == 50 |
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.
Нужно исправить: из финального проекта нужно удалить все файлы и папки, которые не относятся к решению задачи