~ubuntu-branches/ubuntu/precise/python-django/precise-proposed

« back to all changes in this revision

Viewing changes to tests/regressiontests/generic_views/dates.py

  • Committer: Bazaar Package Importer
  • Author(s): Raphaël Hertzog
  • Date: 2011-09-15 12:43:51 UTC
  • mfrom: (1.1.15 upstream) (4.4.15 sid)
  • Revision ID: james.westby@ubuntu.com-20110915124351-5hea3kkc0tp5vlfh
Tags: 1.3.1-1
* New upstream release. It includes security updates described here:
  https://www.djangoproject.com/weblog/2011/sep/09/security-releases-issued/
  Closes: #641405
* Update 01_disable_url_verify_regression_tests.diff and merge
  07_disable_url_verify_model_tests.diff into it.
* Update patch headers to conform to DEP-3.
* Apply patch from Steve Langasek to dynamically build the UTF-8
  locale required by the test-suite instead of build-depending on
  locales-all. Closes: #630421
* Use "dh --with sphinxdoc" to clean up the Sphinx generated documentation
  and avoid the embedded-javascript-library lintian warning. Build-Depends
  on python-sphinx >= 1.0.7+dfsg-1 for this and also add
  ${sphinxdoc:Depends} to python-django-doc Depends field.
* Cleanup build-dependencies now that even oldstable has python 2.5.
* Switch to dh_python2 as python helper tool. Drop legacy files
  debian/pyversions and debian/pycompat.
* New patch 02_disable-sources-in-sphinxdoc.diff to not generate
  the _sources directory that we used to remove manually within the rules
  file. But must be kept disabled until #641710 is fixed.
* Properly support DEB_BUILD_OPTIONS=nocheck despite the override
  of dh_auto_test.

Show diffs side-by-side

added added

removed removed

Lines of Context:
119
119
        self.assertEqual(res.status_code, 200)
120
120
        self.assertEqual(list(res.context['date_list']), [datetime.datetime(year, 1, 1)])
121
121
 
 
122
    def test_year_view_paginated(self):
 
123
        res = self.client.get('/dates/books/2006/paginated/')
 
124
        self.assertEqual(res.status_code, 200)
 
125
        self.assertEqual(list(res.context['book_list']), list(Book.objects.filter(pubdate__year=2006)))
 
126
        self.assertEqual(list(res.context['object_list']), list(Book.objects.filter(pubdate__year=2006)))
 
127
        self.assertTemplateUsed(res, 'generic_views/book_archive_year.html')
 
128
 
122
129
    def test_year_view_invalid_pattern(self):
123
130
        res = self.client.get('/dates/books/no_year/')
124
131
        self.assertEqual(res.status_code, 404)
190
197
        self.assertEqual(res.context['next_month'], future)
191
198
        self.assertEqual(res.context['previous_month'], datetime.date(2006, 5, 1))
192
199
 
 
200
    def test_month_view_paginated(self):
 
201
        res = self.client.get('/dates/books/2008/oct/paginated/')
 
202
        self.assertEqual(res.status_code, 200)
 
203
        self.assertEqual(list(res.context['book_list']), list(Book.objects.filter(pubdate__year=2008, pubdate__month=10)))
 
204
        self.assertEqual(list(res.context['object_list']), list(Book.objects.filter(pubdate__year=2008, pubdate__month=10)))
 
205
        self.assertTemplateUsed(res, 'generic_views/book_archive_month.html')
 
206
 
193
207
    def test_custom_month_format(self):
194
208
        res = self.client.get('/dates/books/2008/10/')
195
209
        self.assertEqual(res.status_code, 200)
251
265
        self.assertEqual(res.status_code, 200)
252
266
        self.assertEqual(list(res.context['book_list']), [b])
253
267
 
 
268
    def test_week_view_paginated(self):
 
269
        week_start = datetime.date(2008, 9, 28)
 
270
        week_end = week_start + datetime.timedelta(days=7)
 
271
        res = self.client.get('/dates/books/2008/week/39/')
 
272
        self.assertEqual(res.status_code, 200)
 
273
        self.assertEqual(list(res.context['book_list']), list(Book.objects.filter(pubdate__gte=week_start, pubdate__lt=week_end)))
 
274
        self.assertEqual(list(res.context['object_list']), list(Book.objects.filter(pubdate__gte=week_start, pubdate__lt=week_end)))
 
275
        self.assertTemplateUsed(res, 'generic_views/book_archive_week.html')
 
276
 
254
277
    def test_week_view_invalid_pattern(self):
255
278
        res = self.client.get('/dates/books/2007/week/no_week/')
256
279
        self.assertEqual(res.status_code, 404)
327
350
        self.assertEqual(res.context['next_day'], future)
328
351
        self.assertEqual(res.context['previous_day'], datetime.date(2006, 5, 1))
329
352
 
 
353
    def test_day_view_paginated(self):
 
354
        res = self.client.get('/dates/books/2008/oct/1/')
 
355
        self.assertEqual(res.status_code, 200)
 
356
        self.assertEqual(list(res.context['book_list']), list(Book.objects.filter(pubdate__year=2008, pubdate__month=10, pubdate__day=1)))
 
357
        self.assertEqual(list(res.context['object_list']), list(Book.objects.filter(pubdate__year=2008, pubdate__month=10, pubdate__day=1)))
 
358
        self.assertTemplateUsed(res, 'generic_views/book_archive_day.html')
 
359
 
330
360
    def test_next_prev_context(self):
331
361
        res = self.client.get('/dates/books/2008/oct/01/')
332
362
        self.assertEqual(res.content, "Archive for Oct. 1, 2008. Previous day is May 1, 2006")