-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add Task_1 The final project #650
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
tests/test_bun.py
Outdated
| def test_bun_creation_with_float_price(self): | ||
| """Проверяем создание булочки с дробной ценой.""" | ||
| bun = Bun("test bun", 99.99) | ||
| assert bun.get_price() == 99.99 | ||
| assert bun.get_name() == "test bun" 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.
Такого теста быть не должно. Юнит проверяет только один метод
tests/test_burger.py
Outdated
| @pytest.fixture | ||
| def burger(self): | ||
| return Burger() | ||
|
|
||
| @pytest.fixture | ||
| def mock_bun(self): | ||
| mock_bun = Mock(spec=Bun) | ||
| mock_bun.get_name.return_value = "test bun" | ||
| mock_bun.get_price.return_value = 100 | ||
| return mock_bun | ||
|
|
||
| @pytest.fixture | ||
| def mock_ingredient(self): | ||
| mock_ingredient = Mock(spec=Ingredient) | ||
| mock_ingredient.get_name.return_value = "test ingredient" | ||
| mock_ingredient.get_price.return_value = 50 | ||
| mock_ingredient.get_type.return_value = INGREDIENT_TYPE_SAUCE | ||
| return mock_ingredient |
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, кроме того, аналогичные там уже описаны
Task 1:
Юнит-тесты для Stellar Burgers
Установлены библиотеки:
pytest - для тестирования
pytest-cov - для измерения покрытия кода
Написаны тесты (43 теста):
Bun - тесты создания булочек, методов get_name(), get_price()
Ingredient - тесты ингредиентов (соусы/начинки), проверка типа, названия, цены
Burger - тесты конструктора бургеров (добавление/удаление ингредиентов, расчет стоимости, формирование чека)
Database - тесты базы данных (получение списков булочек и ингредиентов)
Использованы техники:
✅ Параметризация - тесты с разными данными
✅ Моки (Mock) - для изоляции зависимостей
✅ Фикстуры - для подготовки тестовых данных
Результаты:
43 теста - все проходят
Команды для запуска: