Skip to content

Sprint_2#3

Open
JaneM00 wants to merge 3 commits into
mainfrom
Develop
Open

Sprint_2#3
JaneM00 wants to merge 3 commits into
mainfrom
Develop

Conversation

@JaneM00

@JaneM00 JaneM00 commented Mar 14, 2025

Copy link
Copy Markdown
Owner

No description provided.

Comment thread tests

class TestBooksCollector(unittest.TestCase):

def setUp(self):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно исправить: объект класса BooksCollector() нужно создавать для каждого теста. Чтобы не дублировать код, можно вынести это в фикстуру

Comment thread tests

# Тест на добавление новых книг
def test_add_new_book(self):
self.collector.add_new_book("1984")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно исправить: ты указываешь объект, self для вызова не требуется. Так же он не требуется для вызова ассертов - это не методы объекта

Comment thread tests
# Тест на добавление книги, превышающей максимальную длину
def test_add_new_book_too_long_name(self):
self.collector.add_new_book("A" * 41)
self.assertNotIn("A" * 41, self.collector.books_genre)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно улучшить: этот тест не исключает, что название обрезается

Comment thread tests
def test_get_book_genre(self):
self.collector.add_new_book("The Shining")
self.collector.set_book_genre("The Shining", "Ужасы")
self.assertEqual(self.collector.get_book_genre("The Shining"), "Ужасы")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно исправить: тест не отличается от предыдущего. Подумай, как иначе ты можешь убедится, что get_book_genre возвращает именно то значение, которое есть в словаре

Comment thread create tests 2

class TestBooksCollector(unittest.TestCase):

def setUp(self):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно исправить: тут ничего не происходит, метод можно удалить

Comment thread create tests 2
collector = BooksCollector()
collector.add_new_book("The Shining")
collector.set_book_genre("The Shining", "Ужасы")
assert collector.get_book_genre("The Shining") == "Ужасы"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно исправить: тест не отличается от проверки set метода. Чтобы методы не проверяли друг друга, сравни полученное с состоянием словаря

Comment thread create tests 2
assert collector.get_list_of_favorites_books() == []


if __name__ == '__main__':

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно убрать

Comment thread create tests 2
expected = {"War and Peace": "Classic"}
assert result == expected

# Дополнительный тест для метода get_list_of_favorites_books

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно исправить: обязательно должен быть тест на основной положительный сценарий. То есть проверка, что метод действительно возвращает список избранных книг

Comment thread tests
@@ -0,0 +1,83 @@
import unittest

class TestBooksCollector(unittest.TestCase):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно исправить: тестовый класс должен быть один. После ревью нужно внести изменения в существующий класс, а не добавлять новый

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants