-
Notifications
You must be signed in to change notification settings - Fork 27
Sprint_4 #13
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
Open
vladslav-ya
wants to merge
2
commits into
yandex-praktikum:develop
Choose a base branch
from
vladslav-ya:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+167
−14
Open
Sprint_4 #13
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,27 @@ | ||
| # qa_python | ||
| 1. test_add_new_book_add_two_books - Проверяет, что можно добавить две разные книги | ||
|
|
||
| 2. test_add_new_book_duplicate_not_added - Проверяет, что дубликат книги не добавляется | ||
|
|
||
| 3. test_add_new_book_empty_name - Проверяет, что книга с пустым названием не добавляется | ||
|
|
||
| 4. test_add_new_book_41_symbol_name - Проверяет, что название длиннее 41 символа не добавляется | ||
|
|
||
| 5. test_set_book_genre_set_six_genre - Проверяет, что жанр устанавливается корректно для разных книг | ||
|
|
||
| 6. test_get_book_genre_return_added_genre - Проверяет, что возвращается корректный жанр книги | ||
|
|
||
| 7. test_get_books_with_specific_genre_six_genre - Проверяет, что возвращается правильный список книг по жанру | ||
|
|
||
| 8. test_get_books_genre_return_dict - Проверяет, что возвращается корректный словарь books_genre | ||
|
|
||
| 9. test_get_books_for_children_get_list - Проверяет, что возвращаются только книги без возрастного рейтинга | ||
|
|
||
| 10. test_add_book_in_favorites_add_two_books - Проверяет добавление книг в избранное | ||
|
|
||
| 11. test_delete_book_from_favorites_add_two_books_delete_one - Проверяет удаление одной из двух избранных книг | ||
|
|
||
| 12. test_delete_book_from_favorites_deleted_book_not_in_list - Проверяет, что попытка удалить несуществующую книгу не влияет на список | ||
|
|
||
| 13. test_get_list_of_favorites_books_return_added_books - Проверяет, что возвращаются ранее добавленные в список книги | ||
|
|
||
| 14. test_get_list_of_favorites_books_returns_empty_list - Проверяет, что возвращается пустой список, если нет избранных книг |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import pytest | ||
| from main import BooksCollector | ||
| from data import BOOKS_DATA | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def collector_with_books(): | ||
| collector = BooksCollector() | ||
| for name, genre in BOOKS_DATA: | ||
| collector.add_new_book(name) | ||
| collector.set_book_genre(name, genre) | ||
| return collector |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| BOOKS_DATA = [["Тень за стеной", "Ужасы"], | ||
| ["Лабиринт будущего", "Фантастика"], ["Улика в тумане", "Детективы"], | ||
| ["Смех в мультивселенной", "Комедии"], ["Приключения плюшевого мишки", "Мультфильмы"]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,136 @@ | ||
| import pytest | ||
| from main import BooksCollector | ||
| from data import BOOKS_DATA | ||
|
|
||
|
|
||
| # класс TestBooksCollector объединяет набор тестов, которыми мы покрываем наше приложение BooksCollector | ||
| # обязательно указывать префикс Test | ||
| class TestBooksCollector: | ||
|
|
||
| # пример теста: | ||
| # обязательно указывать префикс test_ | ||
| # дальше идет название метода, который тестируем add_new_book_ | ||
| # затем, что тестируем add_two_books - добавление двух книг | ||
| def test_add_new_book_add_two_books(self): | ||
| # создаем экземпляр (объект) класса BooksCollector | ||
| collector = BooksCollector() | ||
|
|
||
| # добавляем две книги | ||
| collector.add_new_book('Гордость и предубеждение и зомби') | ||
| collector.add_new_book('Что делать, если ваш кот хочет вас убить') | ||
|
|
||
| # проверяем, что добавилось именно две | ||
| # словарь books_rating, который нам возвращает метод get_books_rating, имеет длину 2 | ||
| assert len(collector.get_books_rating()) == 2 | ||
| assert len(collector.get_books_genre()) == 2 | ||
|
|
||
| def test_add_new_book_duplicate_not_added(self): | ||
| collector = BooksCollector() | ||
|
|
||
| collector.add_new_book('Гордость и предубеждение и зомби') | ||
| collector.add_new_book('Гордость и предубеждение и зомби') | ||
|
|
||
| assert len(collector.get_books_genre()) == 1 | ||
|
|
||
| def test_add_new_book_empty_name(self): | ||
| collector = BooksCollector() | ||
|
|
||
| collector.add_new_book('') | ||
|
|
||
| assert len(collector.get_books_genre()) == 0 | ||
|
|
||
| def test_add_new_book_41_symbol_name(self): | ||
| collector = BooksCollector() | ||
| name = 'B' * 41 | ||
|
|
||
| collector.add_new_book(name) | ||
|
|
||
| assert len(collector.get_books_genre()) == 0 | ||
|
|
||
| @pytest.mark.parametrize('name, genre', BOOKS_DATA) | ||
| def test_set_book_genre_set_six_genre(self, name, genre): | ||
| collector = BooksCollector() | ||
|
|
||
| collector.add_new_book(name) | ||
|
|
||
| collector.set_book_genre(name, genre) | ||
|
|
||
| assert collector.get_book_genre(name) == genre | ||
|
|
||
| def test_get_book_genre_return_added_genre(self, collector_with_books): | ||
| collector = collector_with_books | ||
|
|
||
| assert collector.get_book_genre('Лабиринт будущего') == 'Фантастика' | ||
| assert collector.get_book_genre('Приключения плюшевого мишки') == 'Мультфильмы' | ||
|
|
||
| @pytest.mark.parametrize('name, genre', BOOKS_DATA) | ||
| def test_get_books_with_specific_genre_six_genre(self, name, genre, collector_with_books): | ||
| collector = collector_with_books | ||
|
|
||
| books = collector.get_books_with_specific_genre(genre) | ||
|
|
||
| assert len(books) == 1 and books[0] == name | ||
|
|
||
| def test_get_books_genre_return_dict(self, collector_with_books): | ||
| collector = collector_with_books | ||
| data_dict = { | ||
| "Тень за стеной": "Ужасы", | ||
| "Лабиринт будущего": "Фантастика", | ||
| "Улика в тумане": "Детективы", | ||
| "Смех в мультивселенной": "Комедии", | ||
| "Приключения плюшевого мишки": "Мультфильмы" | ||
| } | ||
|
|
||
| assert collector.get_books_genre() == data_dict | ||
|
|
||
| def test_get_books_for_children_get_list(self, collector_with_books): | ||
| collector = collector_with_books | ||
|
|
||
| list_books = collector.get_books_for_children() | ||
|
|
||
| assert set(list_books) == {'Лабиринт будущего', 'Смех в мультивселенной', 'Приключения плюшевого мишки'} | ||
|
|
||
| def test_add_book_in_favorites_add_two_books(self, collector_with_books): | ||
| first_book = 'Тень за стеной' | ||
| second_book = 'Приключения плюшевого мишки' | ||
| collector = collector_with_books | ||
|
|
||
| collector.add_book_in_favorites(first_book) | ||
| collector.add_book_in_favorites(second_book) | ||
|
|
||
| list_favorite_books = collector.get_list_of_favorites_books() | ||
|
|
||
| assert set(list_favorite_books) == {first_book, second_book} | ||
|
|
||
| def test_delete_book_from_favorites_add_two_books_delete_one(self, collector_with_books): | ||
| first_book = 'Тень за стеной' | ||
| second_book = 'Приключения плюшевого мишки' | ||
| collector = collector_with_books | ||
|
|
||
| collector.add_book_in_favorites(first_book) | ||
| collector.add_book_in_favorites(second_book) | ||
|
|
||
| collector.delete_book_from_favorites(first_book) | ||
|
|
||
| favorite_book = collector.get_list_of_favorites_books() | ||
|
|
||
| assert favorite_book == [second_book] | ||
|
|
||
| def test_delete_book_from_favorites_deleted_book_not_in_list(self, collector_with_books): | ||
| first_book = 'Тень за стеной' | ||
| second_book = 'Приключения плюшевого мишки' | ||
| collector = collector_with_books | ||
|
|
||
| collector.add_book_in_favorites(first_book) | ||
| collector.add_book_in_favorites(second_book) | ||
|
|
||
| collector.delete_book_from_favorites('Смех в мультивселенной') | ||
|
|
||
| list_favorite_books = collector.get_list_of_favorites_books() | ||
|
|
||
| assert set(list_favorite_books) == {first_book, second_book} | ||
|
|
||
| def test_get_list_of_favorites_books_return_added_books(self, collector_with_books): | ||
| first_book = 'Улика в тумане' | ||
| second_book = 'Смех в мультивселенной' | ||
| collector = collector_with_books | ||
|
|
||
| collector.add_book_in_favorites(first_book) | ||
| assert collector.get_list_of_favorites_books() == [first_book] | ||
|
|
||
| collector.add_book_in_favorites(second_book) | ||
| assert set(collector.get_list_of_favorites_books()) == {first_book, second_book} | ||
|
|
||
| def test_get_list_of_favorites_books_returns_empty_list(self, collector_with_books): | ||
| collector = collector_with_books | ||
|
|
||
| # напиши свои тесты ниже | ||
| # чтобы тесты были независимыми в каждом из них создавай отдельный экземпляр класса BooksCollector() | ||
| assert collector.get_list_of_favorites_books() == [] | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Нужно исправить: отсутствуют тесты на проверку методов get_book_genre и get_list_of_favorites_books