-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.py
More file actions
71 lines (57 loc) · 2.87 KB
/
tests.py
File metadata and controls
71 lines (57 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from main import BooksCollector
import pytest
class TestBooksCollector:
def test_add_new_book_add_two_books(self):
collector = BooksCollector()
collector.add_new_book('Гордость и предубеждение и зомби')
collector.add_new_book('Что делать, если ваш кот хочет вас убить')
assert len(collector.get_books_rating()) == 2
def test_add_new_book_identical_books_one_book_added(self,book_name):
collector = BooksCollector()
collector.add_new_book(book_name)
collector.add_new_book(book_name)
assert len(collector.get_books_rating()) == 1
def test_set_rating_book_is_not_on_the_list_not_setting(self, book_rating):
collector = BooksCollector()
collector.set_book_rating('Горе от ума', book_rating)
assert collector.get_book_rating('Горе от ума') is None
@pytest.mark.parametrize(
'rating',[-1,11,0]
)
def test_set_rating_book_less_than_1_or_set_rating_book_more_than_10_not_setting(self, book_name,rating):
collector = BooksCollector()
collector.add_new_book(book_name)
collector.set_book_rating(book_name, rating)
assert collector.get_book_rating(book_name) == 1
def test_added_book_has_no_rating_setting_rating_by_default(self, book_name):
collector = BooksCollector()
collector.add_new_book(book_name)
assert collector.get_book_rating(book_name) == 1
def test_add_book_in_list_of_favorites_books_book_added(self, book_name):
collector = BooksCollector()
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_in_list_of_favorites_books_book_deleted(self, book_name):
collector = BooksCollector()
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_cannot_add_a_book_to_list_of_favorites_books_if_it_is_not_in_the_books_rating_book_not_added(self, book_name):
collector = BooksCollector()
collector.add_book_in_favorites(book_name)
assert len(collector.get_list_of_favorites_books()) == 0
@pytest.mark.parametrize(
'books , rating',
[
['Горе от ума', 9],
['Фауст', 8],
['Мертвые души', 5]
]
)
def test_get_book_with_specific_rating_book_gets(self, books, rating):
collector = BooksCollector()
collector.add_new_book(books)
collector.set_book_rating(books, rating)
assert books in collector.get_books_with_specific_rating(rating)