Ticket #16092: 16092-testcase.patch

File 16092-testcase.patch, 1.8 KB (added by Aymeric Augustin, 13 years ago)
  • regressiontests/extra_regress/tests.py

     
    22
    33from django.utils.datastructures import SortedDict
    44
     5from django.db import models
    56from django.contrib.auth.models import User
    67from regressiontests.extra_regress.models import TestObject, Order, \
    7         RevisionableModel
     8        RevisionableModel, FilterModel
    89
    910import datetime
    1011
     
    312313               TestObject.objects.extra(where=["id > %s"], params=[obj.pk]),
    313314            ['<TestObject: TestObject: first,second,third>']
    314315        )
     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

     
    3737    def __unicode__(self):
    3838        return u'TestObject: %s,%s,%s' % (self.first,self.second,self.third)
    3939
     40class FilterModel(models.Model):
     41    timezone_name = models.CharField(max_length=200)
     42    cutoff = models.DateTimeField()
Back to Top