Skip to content

задание 1#714

Open
anastasilugovec wants to merge 8 commits intoYandex-Practicum:mainfrom
anastasilugovec:main
Open

задание 1#714
anastasilugovec wants to merge 8 commits intoYandex-Practicum:mainfrom
anastasilugovec:main

Conversation

@anastasilugovec
Copy link

No description provided.

Copy link

Choose a reason for hiding this comment

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

Нужно исправить: из финального проекта нужно удалить все файлы и папки, которые не относятся к решению задачи

Copy link

Choose a reason for hiding this comment

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

не исправлено

ing.get_price.return_value = price
return ing

@pytest.fixture
Copy link

Choose a reason for hiding this comment

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

нужно исправить: в файле с тестами должны быть только тесты. фикстуры нужно расположить в conftest, а хэлперы в хэлперах

burg.move_ingredient(0, 2) # A -> позиция 2 -> [B, C, A]
assert burg.ingredients[0] is ing_b
assert burg.ingredients[1] is ing_c
assert burg.ingredients[2] is ing_a
Copy link

Choose a reason for hiding this comment

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

Нужно исправить: тест неатомарный. после ассерта уже не должно быть шагов, а каждый тест должен проверять какое то одно поведение приложения

assert f"(==== {bun.get_name()} ====)" in receipt
assert f"= {str(ing1.get_type()).lower()} {ing1.get_name()} =" in receipt
assert f"= {str(ing2.get_type()).lower()} {ing2.get_name()} =" in receipt
assert f"(==== {bun.get_name()} ====)" in receipt
Copy link

Choose a reason for hiding this comment

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

Нужно исправить: тест неатомарный. после ассерта уже не должно быть шагов, а каждый тест должен проверять какое то одно поведение приложения

Copy link

Choose a reason for hiding this comment

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

не исправлено

burger.add_ingredient(mock_ingredient)
burger.move_ingredient(0, 0) # пример перемещения, если есть такая логика
burger.remove_ingredient(0)
assert burger.ingredients == []
Copy link

Choose a reason for hiding this comment

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

нужно исправить: не все методы классы покрыты юнит тестами

Copy link

Choose a reason for hiding this comment

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

Нужно исправить: На каждый метод должен быть отдельный тест, вне зависимости, вызывается он в других тестах или нет
Сейчас не были созданы юнит тесты для:
move_ingredient
отдельные для add_ingredient и get_price()


def test_move_and_remove_ingredients_order(burger, mock_ingredient):
burger.add_ingredient(mock_ingredient)
burger.move_ingredient(0, 0) # пример перемещения, если есть такая логика
Copy link

Choose a reason for hiding this comment

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

тут перемещяем с 0 на 0?


def test_remove_ingredient_invalid_index(burger):
# Удаление по неправильному индексу
burger.remove_ingredient(999) 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_move_ingredient_invalid_index(burger):
# Передача неправильного индекса
with pytest.raises(IndexError):
burger.move_ingredient(0, 10)
Copy link

Choose a reason for hiding this comment

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

что тут проверили?

burger.add_ingredient(mock_ingredient)
burger.move_ingredient(0, 0) # пример перемещения, если есть такая логика
burger.remove_ingredient(0)
assert burger.ingredients == []
Copy link

Choose a reason for hiding this comment

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

Нужно исправить: На каждый метод должен быть отдельный тест, вне зависимости, вызывается он в других тестах или нет
Сейчас не были созданы юнит тесты для:
move_ingredient
отдельные для add_ingredient и get_price()

Choose a reason for hiding this comment

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

Необходимо исправить: эта директория лишняя в проекте. Необходимо убрать её из ветки и добавить в .gitignore в корне проекта

import pytest
from models import Burger

def test_get_price_without_ingredients_and_bun(burger, mock_bun):

Choose a reason for hiding this comment

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

Нужно исправить здесь и далее: Для корректного запуска тестов необходимо код с шагами теста поместить в тестовый метод (нейминг начинается с test_), а метод - в тестовый класс (нейминг начинается с Test). Необходимо привести к такому формату все модули внутри пакета tests

Comment on lines +58 to +62
assert f"(==== {mock_bun.get_name()} ====)" in receipt
ingredient_type = str(mock_ingredient.get_type()).lower()
ingredient_name = mock_ingredient.get_name()
assert f"= {ingredient_type} {ingredient_name}" in receipt
assert f"Price: {burger.get_price()}" in receipt No newline at end of file

Choose a reason for hiding this comment

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

Нужно исправить: проверка через in в данном кейсе не будет надёжной, необходимо проверить полное соответствие

@@ -0,0 +1,62 @@
import pytest
from models import Burger

Choose a reason for hiding this comment

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

Необходимо исправить: получилось, что тесты написаны на новый класс в новом модуле models. Необходимо использовать класс Burger из модуля praktikum.burger

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.

3 participants