Skip to content

Sprint_2#3

Open
JaneM00 wants to merge 3 commits intomainfrom
Develop
Open

Sprint_2#3
JaneM00 wants to merge 3 commits intomainfrom
Develop

Conversation

@JaneM00
Copy link
Owner

@JaneM00 JaneM00 commented Mar 14, 2025

No description provided.


class TestBooksCollector(unittest.TestCase):

def setUp(self):

Choose a reason for hiding this comment

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

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


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

Choose a reason for hiding this comment

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

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

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

Choose a reason for hiding this comment

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

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

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"), "Ужасы")

Choose a reason for hiding this comment

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

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


class TestBooksCollector(unittest.TestCase):

def setUp(self):

Choose a reason for hiding this comment

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

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

collector = BooksCollector()
collector.add_new_book("The Shining")
collector.set_book_genre("The Shining", "Ужасы")
assert collector.get_book_genre("The Shining") == "Ужасы"

Choose a reason for hiding this comment

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

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

assert collector.get_list_of_favorites_books() == []


if __name__ == '__main__':

Choose a reason for hiding this comment

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

Можно убрать

expected = {"War and Peace": "Classic"}
assert result == expected

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

Choose a reason for hiding this comment

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

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

@@ -0,0 +1,83 @@
import unittest

class TestBooksCollector(unittest.TestCase):

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

Comments