-
Notifications
You must be signed in to change notification settings - Fork 1.5k
firstcommitAkanovTimur #880
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
timur-akanov
wants to merge
2
commits into
Yandex-Practicum:main
Choose a base branch
from
timur-akanov: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
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
Binary file not shown.
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
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,133 @@ | ||
| <?xml version="1.0" ?> | ||
| <coverage version="7.15.4" timestamp="1787165521823" lines-valid="89" lines-covered="88" line-rate="0.9888" branches-covered="0" branches-valid="0" branch-rate="0" complexity="0"> | ||
| <!-- Generated by coverage.py: https://coverage.readthedocs.io/en/7.15.4 --> | ||
| <!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd --> | ||
| <sources> | ||
| <source>/Users/tim/Diplom/qa-python-project</source> | ||
| </sources> | ||
| <packages> | ||
| <package name="." line-rate="0.9888" branch-rate="0" complexity="0"> | ||
| <classes> | ||
| <class name="bun.py" filename="bun.py" complexity="0" line-rate="1" branch-rate="0"> | ||
| <methods/> | ||
| <lines> | ||
| <line number="1" hits="1"/> | ||
| <line number="7" hits="1"/> | ||
| <line number="8" hits="1"/> | ||
| <line number="9" hits="1"/> | ||
| <line number="11" hits="1"/> | ||
| <line number="12" hits="1"/> | ||
| <line number="14" hits="1"/> | ||
| <line number="15" hits="1"/> | ||
| </lines> | ||
| </class> | ||
| <class name="burger.py" filename="burger.py" complexity="0" line-rate="1" branch-rate="0"> | ||
| <methods/> | ||
| <lines> | ||
| <line number="1" hits="1"/> | ||
| <line number="3" hits="1"/> | ||
| <line number="4" hits="1"/> | ||
| <line number="7" hits="1"/> | ||
| <line number="15" hits="1"/> | ||
| <line number="16" hits="1"/> | ||
| <line number="17" hits="1"/> | ||
| <line number="19" hits="1"/> | ||
| <line number="20" hits="1"/> | ||
| <line number="22" hits="1"/> | ||
| <line number="23" hits="1"/> | ||
| <line number="25" hits="1"/> | ||
| <line number="26" hits="1"/> | ||
| <line number="28" hits="1"/> | ||
| <line number="29" hits="1"/> | ||
| <line number="31" hits="1"/> | ||
| <line number="32" hits="1"/> | ||
| <line number="34" hits="1"/> | ||
| <line number="35" hits="1"/> | ||
| <line number="37" hits="1"/> | ||
| <line number="39" hits="1"/> | ||
| <line number="40" hits="1"/> | ||
| <line number="42" hits="1"/> | ||
| <line number="43" hits="1"/> | ||
| <line number="45" hits="1"/> | ||
| <line number="46" hits="1"/> | ||
| <line number="48" hits="1"/> | ||
| </lines> | ||
| </class> | ||
| <class name="database.py" filename="database.py" complexity="0" line-rate="1" branch-rate="0"> | ||
| <methods/> | ||
| <lines> | ||
| <line number="1" hits="1"/> | ||
| <line number="3" hits="1"/> | ||
| <line number="4" hits="1"/> | ||
| <line number="5" hits="1"/> | ||
| <line number="8" hits="1"/> | ||
| <line number="13" hits="1"/> | ||
| <line number="14" hits="1"/> | ||
| <line number="15" hits="1"/> | ||
| <line number="17" hits="1"/> | ||
| <line number="18" hits="1"/> | ||
| <line number="19" hits="1"/> | ||
| <line number="21" hits="1"/> | ||
| <line number="22" hits="1"/> | ||
| <line number="23" hits="1"/> | ||
| <line number="25" hits="1"/> | ||
| <line number="26" hits="1"/> | ||
| <line number="27" hits="1"/> | ||
| <line number="29" hits="1"/> | ||
| <line number="30" hits="1"/> | ||
| <line number="32" hits="1"/> | ||
| <line number="33" hits="1"/> | ||
| </lines> | ||
| </class> | ||
| <class name="ingredient.py" filename="ingredient.py" complexity="0" line-rate="1" branch-rate="0"> | ||
| <methods/> | ||
| <lines> | ||
| <line number="1" hits="1"/> | ||
| <line number="8" hits="1"/> | ||
| <line number="9" hits="1"/> | ||
| <line number="10" hits="1"/> | ||
| <line number="11" hits="1"/> | ||
| <line number="13" hits="1"/> | ||
| <line number="14" hits="1"/> | ||
| <line number="16" hits="1"/> | ||
| <line number="17" hits="1"/> | ||
| <line number="19" hits="1"/> | ||
| <line number="20" hits="1"/> | ||
| </lines> | ||
| </class> | ||
| <class name="ingredient_types.py" filename="ingredient_types.py" complexity="0" line-rate="1" branch-rate="0"> | ||
| <methods/> | ||
| <lines> | ||
| <line number="6" hits="1"/> | ||
| <line number="7" hits="1"/> | ||
| </lines> | ||
| </class> | ||
| <class name="praktikum.py" filename="praktikum.py" complexity="0" line-rate="0.95" branch-rate="0"> | ||
| <methods/> | ||
| <lines> | ||
| <line number="1" hits="1"/> | ||
| <line number="3" hits="1"/> | ||
| <line number="4" hits="1"/> | ||
| <line number="5" hits="1"/> | ||
| <line number="6" hits="1"/> | ||
| <line number="9" hits="1"/> | ||
| <line number="11" hits="1"/> | ||
| <line number="14" hits="1"/> | ||
| <line number="17" hits="1"/> | ||
| <line number="20" hits="1"/> | ||
| <line number="23" hits="1"/> | ||
| <line number="25" hits="1"/> | ||
| <line number="26" hits="1"/> | ||
| <line number="27" hits="1"/> | ||
| <line number="28" hits="1"/> | ||
| <line number="31" hits="1"/> | ||
| <line number="34" hits="1"/> | ||
| <line number="37" hits="1"/> | ||
| <line number="40" hits="1"/> | ||
| <line number="41" hits="0"/> | ||
| </lines> | ||
| </class> | ||
| </classes> | ||
| </package> | ||
| </packages> | ||
| </coverage> |
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
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
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,3 @@ | ||
| [pytest] | ||
| addopts = --cov=bun --cov=burger --cov=database --cov=ingredient --cov=ingredient_types --cov=praktikum --cov-report=term-missing --cov-report=xml | ||
| python_files = tests/test_*.py |
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 @@ | ||
| pytest>=8.0 | ||
| pytest-cov>=4.0 |
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,102 @@ | ||
| import pytest | ||
| from unittest.mock import Mock | ||
|
|
||
| from burger import Burger | ||
| from ingredient import Ingredient | ||
|
|
||
|
|
||
| def test_burger_init_sets_empty_state(): | ||
| burger = Burger() | ||
|
|
||
| assert burger.bun is None | ||
| assert burger.ingredients == [] | ||
|
|
||
|
|
||
| def test_set_buns_assigns_bun_object(): | ||
| bun = Mock(get_name=Mock(return_value="plain bun"), get_price=Mock(return_value=100.0)) | ||
| burger = Burger() | ||
|
|
||
| burger.set_buns(bun) | ||
|
|
||
| assert burger.bun is bun | ||
|
|
||
|
|
||
| def test_add_ingredient_appends_ingredient_to_list(): | ||
| ingredient = Ingredient("FILLING", "cutlet", 35.0) | ||
| burger = Burger() | ||
|
|
||
| burger.add_ingredient(ingredient) | ||
|
|
||
| assert burger.ingredients == [ingredient] | ||
|
|
||
|
|
||
| def test_remove_ingredient_deletes_item_by_index(): | ||
| first = Ingredient("SAUCE", "hot sauce", 10.0) | ||
| second = Ingredient("FILLING", "cutlet", 35.0) | ||
| burger = Burger() | ||
| burger.add_ingredient(first) | ||
| burger.add_ingredient(second) | ||
|
|
||
| burger.remove_ingredient(0) | ||
|
|
||
| assert burger.ingredients == [second] | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "ingredient_prices,expected_total", | ||
| [ | ||
| ([100.0], 300.0), | ||
| ([10.0, 20.0], 230.0), | ||
| ([5.0, 15.0, 25.0], 245.0), | ||
| ], | ||
| ) | ||
| def test_get_price_includes_bun_twice_and_all_ingredient_prices( | ||
| ingredient_prices, expected_total | ||
| ): | ||
| # Мокаем булочку и ингредиенты, чтобы тест был независим от реализации Ingredient. | ||
| bun = Mock(get_name=Mock(return_value="mock bun"), get_price=Mock(return_value=100.0)) | ||
| burger = Burger() | ||
| burger.set_buns(bun) | ||
|
|
||
| for price in ingredient_prices: | ||
| ingredient = Mock(get_price=Mock(return_value=price)) | ||
| burger.add_ingredient(ingredient) | ||
|
|
||
| assert burger.get_price() == expected_total | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "initial_names,move_from,move_to,expected_names", | ||
| [ | ||
| (["hot sauce", "cutlet", "sausage"], 2, 0, ["sausage", "hot sauce", "cutlet"]), | ||
| (["sour cream", "dinosaur", "cutlet"], 0, 2, ["dinosaur", "cutlet", "sour cream"]), | ||
| ], | ||
| ) | ||
| def test_move_ingredient_reorders_list_correctly( | ||
| initial_names, move_from, move_to, expected_names | ||
| ): | ||
| burger = Burger() | ||
|
|
||
| for name in initial_names: | ||
| burger.add_ingredient(Ingredient("FILLING", name, 1.0)) | ||
|
|
||
| burger.move_ingredient(move_from, move_to) | ||
| assert [ingredient.get_name() for ingredient in burger.ingredients] == expected_names | ||
|
|
||
|
|
||
| def test_get_receipt_outputs_bun_and_ingredient_lines(): | ||
| bun = Mock(get_name=Mock(return_value="test bun"), get_price=Mock(return_value=50.0)) | ||
| ingredient = Mock( | ||
| get_type=Mock(return_value="SAUCE"), | ||
| get_name=Mock(return_value="hot sauce"), | ||
| get_price=Mock(return_value=10.0), | ||
| ) | ||
| burger = Burger() | ||
| burger.set_buns(bun) | ||
| burger.add_ingredient(ingredient) | ||
|
|
||
| receipt = burger.get_receipt() | ||
|
|
||
| assert "(==== test bun ====)" in receipt | ||
| assert "= sauce hot sauce =" in receipt | ||
| assert "Price: 110.0" in receipt | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. нужно протестировать все методы бургера |
||
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,45 @@ | ||
| from database import Database | ||
|
|
||
|
|
||
| def test_available_buns_returns_three_items(): | ||
| database = Database() | ||
| buns = database.available_buns() | ||
|
|
||
| assert len(buns) == 3 | ||
|
|
||
|
|
||
| def test_available_buns_returns_expected_bun_names(): | ||
| database = Database() | ||
| buns = database.available_buns() | ||
|
|
||
| assert buns[0].get_name() == "black bun" | ||
| assert buns[1].get_name() == "white bun" | ||
| assert buns[2].get_name() == "red bun" | ||
|
|
||
|
|
||
| def test_available_buns_contains_expected_bun_price(): | ||
| database = Database() | ||
| buns = database.available_buns() | ||
|
|
||
| assert buns[1].get_price() == 200 | ||
|
|
||
|
|
||
| def test_available_ingredients_returns_six_items(): | ||
| database = Database() | ||
| ingredients = database.available_ingredients() | ||
|
|
||
| assert len(ingredients) == 6 | ||
|
|
||
|
|
||
| def test_available_ingredients_returns_sauce_and_filling_types(): | ||
| database = Database() | ||
| ingredients = database.available_ingredients() | ||
|
|
||
| assert {ingredient.get_type() for ingredient in ingredients} == {"SAUCE", "FILLING"} | ||
|
|
||
|
|
||
| def test_available_ingredients_contains_cutlet(): | ||
| database = Database() | ||
| ingredients = database.available_ingredients() | ||
|
|
||
| assert any(ingredient.get_name() == "cutlet" for ingredient in ingredients) |
Oops, something went wrong.
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.
Нужно исправить: из финального проекта нужно удалить все файлы и папки, которые не относятся к решению задачи