def test_review_list_returns_books_to_review(self): # Setup our data books_without_reviews = BookFactory.create_batch(2, authors=[self.author, ]) self.client.login(username="******", password="******") response = self.client.get(reverse('review-books')) books = list(response.context['books']) self.assertEqual(books, books_without_reviews)
def test_review_list_returns_books_to_review(self): # Setup our data books_without_reviews = BookFactory.create_batch(2, authors=[self.author,]) self.client.login(username="******", password="******") response = self.client.get(reverse('review-books')) books = list(response.context['books']) self.assertEqual(books, books_without_reviews)
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)
def test_review_list_returns_books_to_review(self): # set up data books_without_reviews = BookFactory.create_batch(4) self.client.login(username='******', password='******') response = self.client.get(reverse('review-books')) books_to_test = list(response.context['books']) self.assertEqual(books_to_test, books_without_reviews)
def test_review_list_returns_books_to_review(self): # Setup the data books_without_reviews = BookFactory.create_batch(2, authors=[self.author,]) c = Client() loginStatus = c.login(username='******', password='******') response = c.get(reverse('review-books')) books = list(response.context['books']) self.assertEqual(books_without_reviews, books)
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)
def test_list(self): """ Make sure that list method is working as expected. """ number_of_books = 5 author = UserFactory() # Use the same author, rather than creating a new instance for each one. _ = BookFactory.create_batch(number_of_books, author=author) request = self.factory.get(BASE_URL, format='json') self.view = BookViewSet.as_view({'get': 'list'}) response = self.view(request) self.assertEqual(len(response.data), number_of_books)
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)
def test_review_list_returns_books_to_review(self): books_without_revies = BookFactory.create_batch(10, authors=[self.author,]) self.client.login(username='******', password='******') response = self.client.get(reverse('review-books')) books = list(response.context['books']) self.assertEquals(books_without_revies, books)