Coverage for books/tests/test_core.py: 100.00%
0 statements
« prev ^ index » next coverage.py v7.9.2, created at 2025-07-16 12:21 -0700
« prev ^ index » next coverage.py v7.9.2, created at 2025-07-16 12:21 -0700
1"""
2Note: These tests were used prior to implementing BookFactory
4from django.test import TestCase
6from .models import Book
9class BookModelTest(TestCase):
10 @classmethod
11 def setUpTestData(cls):
12 Book.objects.create(
13 title="Django for APIs",
14 subtitle="Build web APIs with Python & Django",
15 author="William S. Vincent",
16 isbn="1093633948",
17 )
19 def test_book___str__(self):
20 book = Book.objects.get(id=1)
21 self.assertEqual(str(book), book.title)
23 def test_title_content(self):
24 book = Book.objects.get(id=1)
25 expected_object_name = f"{book.title}"
26 self.assertEqual(expected_object_name, "Django for APIs")
28 def test_subtitle_content(self):
29 book = Book.objects.get(id=1)
30 expected_object_name = f"{book.subtitle}"
31 self.assertEqual(
32 expected_object_name, "Build web APIs with Python & Django"
33 )
35 def test_author_content(self):
36 book = Book.objects.get(id=1)
37 expected_object_name = f"{book.author}"
38 self.assertEqual(expected_object_name, "William S. Vincent")
40 def test_isbn_content(self):
41 book = Book.objects.get(id=1)
42 expected_object_name = f"{book.isbn}"
43 self.assertEqual(expected_object_name, "1093633948")
44"""