Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed tests for date-based generic views.

  • Loading branch information...
commit 435081fd22cec08d98ccbf1efcd223ccaa634ecd 1 parent aaa3382
@aaugustin aaugustin authored
Showing with 15 additions and 11 deletions.
  1. +15 −11 tests/regressiontests/generic_views/dates.py
View
26 tests/regressiontests/generic_views/dates.py
@@ -456,15 +456,17 @@ def test_datetime_day_view(self):
@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 @@ def test_get_object_custom_queryset(self):
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)
Please sign in to comment.
Something went wrong with that request. Please try again.