-
Notifications
You must be signed in to change notification settings - Fork 0
Sprint_4 #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
sanchos357-bit
wants to merge
4
commits 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
Sprint_4 #8
Changes from all commits
Commits
Show all changes
4 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 |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| .vscode/ | ||
| __pycache__/main.cpython-314.pyc | ||
| __pycache__/tests.cpython-314-pytest-9.0.2.pyc | ||
| __pycache__/conftest.cpython-314-pytest-9.0.2.pyc | ||
| conftest.py |
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,8 @@ | ||
| # qa_python | ||
| # qa_python | ||
| # 1. test_set_book_genre_set_know_genre_book_added - Проверка метода установки жанра книги, если книга есть в books_genre и её жанр входит в список genre | ||
| # 2. test_get_book_genre_know_book_get_genre_done - Проверка метода вывода жанра книги по её имени + получение словаря books_genre | ||
| # 3. test_get_books_with_specific_genre_know_genre_get_book_done - Проверка метода вывода списка книг с определённым жанром | ||
| # 4. test_get_books_for_children_add_two_books_one_book_added - Проверка метода возврата книг, которые подходят детям | ||
| # 5. test_add_book_in_favorites_add_one_book_book_added - Проверка метода добавления книги в избранное + получение списка избранных книг | ||
| # 6. test_delete_book_from_favorites_delete_one_book_book_deleted - Проверка удаления книги из избранного | ||
| # 7. test_positive_input(name) - Проверка добавления книги с количеством символов в названии (1,2,20,39,40) |
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
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,66 @@ | ||
| from main import BooksCollector | ||
| import pytest | ||
|
|
||
| # класс TestBooksCollector объединяет набор тестов, которыми мы покрываем наше приложение BooksCollector | ||
| # обязательно указывать префикс Test | ||
| class TestBooksCollector: | ||
|
|
||
| # пример теста: | ||
| # обязательно указывать префикс test_ | ||
| # дальше идет название метода, который тестируем add_new_book_ | ||
| # затем, что тестируем add_two_books - добавление двух книг | ||
| def test_add_new_book_add_two_books(self): | ||
| # создаем экземпляр (объект) класса BooksCollector | ||
| collector = BooksCollector() | ||
| def test_add_new_book_add_two_books_books_added(self, collector): | ||
| collector.add_new_book('Гордость и предубеждение и зомби') | ||
| collector.add_new_book('Что делать, если ваш кот хочет вас убить') | ||
|
|
||
| assert len(collector.get_books_genre()) == 2 | ||
|
|
||
| def test_set_book_genre_set_know_genre_book_added(self, collector): | ||
| collector.add_new_book('Гордость и предубеждение и зомби') | ||
| collector.set_book_genre('Гордость и предубеждение и зомби', 'Ужасы') | ||
|
|
||
| assert collector.get_books_genre() == {'Гордость и предубеждение и зомби': 'Ужасы'} | ||
|
|
||
| def test_get_book_genre_know_book_get_genre_done(self, collector): | ||
| collector.add_new_book('Гордость и предубеждение и зомби') | ||
| collector.set_book_genre('Гордость и предубеждение и зомби', 'Ужасы') | ||
| collector.get_book_genre('Гордость и предубеждение и зомби') | ||
|
|
||
| assert collector.books_genre.get('Гордость и предубеждение и зомби') == 'Ужасы' | ||
|
|
||
| def test_get_books_with_specific_genre_know_genre_get_book_done(self, collector): | ||
| collector.add_new_book('Гордость и предубеждение и зомби') | ||
| collector.set_book_genre('Гордость и предубеждение и зомби', 'Ужасы') | ||
|
|
||
| # добавляем две книги | ||
| books_with_genre = collector.get_books_with_specific_genre('Ужасы') | ||
| assert 'Гордость и предубеждение и зомби' in books_with_genre | ||
|
|
||
| def test_get_books_for_children_add_two_books_one_book_added(self, collector): | ||
| collector.add_new_book('Гордость и предубеждение и зомби') | ||
| collector.set_book_genre('Гордость и предубеждение и зомби', 'Ужасы') | ||
| collector.add_new_book('Что делать, если ваш кот хочет вас убить') | ||
| collector.set_book_genre('Что делать, если ваш кот хочет вас убить', 'Комедии') | ||
|
|
||
| books_for_children = collector.get_books_for_children() | ||
| assert len(books_for_children) == 1 and 'Что делать, если ваш кот хочет вас убить' in books_for_children | ||
|
|
||
| def test_add_book_in_favorites_add_one_book_book_added(self, collector): | ||
| collector.add_new_book('Гордость и предубеждение и зомби') | ||
| collector.add_book_in_favorites('Гордость и предубеждение и зомби') | ||
|
|
||
| assert 'Гордость и предубеждение и зомби' in collector.get_list_of_favorites_books() | ||
|
|
||
| def test_delete_book_from_favorites_delete_one_book_book_deleted(self, collector): | ||
| collector.add_new_book('Гордость и предубеждение и зомби') | ||
| collector.add_book_in_favorites('Гордость и предубеждение и зомби') | ||
| collector.delete_book_from_favorites('Гордость и предубеждение и зомби') | ||
|
|
||
| assert collector.get_list_of_favorites_books() == [] | ||
|
|
||
| def test_get_books_genre_get_list_books_genre_list_geted(self, collector): | ||
| collector.add_new_book('Гордость и предубеждение и зомби') | ||
| collector.set_book_genre('Гордость и предубеждение и зомби', 'Ужасы') | ||
| assert collector.get_books_genre() == {'Гордость и предубеждение и зомби': 'Ужасы'} | ||
|
|
||
|
|
||
|
|
||
| # проверяем, что добавилось именно две | ||
| # словарь books_rating, который нам возвращает метод get_books_rating, имеет длину 2 | ||
| assert len(collector.get_books_rating()) == 2 | ||
| @pytest.mark.parametrize('name', ['Я','Он','Дети завтрашнего дня','Дети завтрашнего дняПиксельпутеводитель','Компания с ограниченной ответственностью']) | ||
| def test_add_new_book_positive_input_name_with_different_number_characters(self, collector, name): | ||
| collector.add_new_book(name) | ||
|
|
||
| assert len(collector.get_books_genre()) == 1 | ||
|
|
||
| # напиши свои тесты ниже | ||
| # чтобы тесты были независимыми в каждом из них создавай отдельный экземпляр класса BooksCollector() | ||
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_books_genre. На каждый метод должен быть отдельный тест, вне зависимости, вызывается он в других тестах или нет