Skip to content

Conversation

@Karlen32
Copy link

Добавлены юнит-тесты для классов Bun, Burger, Ingredient и Database
Использованы моки и параметризация
Покрытие pytest-cov: 88%

Copy link

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
Copy link

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()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Отлично: благодаря мокам тесты стали быстрее и управляемее, теперь они меньше зависят от внешних данных


def test_database_available_buns():
database = Database()
buns = database.available_buns()
Copy link

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
Copy link

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),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно лучше: надежнее тестировать параметр при остальных неизменных. Например тут тестируем имя, значит в параметризации должна менять только имя, а цена быть всегда одинаковой. Также имеет смысл тестировать разные КЭ а не только латинские буквы с пробелом

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants