From 435081fd22cec08d98ccbf1efcd223ccaa634ecd Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Tue, 1 May 2012 22:23:17 +0200 Subject: [PATCH] Fixed tests for date-based generic views. --- tests/regressiontests/generic_views/dates.py | 26 +++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/tests/regressiontests/generic_views/dates.py b/tests/regressiontests/generic_views/dates.py index f3984c6c0e..eb1f7d0a95 100644 --- a/tests/regressiontests/generic_views/dates.py +++ b/tests/regressiontests/generic_views/dates.py @@ -456,15 +456,17 @@ class DayArchiveViewTests(TestCase): @override_settings(USE_TZ=True, TIME_ZONE='Africa/Nairobi') def test_aware_datetime_day_view(self): - BookSigning.objects.create(event_date=datetime.datetime(2008, 4, 2, 12, 0, tzinfo=timezone.utc)) + bs = BookSigning.objects.create(event_date=datetime.datetime(2008, 4, 2, 12, 0, tzinfo=timezone.utc)) res = self.client.get('/dates/booksignings/2008/apr/2/') self.assertEqual(res.status_code, 200) # 2008-04-02T00:00:00+03:00 (beginning of day) > 2008-04-01T22:00:00+00:00 (book signing event date) - BookSigning.objects.filter(pk=1).update(event_date=datetime.datetime(2008, 4, 1, 22, 0, tzinfo=timezone.utc)) + bs.event_date = datetime.datetime(2008, 4, 1, 22, 0, tzinfo=timezone.utc) + bs.save() res = self.client.get('/dates/booksignings/2008/apr/2/') self.assertEqual(res.status_code, 200) # 2008-04-03T00:00:00+03:00 (end of day) > 2008-04-02T22:00:00+00:00 (book signing event date) - BookSigning.objects.filter(pk=1).update(event_date=datetime.datetime(2008, 4, 2, 22, 0, tzinfo=timezone.utc)) + bs.event_date = datetime.datetime(2008, 4, 2, 22, 0, tzinfo=timezone.utc) + bs.save() res = self.client.get('/dates/booksignings/2008/apr/2/') self.assertEqual(res.status_code, 404) @@ -524,20 +526,22 @@ class DateDetailViewTests(TestCase): self.assertEqual(res.status_code, 404) def test_datetime_date_detail(self): - BookSigning.objects.create(event_date=datetime.datetime(2008, 4, 2, 12, 0)) - res = self.client.get('/dates/booksignings/2008/apr/2/1/') + bs = BookSigning.objects.create(event_date=datetime.datetime(2008, 4, 2, 12, 0)) + res = self.client.get('/dates/booksignings/2008/apr/2/%d/' % bs.pk) self.assertEqual(res.status_code, 200) @override_settings(USE_TZ=True, TIME_ZONE='Africa/Nairobi') def test_aware_datetime_date_detail(self): - BookSigning.objects.create(event_date=datetime.datetime(2008, 4, 2, 12, 0, tzinfo=timezone.utc)) - res = self.client.get('/dates/booksignings/2008/apr/2/1/') + bs = BookSigning.objects.create(event_date=datetime.datetime(2008, 4, 2, 12, 0, tzinfo=timezone.utc)) + res = self.client.get('/dates/booksignings/2008/apr/2/%d/' % bs.pk) self.assertEqual(res.status_code, 200) # 2008-04-02T00:00:00+03:00 (beginning of day) > 2008-04-01T22:00:00+00:00 (book signing event date) - BookSigning.objects.filter(pk=1).update(event_date=datetime.datetime(2008, 4, 1, 22, 0, tzinfo=timezone.utc)) - res = self.client.get('/dates/booksignings/2008/apr/2/1/') + bs.event_date = datetime.datetime(2008, 4, 1, 22, 0, tzinfo=timezone.utc) + bs.save() + res = self.client.get('/dates/booksignings/2008/apr/2/%d/' % bs.pk) self.assertEqual(res.status_code, 200) # 2008-04-03T00:00:00+03:00 (end of day) > 2008-04-02T22:00:00+00:00 (book signing event date) - BookSigning.objects.filter(pk=1).update(event_date=datetime.datetime(2008, 4, 2, 22, 0, tzinfo=timezone.utc)) - res = self.client.get('/dates/booksignings/2008/apr/2/1/') + bs.event_date = datetime.datetime(2008, 4, 2, 22, 0, tzinfo=timezone.utc) + bs.save() + res = self.client.get('/dates/booksignings/2008/apr/2/%d/' % bs.pk) self.assertEqual(res.status_code, 404)