Пример #1
0
 def test_last_page(self):
     "PaginatedListView should return last page with ?p=last"
     # Two pages' worth:
     PublicationFactory.create_batch(51)
     request = self.factory.get('/fake-path/?p=last')
     response = views.PublicationListView.as_view()(request)
     # Has the final one publication on the second page:
     self.assertEqual(len(response.context_data['publication_list']), 1)
Пример #2
0
 def test_context_counts(self):
     "It should include the book and periodical counts."
     PublicationFactory.create_batch(2, kind='book')
     PublicationFactory.create_batch(3, kind='periodical')
     response = views.PublicationListView.as_view()(self.request)
     self.assertIn('book_count', response.context_data)
     self.assertEqual(response.context_data['book_count'], 2)
     self.assertIn('periodical_count', response.context_data)
     self.assertEqual(response.context_data['periodical_count'], 3)
Пример #3
0
 def setUp(self):
     super().setUp()
     series = PublicationSeriesFactory(pk=123)
     PublicationFactory.create_batch(2, series=series)