def test_average_consumption_by_hour(self, now_mock):
""" Test whether timezones are converted properly when grouping hours. """
now_mock.return_value = timezone.make_aware(timezone.datetime(2016, 1, 25, 12))
HourStatistics.objects.create(
# This should be stored with local timezone, so +1.
hour_start=timezone.make_aware(timezone.datetime(2016, 1, 1, 12)),
electricity1=1,
electricity2=0,
electricity1_returned=0,
electricity2_returned=0,
)
hour_stat = dsmr_stats.services.average_consumption_by_hour(max_weeks_ago=4)[0]
# @see "Trends are always shown in UTC #76", only PostgreSQL can fix this.
if connection.vendor == 'postgresql':
# Regression, Django defaults to UTC, so '11' here.
self.assertEqual(hour_stat['hour_start'], 12)
else:
return self.skipTest('Test cannot be fixed for backends other than PostgreSQL')
评论列表
文章目录