-
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?
Sprint_4 #5
Changes from all commits
552c480
1e63339
4e375ed
9f5d2df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,14 @@ | ||
| # qa_python | ||
| # qa_python | ||
| test_add_new_book_add_two_books - метод add_new_book добавляет две книги в словарь books_genre | ||
| test_add_new_book_name_longer_than40_not_added - метод add_new_book не добавляет книги в словарь books_genre с названием больше 40 символов (41 и 50) | ||
| test_set_book_genre_existing_book_genre_set - метод set_book_genre добавляет жанр существующей книге | ||
| test_get_book_genre_non_existing_book_none - метод get_book_genre не отображает отсутсвующие в списке books_genre книги | ||
| test_get_books_with_specific_genre_books_with_set_genre_returned - метод get_books_with_specific_genre возвращается список книг, по заданному жанру | ||
| test_get_books_genre_added_books_returned - метод get_books_genre возвращает books_genre с добавленными книгами | ||
| test_get_books_for_children_adult_genre_book_excluded - метод get_books_for_children не возвращает книгу с взрослым рейтингом | ||
| test_add_book_in_favorites_existing_book_added - метод add_book_in_favorites добавляет книгу в список избранного | ||
| test_delete_book_from_favorites_existing_book_deleted - метод delete_book_from_favorites удаляет присутствующую в списке избранного книгу | ||
| test_get_list_of_favorites_books_favorites_returned - метод get_list_of_favorites возвращает список избранных книг | ||
| test_add_new_book_existing_book_not_added - метод add_new_book не добавляет дубликат книги в словарь books_genre | ||
| test_add_new_book_name_is_40_symbols_added - метод add_new_book добавляет книгу с названием длиной в 40 символов в словарь books_genre | ||
| test_add_book_in_favorites_non_existing_book_not_added - метод add_book_in_favorites не добавляет в избранное книгу, которая не была добавлена в коллекцию |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| from main import BooksCollector | ||
| import pytest | ||
|
|
||
| # класс TestBooksCollector объединяет набор тестов, которыми мы покрываем наше приложение BooksCollector | ||
| # обязательно указывать префикс Test | ||
|
|
@@ -17,8 +18,93 @@ def test_add_new_book_add_two_books(self): | |
| collector.add_new_book('Что делать, если ваш кот хочет вас убить') | ||
|
|
||
| # проверяем, что добавилось именно две | ||
| # словарь books_rating, который нам возвращает метод get_books_rating, имеет длину 2 | ||
| assert len(collector.get_books_rating()) == 2 | ||
| # словарь books_genre, который нам возвращает метод get_books_genre, имеет длину 2 | ||
| assert len(collector.get_books_genre()) == 2 | ||
|
|
||
| # напиши свои тесты ниже | ||
| # чтобы тесты были независимыми в каждом из них создавай отдельный экземпляр класса BooksCollector() | ||
| # чтобы тесты были независимыми в каждом из них создавай отдельный экземпляр класса BooksCollector() | ||
| def test_add_new_book_name_is_40_symbols_added(self): | ||
| collector = BooksCollector() | ||
| book_name = 'А' * 40 | ||
| collector.add_new_book(book_name) | ||
| assert len(collector.get_books_genre()) == 1 | ||
|
|
||
| @pytest.mark.parametrize('book_name',['А' * 41,'Б' * 50]) | ||
| def test_add_new_book_name_longer_than40_not_added(self, book_name): | ||
| collector = BooksCollector() | ||
| collector.add_new_book(book_name) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Необходимо исправить: не хватает теста на повторное добавление книги |
||
| assert len(collector.get_books_genre()) == 0 | ||
|
|
||
| def test_add_new_book_existing_book_not_added(self): | ||
| collector = BooksCollector() | ||
| collector.add_new_book('Дюна') | ||
| collector.add_new_book('Дюна') | ||
| assert len(collector.get_books_genre()) == 1 | ||
|
|
||
| def test_set_book_genre_existing_book_genre_set(self): | ||
| collector = BooksCollector() | ||
| collector.add_new_book('Извилистый путь') | ||
| collector.set_book_genre('Извилистый путь', 'Комедии') | ||
| assert collector.get_book_genre('Извилистый путь') == 'Комедии' | ||
|
|
||
| def test_get_book_genre_non_existing_book_none(self): | ||
| collector = BooksCollector() | ||
| assert collector.get_book_genre('Голос между') is None | ||
|
|
||
| def test_get_books_with_specific_genre_books_with_set_genre_returned(self): | ||
| collector = BooksCollector() | ||
| collector.add_new_book('Split Fiction') | ||
| collector.add_new_book('Звездные войны') | ||
| collector.add_new_book('Песнь льда и пламени') | ||
| collector.set_book_genre('Split Fiction','Фантастика') | ||
| collector.set_book_genre('Звездные войны', 'Фантастика') | ||
| collector.set_book_genre('Песнь льда и пламени', 'Ужасы') | ||
| books = collector.get_books_with_specific_genre('Фантастика') | ||
| assert set (books) == {'Split Fiction', 'Звездные войны'} | ||
|
|
||
| def test_get_books_genre_added_books_returned(self): | ||
| collector = BooksCollector() | ||
| collector.add_new_book('Изгой') | ||
| collector.add_new_book('Достать ножи') | ||
| collector.set_book_genre('Изгой', 'Фантастика') | ||
| collector.set_book_genre('Достать ножи', 'Детективы') | ||
| books_genre = collector.get_books_genre() | ||
| expected = { | ||
| 'Изгой': 'Фантастика', | ||
| 'Достать ножи': 'Детективы' | ||
| } | ||
| assert books_genre == expected | ||
|
|
||
| def test_get_books_for_children_adult_genre_book_excluded(self): | ||
| collector = BooksCollector() | ||
| collector.add_new_book('Тетрадь смерти') | ||
| collector.set_book_genre('Тетрадь смерти', 'Ужасы') | ||
| books_for_children = collector.get_books_for_children() | ||
| assert 'Тетрадь смерти' not in books_for_children | ||
|
|
||
| def test_add_book_in_favorites_existing_book_added(self): | ||
| collector = BooksCollector() | ||
| collector.add_new_book('Властелин колец') | ||
| collector.add_book_in_favorites('Властелин колец') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Необходимо исправить: не хватает теста на добавление в избранное книги, которая не была добавлена в коллекцию |
||
| assert 'Властелин колец' in collector.get_list_of_favorites_books() | ||
|
|
||
| def test_add_book_in_favorites_non_existing_book_not_added(self): | ||
| collector = BooksCollector() | ||
| collector.add_book_in_favorites('Ветра зимы') | ||
| assert 'Ветра зимы' not in collector.get_list_of_favorites_books() | ||
|
|
||
| def test_delete_book_from_favorites_existing_book_deleted(self): | ||
| collector = BooksCollector() | ||
| collector.add_new_book('Гарри Поттер') | ||
| collector.add_book_in_favorites('Гарри Поттер') | ||
| collector.delete_book_from_favorites('Гарри Поттер') | ||
| assert 'Гарри Поттер' not in collector.get_list_of_favorites_books() | ||
|
|
||
| def test_get_list_of_favorites_books_favorites_returned(self): | ||
| collector = BooksCollector() | ||
| collector.add_new_book('Шерлок Холмс') | ||
| collector.add_new_book('Тени Орды') | ||
| collector.add_book_in_favorites('Шерлок Холмс') | ||
| collector.add_book_in_favorites('Тени Орды') | ||
| favorites = collector.get_list_of_favorites_books() | ||
| assert set(favorites) == {'Шерлок Холмс', 'Тени Орды'} | ||
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.
Необходимо исправить: не хватает теста на проверку границы в 40 символов