Ticket #14711: tests.diff

File tests.diff, 2.4 KB (added by Mark Sundstrom, 14 years ago)

test case demonstrating the problem

  • tests/regressiontests/generic_views/dates.py

     
    350350    def test_invalid_url(self):
    351351        self.assertRaises(AttributeError, self.client.get, "/dates/books/2008/oct/01/nopk/")
    352352
     353class NextPreviousMonthViewTests(TestCase):
     354    urls = 'regressiontests.generic_views.urls'
     355
     356    def setUp(self):
     357        self.pubdate_list = [
     358            datetime.date(2010, month, day)
     359            for month,day in ((9,1), (10,2), (11,3))
     360        ]
     361        for pubdate in self.pubdate_list:
     362            name = str(pubdate)
     363            Book.objects.create(name=name, slug=name, pages=100, pubdate=pubdate)
     364
     365    def test_previous_month_bug(self):
     366        res = self.client.get('/dates/books/2010/nov/allow_empty/')
     367        self.assertEqual(res.status_code, 200)
     368        self.assertEqual(res.context['previous_month'], datetime.date(2010,10,1))
     369        # The following test demonstrates the bug
     370        res = self.client.get('/dates/books/2010/nov/')
     371        self.assertEqual(res.status_code, 200)
     372        self.assertEqual(res.context['previous_month'], datetime.date(2010,10,1))
     373        # The bug does not occur here because a Book with pubdate of Sep 1 exists
     374        res = self.client.get('/dates/books/2010/oct/')
     375        self.assertEqual(res.status_code, 200)
     376        self.assertEqual(res.context['previous_month'], datetime.date(2010,9,1))
     377       
     378 No newline at end of file
  • tests/regressiontests/generic_views/tests.py

     
    22from regressiontests.generic_views.dates import ArchiveIndexViewTests, YearArchiveViewTests, MonthArchiveViewTests, WeekArchiveViewTests, DayArchiveViewTests, DateDetailViewTests
    33from regressiontests.generic_views.detail import DetailViewTest
    44from regressiontests.generic_views.edit import CreateViewTests, UpdateViewTests, DeleteViewTests
    5 from regressiontests.generic_views.list import ListViewTests
    6  No newline at end of file
     5from regressiontests.generic_views.list import ListViewTests
     6from regressiontests.generic_views.dates import NextPreviousMonthViewTests
     7 No newline at end of file
Back to Top