Ticket #16092: 16092-testcase.patch
File 16092-testcase.patch, 1.8 KB (added by , 13 years ago) |
---|
-
regressiontests/extra_regress/tests.py
2 2 3 3 from django.utils.datastructures import SortedDict 4 4 5 from django.db import models 5 6 from django.contrib.auth.models import User 6 7 from regressiontests.extra_regress.models import TestObject, Order, \ 7 RevisionableModel 8 RevisionableModel, FilterModel 8 9 9 10 import datetime 10 11 … … 312 313 TestObject.objects.extra(where=["id > %s"], params=[obj.pk]), 313 314 ['<TestObject: TestObject: first,second,third>'] 314 315 ) 316 317 def test_regression_16092(self): 318 f1 = FilterModel.objects.create( 319 timezone_name='America/New_York', 320 cutoff=datetime.datetime(2038, 1, 1, 0, 0, 0)) 321 f2 = FilterModel.objects.create( 322 timezone_name='America/Los_Angeles', 323 cutoff=datetime.datetime(2000, 1, 1, 0, 0, 0)) 324 325 qs = FilterModel.objects.extra(select={'now_in_local_tz': 326 "convert_tz(now(), 'GMT', test_model.timezone_name)"}) 327 qs = qs.filter(cutoff__lte=models.F('now_in_local_tz')) 328 self.assertQuerysetEqual(qs, [f2]) 329 330 No newline at end of file -
regressiontests/extra_regress/models.py
37 37 def __unicode__(self): 38 38 return u'TestObject: %s,%s,%s' % (self.first,self.second,self.third) 39 39 40 class FilterModel(models.Model): 41 timezone_name = models.CharField(max_length=200) 42 cutoff = models.DateTimeField()