Esempio n. 1
0
    def test_list_books_returns_books_with_reviews(self):
        author = AuthorFactory()
        books_with_reviews = ReviewFactory.create_batch(2, authors=[author,])
        books_without_reviews = BookFactory.create_batch(4, authors=[author,])

        response = self.client.get(reverse(list_books))
        books = list(response.context['books'])
        self.assertEquals(books, books_with_reviews)
        self.assertNotEquals(books, books_without_reviews)
Esempio n. 2
0
    def test_list_books_retrurns_books_with_reviews(self):
        # Setup our data
        author = AuthorFactory()
        books_with_reviews = ReviewFactory.create_batch(2, authors=[author,])
        books_without_reviews = BookFactory.create_batch(4, authors=[author,])

        response = self.client.get(reverse(list_books))
        books = list(response.context['books'])

        self.assertEqual(books_with_reviews, books)
        self.assertNotEqual(books_without_reviews, books)
Esempio n. 3
0
    def test_list_books_returns_books_with_reviews(self):
        # this view only returns books with a review
        # so we test another thing, we make a set of reviewed books and a set of
        # not reviewed books and test.
        author = AuthorFactory()
        books_with_reviews = ReviewFactory.create_batch(2, authors=[
            author,
        ])
        books_without_reviews = BookFactory.create_batch(4, authors=[
            author,
        ])

        response = self.client.get(reverse(list_books))
        books = list(response.context['books'])

        self.assertEqual(books_with_reviews, books)
        self.assertNotEqual(books_without_reviews, books)