-
Notifications
You must be signed in to change notification settings - Fork 0
Sprint_4 #5
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.py
Outdated
| ], | ||
| ) | ||
| def test_add_new_book(name, expected): | ||
| collector = BooksCollector() |
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.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: |
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.py
Outdated
| collector.set_book_genre("Книга1", "Фантастика") | ||
| assert collector.get_book_genre("Книга1") == "Фантастика", "Вернуть правильный жанр." | ||
|
|
||
| assert collector.get_book_genre("НетТакойКниги") is None, "Отсутствие жанра должно вернуть None." |
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.py
Outdated
| collector = BooksCollector() | ||
| collector.add_new_book("Книга1") | ||
| collector.set_book_genre("Книга1", "Фантастика") | ||
| assert collector.get_book_genre("Книга1") == "Фантастика", "Вернуть правильный жанр." |
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.
Нужно исправить: тест аналогичен тесту set_book_genre. Попробуй установить значение жанра иначе, или иначе получить его для сравнения. Используй доступ к словарю
tests.py
Outdated
| favorites = collector.get_list_of_favorites_books() | ||
| assert "Книга1" in favorites, "Книга должна быть добавлена в избранное." | ||
|
|
||
| collector.delete_book_from_favorites("Книга1") |
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.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): |
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.py
Outdated
|
|
||
| def test_get_book_genre(self, collector): | ||
| collector._books = {"Книга1": None} | ||
| collector._genres = {"Книга1": "Фантастика"} |
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.
Идея верная, но тебе нужен словарь books_genre, указанных атрибутов у объекта нет
tests.py
Outdated
| assert genre == "Фантастика", "Метод get_book_genre возвращает неправильный жанр." | ||
|
|
||
| def test_get_books_genre(self, collector): | ||
| collector._books = { |
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.py
Outdated
| assert books_with_genres == expected_result, "Метод get_books_genre вернул некорректный список книг с жанрами." | ||
|
|
||
| def test_get_list_of_favorites_books(self, collector): | ||
| collector._favorites = ["Книга1", "Книга3"] |
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.
аналогично предыдущим
Fitrst_load