def test_annotate(self): self.assertQuerysetEqual( NaiveDateTimeTestModel.objects.annotate( naive_converted=AtTimeZone("aware", "timezone"), aware_converted=AtTimeZone("naive", "timezone"), ).values_list("naive_converted", "aware_converted"), [ (self.now, timezone.make_aware(self.now, self.perth_tz)), (self.now, timezone.make_aware(self.now, self.sydney_tz)), ], transform=identity, )
def test_raw_naive_value_timezone(self): self.assertQuerysetEqual( NaiveDateTimeTestModel.objects.filter(aware__lt=AtTimeZone( self.now, Value("Australia/Adelaide"), )), [self.sydney], transform=identity, )
def test_raw_naive_db_timezone(self): self.assertQuerysetEqual( NaiveDateTimeTestModel.objects.filter(aware=AtTimeZone( self.now, "timezone", )), [self.perth, self.sydney], transform=identity, )
def test_raw_aware_value_timezone(self): self.assertQuerysetEqual( NaiveDateTimeTestModel.objects.filter(naive=AtTimeZone( timezone.make_aware(self.now, self.adelaide_tz), Value("Australia/Adelaide"), )), [self.perth, self.sydney], transform=identity, )
def test_raw_aware_db_timezone(self): self.assertQuerysetEqual( NaiveDateTimeTestModel.objects.filter(naive__lt=AtTimeZone( timezone.make_aware(self.now, self.adelaide_tz), "timezone", )), [self.sydney], transform=identity, )
def test_db_aware_value_timezone(self): self.assertQuerysetEqual( NaiveDateTimeTestModel.objects.filter(naive__lt=AtTimeZone( "aware", Value("Australia/Adelaide"), )), [self.perth], transform=identity, )