1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Increased test coverage of django/views/generic/dates.py.

This commit is contained in:
Hasan Ramezani
2018-10-30 12:44:25 +01:00
committed by Tim Graham
parent 916aecd29d
commit c1c68d1ac0
3 changed files with 19 additions and 2 deletions

View File

@@ -156,6 +156,11 @@ class ArchiveIndexViewTests(TestDataMixin, TestCase):
self.assertEqual(list(res.context['latest']), list(Book.objects.order_by('-name').all()))
self.assertTemplateUsed(res, 'generic_views/book_archive.html')
def test_archive_view_without_date_field(self):
msg = 'BookArchiveWithoutDateField.date_field is required.'
with self.assertRaisesMessage(ImproperlyConfigured, msg):
self.client.get('/dates/books/without_date_field/')
@override_settings(ROOT_URLCONF='generic_views.urls')
class YearArchiveViewTests(TestDataMixin, TestCase):
@@ -291,6 +296,11 @@ class YearArchiveViewTests(TestDataMixin, TestCase):
self.assertIsNone(kwargs['previous_year'])
self.assertIsNone(kwargs['next_year'])
def test_get_dated_items_not_implemented(self):
msg = 'A DateView must provide an implementation of get_dated_items()'
with self.assertRaisesMessage(NotImplementedError, msg):
self.client.get('/BaseDateListViewTest/')
@override_settings(ROOT_URLCONF='generic_views.urls')
class MonthArchiveViewTests(TestDataMixin, TestCase):