-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Добавлены юнит-тесты для приложения бургеров #664
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
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.
Нужно исправить: из финального проекта нужно удалить все файлы и папки, которые не относятся к решению задачи
| bun = Bun(name, price) | ||
|
|
||
| assert bun.get_name() == name | ||
| assert bun.get_price() == price 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.
нужно исправить: в юнит тестировании мы хотим проверить методы по отдельности
|
|
||
| def test_add_ingredient(): | ||
| burger = Burger() | ||
| ingredient = 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.
Отлично: благодаря мокам тесты стали быстрее и управляемее, теперь они меньше зависят от внешних данных
tests/test_database.py
Outdated
|
|
||
| def test_database_available_buns(): | ||
| database = Database() | ||
| buns = database.available_buns() |
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.
Можно лучше: мы тестируем не атрибуты экземпляров класса или наполнение базы данных, а методы приложения. Необходимо добавить шаги в которых будут использованы методы и проверить результат. Базу данных тестировать юниттестами не получится
| def test_ingredient_getters(ingredient_type, name, price): | ||
| ingredient = Ingredient(ingredient_type, name, price) | ||
|
|
||
| assert ingredient.get_type() == ingredient_type |
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.
нужно протестировать методы атомарно
| BUN_DATA = [ | ||
| ("black bun", 100), | ||
| ("white bun", 200), | ||
| ("gluten free", 300), |
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.
Можно лучше: надежнее тестировать параметр при остальных неизменных. Например тут тестируем имя, значит в параметризации должна менять только имя, а цена быть всегда одинаковой. Также имеет смысл тестировать разные КЭ а не только латинские буквы с пробелом
Добавлены юнит-тесты для классов Bun, Burger, Ingredient и Database
Использованы моки и параметризация
Покрытие pytest-cov: 88%