diff options
author | Hasan Ramezani <hasan.r67@gmail.com> | 2018-10-29 15:56:04 +0100 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2018-10-29 14:22:42 -0400 |
commit | 4f8f1b2f245bba83c64b3d5765332bfcb591f1c9 (patch) | |
tree | 422747860a8a978c91ec66fb72aa60c464590777 /tests/generic_views | |
parent | 7f2b27e95c754e7761a559c9564ff8943753ac32 (diff) | |
download | django-4f8f1b2f245bba83c64b3d5765332bfcb591f1c9.tar.gz |
Fixed #29903 -- Added error message for invalid WeekArchiveView week_format.
Diffstat (limited to 'tests/generic_views')
-rw-r--r-- | tests/generic_views/test_dates.py | 4 | ||||
-rw-r--r-- | tests/generic_views/urls.py | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/tests/generic_views/test_dates.py b/tests/generic_views/test_dates.py index 2daac10b31..8cd2b2a8be 100644 --- a/tests/generic_views/test_dates.py +++ b/tests/generic_views/test_dates.py @@ -528,6 +528,10 @@ class WeekArchiveViewTests(TestDataMixin, TestCase): self.assertEqual(res.status_code, 200) self.assertEqual(res.context['week'], datetime.date(2008, 9, 29)) + def test_unknown_week_format(self): + with self.assertRaisesMessage(ValueError, "Unknown week format '%T'. Choices are: %U, %W"): + self.client.get('/dates/books/2008/week/39/unknown_week_format/') + def test_datetime_week_view(self): BookSigning.objects.create(event_date=datetime.datetime(2008, 4, 2, 12, 0)) res = self.client.get('/dates/booksignings/2008/week/13/') diff --git a/tests/generic_views/urls.py b/tests/generic_views/urls.py index f2af8ad1a3..8fbcbbc8cb 100644 --- a/tests/generic_views/urls.py +++ b/tests/generic_views/urls.py @@ -182,6 +182,10 @@ urlpatterns = [ path('dates/books/<int:year>/week/<int:week>/paginated/', views.BookWeekArchive.as_view(paginate_by=30)), path('dates/books/<int:year>/week/no_week/', views.BookWeekArchive.as_view()), path('dates/books/<int:year>/week/<int:week>/monday/', views.BookWeekArchive.as_view(week_format='%W')), + path( + 'dates/books/<int:year>/week/<int:week>/unknown_week_format/', + views.BookWeekArchive.as_view(week_format='%T'), + ), path('dates/booksignings/<int:year>/week/<int:week>/', views.BookSigningWeekArchive.as_view()), # DayArchiveView |