mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Updated tests of .dates().
Replaced .dates() by .datetimes() for DateTimeFields. Replaced dates with datetimes in the expected output for DateFields.
This commit is contained in:
@@ -141,7 +141,7 @@ class YearArchiveViewTests(TestCase):
|
||||
def test_year_view(self):
|
||||
res = self.client.get('/dates/books/2008/')
|
||||
self.assertEqual(res.status_code, 200)
|
||||
self.assertEqual(list(res.context['date_list']), [datetime.datetime(2008, 10, 1)])
|
||||
self.assertEqual(list(res.context['date_list']), [datetime.date(2008, 10, 1)])
|
||||
self.assertEqual(res.context['year'], datetime.date(2008, 1, 1))
|
||||
self.assertTemplateUsed(res, 'generic_views/book_archive_year.html')
|
||||
|
||||
@@ -152,7 +152,7 @@ class YearArchiveViewTests(TestCase):
|
||||
def test_year_view_make_object_list(self):
|
||||
res = self.client.get('/dates/books/2006/make_object_list/')
|
||||
self.assertEqual(res.status_code, 200)
|
||||
self.assertEqual(list(res.context['date_list']), [datetime.datetime(2006, 5, 1)])
|
||||
self.assertEqual(list(res.context['date_list']), [datetime.date(2006, 5, 1)])
|
||||
self.assertEqual(list(res.context['book_list']), list(Book.objects.filter(pubdate__year=2006)))
|
||||
self.assertEqual(list(res.context['object_list']), list(Book.objects.filter(pubdate__year=2006)))
|
||||
self.assertTemplateUsed(res, 'generic_views/book_archive_year.html')
|
||||
@@ -182,7 +182,7 @@ class YearArchiveViewTests(TestCase):
|
||||
|
||||
res = self.client.get('/dates/books/%s/allow_future/' % year)
|
||||
self.assertEqual(res.status_code, 200)
|
||||
self.assertEqual(list(res.context['date_list']), [datetime.datetime(year, 1, 1)])
|
||||
self.assertEqual(list(res.context['date_list']), [datetime.date(year, 1, 1)])
|
||||
|
||||
def test_year_view_paginated(self):
|
||||
res = self.client.get('/dates/books/2006/paginated/')
|
||||
@@ -227,7 +227,7 @@ class MonthArchiveViewTests(TestCase):
|
||||
res = self.client.get('/dates/books/2008/oct/')
|
||||
self.assertEqual(res.status_code, 200)
|
||||
self.assertTemplateUsed(res, 'generic_views/book_archive_month.html')
|
||||
self.assertEqual(list(res.context['date_list']), [datetime.datetime(2008, 10, 1)])
|
||||
self.assertEqual(list(res.context['date_list']), [datetime.date(2008, 10, 1)])
|
||||
self.assertEqual(list(res.context['book_list']),
|
||||
list(Book.objects.filter(pubdate=datetime.date(2008, 10, 1))))
|
||||
self.assertEqual(res.context['month'], datetime.date(2008, 10, 1))
|
||||
@@ -270,7 +270,7 @@ class MonthArchiveViewTests(TestCase):
|
||||
# allow_future = True, valid future month
|
||||
res = self.client.get('/dates/books/%s/allow_future/' % urlbit)
|
||||
self.assertEqual(res.status_code, 200)
|
||||
self.assertEqual(res.context['date_list'][0].date(), b.pubdate)
|
||||
self.assertEqual(res.context['date_list'][0], b.pubdate)
|
||||
self.assertEqual(list(res.context['book_list']), [b])
|
||||
self.assertEqual(res.context['month'], future)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user