Skip to content

Conversation

@DimPonLe
Copy link
Owner

@DimPonLe DimPonLe commented Sep 9, 2025

Fitrst_load

tests.py Outdated
],
)
def test_add_new_book(name, expected):
collector = BooksCollector()

Choose a reason for hiding this comment

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

Можно улучшить: общее для всех тестов предусловие можно вынести в фикстуру

tests.py Outdated
if exception_type is None:
collector.set_book_genre(book_name, genre)
assert collector.get_book_genre(book_name) == genre, f"Жанр '{genre}' должен быть установлен."
else:

Choose a reason for hiding this comment

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

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

tests.py Outdated
collector.set_book_genre("Книга1", "Фантастика")
assert collector.get_book_genre("Книга1") == "Фантастика", "Вернуть правильный жанр."

assert collector.get_book_genre("НетТакойКниги") is None, "Отсутствие жанра должно вернуть None."
Copy link

@Ayantea1 Ayantea1 Sep 10, 2025

Choose a reason for hiding this comment

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

нужно исправить здесь и далее: в каждом тесте проверяем только один кейс

tests.py Outdated
collector = BooksCollector()
collector.add_new_book("Книга1")
collector.set_book_genre("Книга1", "Фантастика")
assert collector.get_book_genre("Книга1") == "Фантастика", "Вернуть правильный жанр."

Choose a reason for hiding this comment

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

Нужно исправить: тест аналогичен тесту set_book_genre. Попробуй установить значение жанра иначе, или иначе получить его для сравнения. Используй доступ к словарю

tests.py Outdated
favorites = collector.get_list_of_favorites_books()
assert "Книга1" in favorites, "Книга должна быть добавлена в избранное."

collector.delete_book_from_favorites("Книга1")

Choose a reason for hiding this comment

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

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

tests.py Outdated
collector.set_book_genre(book_name, invalid_genre)
assert collector.get_book_genre(book_name) == initial_genre, f"Некорректный жанр ('{invalid_genre}') изменил текущий жанр ('{initial_genre}')"

def test_internal_genre_storage(self, collector):

Choose a reason for hiding this comment

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

нужно исправить: список жанров не изменяется, тест некорректен

tests.py Outdated

def test_get_book_genre(self, collector):
collector._books = {"Книга1": None}
collector._genres = {"Книга1": "Фантастика"}
Copy link

@Ayantea1 Ayantea1 Sep 15, 2025

Choose a reason for hiding this comment

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

Идея верная, но тебе нужен словарь books_genre, указанных атрибутов у объекта нет

tests.py Outdated
assert genre == "Фантастика", "Метод get_book_genre возвращает неправильный жанр."

def test_get_books_genre(self, collector):
collector._books = {

Choose a reason for hiding this comment

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

аналогично предыдущему

tests.py Outdated
assert books_with_genres == expected_result, "Метод get_books_genre вернул некорректный список книг с жанрами."

def test_get_list_of_favorites_books(self, collector):
collector._favorites = ["Книга1", "Книга3"]

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.

3 participants