Coverage for books/tests/test_views.py: 100.00%
21 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-04 11:03 -0700
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-04 11:03 -0700
1from django.test import TestCase 1a
2from django.urls import reverse 1a
4from ..models import Book 1a
7class BookTests(TestCase): 1a
8 @classmethod 1a
9 def setUpTestData(cls): 1a
10 cls.book = Book.objects.create( 1a
11 title="Code Complete",
12 subtitle="A handbook of software construction",
13 author="Steve McConnell",
14 pages="952",
15 publisher="Microsoft Press",
16 pubdate="2004-03-29",
17 price="65.72",
18 isbn="0735619670",
19 )
21 def test_book_content(self): 1a
22 self.assertEqual(self.book.title, "Code Complete") 1a
23 self.assertEqual(self.book.subtitle, "A handbook of software construction") 1a
24 self.assertEqual(self.book.author, "Steve McConnell") 1a
25 self.assertEqual(self.book.pages, "952") 1a
26 self.assertEqual(self.book.publisher, "Microsoft Press") 1a
27 self.assertEqual(self.book.pubdate, "2004-03-29") 1a
28 self.assertEqual(self.book.price, "65.72") 1a
29 self.assertEqual(self.book.isbn, "0735619670") 1a
31 def test_book_listview(self): 1a
32 response = self.client.get(reverse("booklist")) 1a
33 self.assertEqual(response.status_code, 200) 1a
34 self.assertContains(response, "A handbook of software construction") 1a
35 self.assertTemplateUsed(response, "books/book_list.html") 1a