generated from yandex-praktikum/qa_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Develop #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
Open
Mefite
wants to merge
2
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
Develop #5
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,33 @@ | ||
| # qa_python | ||
| # BooksCollector | ||
|
|
||
| ### Тесты: | ||
|
|
||
| 1. **test_add_new_book_title_length_limit** | ||
| Проверка допустимого количества символов в названии книги. | ||
|
|
||
| 2. **test_set_book_genre_set_invalid_genre** | ||
| Проверка, что нельзя установить недопустимый жанр | ||
|
|
||
| 3. **test_add_book_empty_genre** | ||
| Проверка, что у добавленной книги отсутсвует жанр | ||
|
|
||
| 4. **test_get_books_with_specific_genre** | ||
| Проверка, что можно вывести книги выбранного жанра | ||
|
|
||
| 5. **test_get_books_genre** | ||
| Проверка, что можно вывести текущий словарь | ||
|
|
||
| 6. **test_get_books_for_children** | ||
| Проверка, что можно вывести список детских книг | ||
|
|
||
| 7. **test_get_books_for_children_except_adult** | ||
| Проверка, что в списке детских книг отсутствуют жанры с возрастным рейтингом | ||
|
|
||
| 8. **test_add_book_in_favorites** | ||
| Проверка, что можно добавить книгу в список избранного | ||
|
|
||
| 9. **test_delete_book_from_favorites** | ||
| Проверка, что можно удалить книгу из списка избранного | ||
|
|
||
| 10. **test_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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| from main import BooksCollector | ||
| import pytest | ||
|
|
||
| # класс TestBooksCollector объединяет набор тестов, которыми мы покрываем наше приложение BooksCollector | ||
| # обязательно указывать префикс Test | ||
|
|
@@ -21,4 +22,82 @@ def test_add_new_book_add_two_books(self): | |
| assert len(collector.get_books_rating()) == 2 | ||
|
|
||
| # напиши свои тесты ниже | ||
| # чтобы тесты были независимыми в каждом из них создавай отдельный экземпляр класса BooksCollector() | ||
| # чтобы тесты были независимыми в каждом из них создавай отдельный экземпляр класса BooksCollector() | ||
|
|
||
| # Параметризованный тест на проверку допустимого количества символов в названии | ||
| @pytest.mark.parametrize('name, approve', [ | ||
| ('A', True), | ||
| ('B' * 40, True), | ||
| ('', False), | ||
| ('C' * 41, False) | ||
| ]) | ||
| def test_add_new_book_title_length_limit(self, name, approve): | ||
| collector = BooksCollector() | ||
| collector.add_new_book(name) | ||
|
|
||
| assert (name in collector.get_books_genre()) == approve | ||
|
|
||
| # Нельзя установить недопустимый жанр | ||
| def test_set_book_genre_set_invalid_genre(self): | ||
| collector = BooksCollector() | ||
| collector.add_new_book('Остров сокровищ') | ||
| collector.set_book_genre('Остров сокровищ', 'Приключения') | ||
| assert collector.get_book_genre('Остров сокровищ') == '' | ||
|
|
||
| # У добавленной книги отсутсвует жанр | ||
| def test_add_book_empty_genre(self): | ||
| collector = BooksCollector() | ||
| collector.add_new_book('Остров сокровищ') | ||
| assert collector.get_book_genre('Остров сокровищ') == '' | ||
|
|
||
| # Можно вывести книги выбранного жанра | ||
| def test_get_books_with_specific_genre(self): | ||
| collector = BooksCollector() | ||
| collector.add_new_book('Остров сокровищ') | ||
| collector.set_book_genre('Остров сокровищ', 'Мультфильмы') | ||
|
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 collector.get_books_with_specific_genre('Мультфильмы') == ['Остров сокровищ'] | ||
|
|
||
| # Можно вывести текущий словарь | ||
| def test_get_books_genre(self): | ||
| collector = BooksCollector() | ||
| collector.add_new_book('Остров сокровищ') | ||
| assert collector.get_books_genre() == {'Остров сокровищ': ''} | ||
|
|
||
| # Можно вывести список детских книг | ||
| def test_get_books_for_children(self): | ||
| collector = BooksCollector() | ||
| collector.add_new_book('Остров сокровищ') | ||
| collector.set_book_genre('Остров сокровищ', 'Мультфильмы') | ||
| assert 'Остров сокровищ' in collector.get_books_for_children() | ||
|
|
||
| #В списке детских книг отсутствуют жанры с возрастным рейтингом | ||
| def test_get_books_for_children_except_adult(self): | ||
| collector = BooksCollector() | ||
| collector.add_new_book('Оно') | ||
| collector.set_book_genre('Оно', 'Ужасы') | ||
| assert 'Оно' not in collector.get_books_for_children() | ||
|
|
||
| #Можно добавить книгу в избранное | ||
| def test_add_book_in_favorites(self): | ||
| collector = BooksCollector() | ||
| collector.add_new_book('Остров сокровищ') | ||
| collector.add_book_in_favorites('Остров сокровищ') | ||
| assert 'Остров сокровищ' in collector.get_list_of_favorites_books() | ||
|
|
||
| #Можно удалить книгу из избранного | ||
| def test_delete_book_from_favorites(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(self): | ||
| collector = BooksCollector() | ||
| collector.add_new_book('Остров сокровищ') | ||
| collector.add_book_in_favorites('Остров сокровищ') | ||
| 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.
Нужно исправить: нет такого метода у тестируемой программы, код проекта должен быть полностью рабочим