-
Notifications
You must be signed in to change notification settings - Fork 0
Задание четвертого спринта #8
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
vladimir-mtn
wants to merge
1
commit into
main
Choose a base branch
from
develop
base: main
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.
Open
Changes from all commits
Commits
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 |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| venv/ | ||
| env/ | ||
| ENV/ | ||
| .venv/ | ||
| .env/ | ||
| __pycache__/ | ||
| *.py[cod] | ||
| *$py.class | ||
| *.so | ||
| .Python | ||
| *.egg-info/ | ||
| dist/ | ||
| build/ | ||
| .pytest_cache/ | ||
| .pytest/ | ||
| *.pyc | ||
| .coverage | ||
| htmlcov/ | ||
| .vscode/ | ||
| .idea/ | ||
| *.swp | ||
| *.swo | ||
| *~ | ||
| .project | ||
| .pydevproject | ||
| .DS_Store | ||
| Thumbs.db | ||
| desktop.ini | ||
| *.log | ||
| *.tmp | ||
| *.bak | ||
| *.db | ||
| *.sqlite | ||
| .env.local |
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,33 @@ | ||
| # qa_python | ||
| # qa_python | ||
|
|
||
| ## Реализованные тесты | ||
|
|
||
| 1. **__init__** | ||
| - Проверка количества жанров | ||
|
|
||
| 2. **add_new_book** | ||
| - Добавление новой книги | ||
|
|
||
| 3. **set_book_genre** | ||
| - Установка несуществующего жанра | ||
|
|
||
| 4. **get_book_genre** | ||
| - Вывод жанра по имени книги | ||
|
|
||
| 5. **get_books_with_specific_genre** | ||
| - Вывод списка книг по определенному жанру | ||
|
|
||
| 6. **get_books_genre** | ||
| - Вывод текущего словаря | ||
|
|
||
| 7. **get_books_for_children** | ||
| - Вывод книг которые подходят детям | ||
|
|
||
| 8. **add_book_in_favorites** | ||
| - Добавление книги в избранное | ||
|
|
||
| 9. **delete_book_from_favorites** | ||
| - Удаление книги из избранного | ||
|
|
||
| 10. **get_list_of_favorites_books** | ||
| - Вывод списка избранных книг |
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,6 @@ | ||
| import pytest | ||
| from main import BooksCollector | ||
|
|
||
| @pytest.fixture | ||
| def collector(): | ||
| return BooksCollector() |
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,88 @@ | ||
| import pytest | ||
| from main import BooksCollector | ||
|
|
||
| # класс TestBooksCollector объединяет набор тестов, которыми мы покрываем наше приложение BooksCollector | ||
| # обязательно указывать префикс Test | ||
| class TestBooksCollector: | ||
|
|
||
| def test_init_has_correct_genres(self, collector): | ||
| assert collector.genre == ['Фантастика', 'Ужасы', 'Детективы', 'Мультфильмы', 'Комедии'] | ||
|
|
||
| # пример теста: | ||
| # обязательно указывать префикс test_ | ||
| # дальше идет название метода, который тестируем add_new_book_ | ||
| # затем, что тестируем add_two_books - добавление двух книг | ||
| def test_add_new_book_add_two_books(self): | ||
| # создаем экземпляр (объект) класса BooksCollector | ||
| collector = BooksCollector() | ||
| @pytest.mark.parametrize('book_name', [ | ||
| 'Эхо', | ||
| 'Зов Ктулху', | ||
| ]) | ||
|
|
||
| # добавляем две книги | ||
| collector.add_new_book('Гордость и предубеждение и зомби') | ||
| collector.add_new_book('Что делать, если ваш кот хочет вас убить') | ||
| def test_add_new_book_success(self, collector, book_name): | ||
| collector.add_new_book(book_name) | ||
| assert book_name in collector.books_genre | ||
|
|
||
| # проверяем, что добавилось именно две | ||
| # словарь books_rating, который нам возвращает метод get_books_rating, имеет длину 2 | ||
| assert len(collector.get_books_rating()) == 2 | ||
| def test_set_book_genre_invalid_genre_fail(self, collector): | ||
| book_name = 'Нейромант' | ||
|
|
||
| collector.add_new_book(book_name) | ||
| collector.set_book_genre(book_name, 'Киберпанк') | ||
| assert collector.get_book_genre(book_name) == '' | ||
|
|
||
| # напиши свои тесты ниже | ||
| # чтобы тесты были независимыми в каждом из них создавай отдельный экземпляр класса BooksCollector() | ||
| def test_get_book_genre_returns_correct_genre(self, collector): | ||
| book_name = 'Гиперион' | ||
| genre = 'Фантастика' | ||
|
|
||
| collector.add_new_book(book_name) | ||
| collector.set_book_genre(book_name, genre) | ||
| assert collector.get_book_genre(book_name) == genre | ||
|
|
||
| def test_get_books_with_specific_genre(self, collector): | ||
| book_name = 'Лавина' | ||
| genre = 'Фантастика' | ||
|
|
||
| collector.add_new_book(book_name) | ||
| collector.set_book_genre(book_name, genre) | ||
| assert collector.get_books_with_specific_genre(genre) == [book_name] | ||
|
|
||
| def test_get_books_genre_returns_correct_dictionary(self, collector): | ||
|
|
||
| book1 = 'Игра престолов' | ||
| book2 = 'Властелин колец' | ||
| book3 = 'Ведьмак' | ||
|
|
||
| collector.add_new_book(book1) | ||
| collector.add_new_book(book2) | ||
| collector.add_new_book(book3) | ||
| assert collector.get_books_genre() == {book1: '', book2: '', book3: ''} | ||
|
|
||
| def test_get_books_for_children(self, collector): | ||
|
|
||
| book_name = 'Вверх' | ||
| genre = 'Мультфильмы' | ||
|
|
||
| collector.add_new_book(book_name) | ||
| collector.set_book_genre(book_name, genre) | ||
| assert book_name in collector.get_books_for_children() | ||
|
|
||
| def test_add_book_in_favorites_success(self, collector): | ||
|
|
||
| book_name = 'Властелин колец' | ||
|
|
||
| collector.add_new_book(book_name) | ||
| collector.add_book_in_favorites(book_name) | ||
| assert book_name in collector.get_list_of_favorites_books() | ||
|
|
||
| def test_delete_book_from_favorites_success(self, collector): | ||
|
|
||
| book_name = 'Молчание' | ||
|
|
||
| collector.add_new_book(book_name) | ||
| collector.add_book_in_favorites(book_name) | ||
| collector.delete_book_from_favorites(book_name) | ||
| assert book_name not in collector.get_list_of_favorites_books() | ||
|
|
||
| def test_get_list_of_favorites_books_returns_correct_list(self, collector): | ||
|
|
||
| book1 = 'Рельсы' | ||
| book2 = 'Эндимион' | ||
|
|
||
| collector.add_new_book(book1) | ||
| collector.add_new_book(book2) | ||
| collector.add_book_in_favorites(book1) | ||
| collector.add_book_in_favorites(book2) | ||
|
|
||
| assert collector.get_list_of_favorites_books() == [book1, book2] | ||
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.
Не хватает негативного теста - пустое название либо слишком длинное
Также не забываем про граничные кейсы (1 символ, 40 символов)