Skip to content

Comments

Финальный проект 4 спринта#5

Open
mdkudino wants to merge 6 commits intomainfrom
develop
Open

Финальный проект 4 спринта#5
mdkudino wants to merge 6 commits intomainfrom
develop

Conversation

@mdkudino
Copy link
Owner

@mdkudino mdkudino commented Aug 2, 2025

Добавлены тесты к приложению BooksCollector

tests.py Outdated
'Ехала машина полный бак бензина ехала ехала и в гараж заехала',
'По поля по полям синий трактор едет к нам'])
def test_add_new_book_title_greater_than40_unsuccessfull(self, name):
collector = BooksCollector()
Copy link

Choose a reason for hiding this comment

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

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

Copy link
Owner Author

Choose a reason for hiding this comment

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

Создание объекта BooksCollector вынесено в фикстуру

tests.py Outdated
collector.add_new_book(name)
collector.set_book_genre(name, genre)

assert len(collector.get_books_genre()) == 1
Copy link

Choose a reason for hiding this comment

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

Нужно исправить здесь и далее: лишняя проверка. Добавление в словарь проверяется для метода add_new_book в тесте test_add_new_book_title_less_than40_successfull

Copy link
Owner Author

Choose a reason for hiding this comment

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

Убраны лишние проверки

tests.py Outdated
assert len(collector.get_books_genre()) == 1
assert collector.get_book_genre(name) == ''

def test_get_book_genre_not_from_list_empty_string(self):
Copy link

Choose a reason for hiding this comment

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

Нужно исправить: для get_book_genre должен быть отдельный тест позитивного сценария. Тесты не должны дублировать друг друга. В идеале - чтобы в каждом тесте использовался только один проверяемый метод, все остальное можно получить прямым доступом к словарям и спискам

Copy link
Owner Author

Choose a reason for hiding this comment

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

Добавлены тесты для позитивных сценариев функций get...()

tests.py Outdated
name = 'Гордость и предубеждение'
genre = 'Детективы'
collector.add_new_book(name)
collector.set_book_genre(name, genre)
Copy link

Choose a reason for hiding this comment

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

можно улучшить: для добавления в избранное не обязательно устанавливать жанр

Copy link
Owner Author

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