-
Notifications
You must be signed in to change notification settings - Fork 1.1k
добавляю первое задание второй части диплома #635
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
base: main
Are you sure you want to change the base?
Conversation
| def bun(): | ||
| """Фикстура для создания булочки""" | ||
| from bun import Bun | ||
| return Bun("Краторная булочка", 100.0) |
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.
Можно лучше здесь и далее: лучше выносить тестовые данные во внешний модуль (например, data). Это позволит облегчить их поддержку
| @pytest.fixture | ||
| def burger(): | ||
| """Создает новый бургер для каждого теста""" | ||
| return Burger() | ||
|
|
||
| @pytest.fixture | ||
| def mock_bun(): | ||
| """Создает мок булочки""" | ||
| mock = Mock() | ||
| mock.get_price.return_value = 100 | ||
| mock.get_name.return_value = "test bun" | ||
| return mock | ||
|
|
||
| @pytest.fixture | ||
| def mock_ingredient(): | ||
| """Создает мок ингредиента""" | ||
| mock = Mock() | ||
| mock.get_price.return_value = 50 | ||
| mock.get_name.return_value = "test ingredient" | ||
| mock.get_type.return_value = INGREDIENT_TYPE_SAUCE | ||
| return mock |
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.
Необходимо исправить здесь и далее: фикстуры стоит вынести к остальным в модуль conftest
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.
А тут фикстуры все еще в теле теста, дублируют те что уже есть в conftest. От этих можно избавиться
tests/test_burger.py
Outdated
| assert "test bun" in receipt | ||
| assert "test sauce" in receipt | ||
| assert "Price: 250" in receipt # 2*100 + 50 No newline at end of file |
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.
Нужно исправить: проверка через in в данном кейсе не будет надёжной, необходимо проверить полное соответствие вывода от get_receipt
| assert ingredient.get_type() == INGREDIENT_TYPE_SAUCE | ||
| assert ingredient.get_name() == "hot sauce" | ||
| assert ingredient.get_price() == 100.0 |
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.
Нужно исправить: стоит разделить эти тесты, юнит-тесты должны быть максимально атомарными
Добавил юнит-тесты с 100% покрытием: