Rename method to convert from utc to bst for consistency

This commit is contained in:
Imdad Ahad
2017-08-10 16:24:48 +01:00
parent 955ec60fe3
commit 19b09f2a27
4 changed files with 10 additions and 7 deletions

View File

@@ -5,7 +5,7 @@ from datetime import datetime
import requests import requests
from flask import current_app from flask import current_app
from app.utils import get_midnight_for_day_before, get_london_midnight_in_utc, convert_utc_time_in_bst from app.utils import get_midnight_for_day_before, get_london_midnight_in_utc, convert_utc_to_bst
class PerformancePlatformClient: class PerformancePlatformClient:
@@ -27,7 +27,7 @@ class PerformancePlatformClient:
def send_performance_stats(self, date, channel, count, period): def send_performance_stats(self, date, channel, count, period):
if self.active: if self.active:
payload = { payload = {
'_timestamp': convert_utc_time_in_bst(date).isoformat(), '_timestamp': convert_utc_to_bst(date).isoformat(),
'service': 'govuk-notify', 'service': 'govuk-notify',
'channel': channel, 'channel': channel,
'count': count, 'count': count,

View File

@@ -28,7 +28,7 @@ from app import (
) )
from app.history_meta import Versioned from app.history_meta import Versioned
from app.utils import convert_utc_time_in_bst, convert_bst_to_utc from app.utils import convert_utc_to_bst, convert_bst_to_utc
SMS_TYPE = 'sms' SMS_TYPE = 'sms'
EMAIL_TYPE = 'email' EMAIL_TYPE = 'email'
@@ -950,7 +950,7 @@ class Notification(db.Model):
}[self.template.template_type].get(self.status, self.status) }[self.template.template_type].get(self.status, self.status)
def serialize_for_csv(self): def serialize_for_csv(self):
created_at_in_bst = convert_utc_time_in_bst(self.created_at) created_at_in_bst = convert_utc_to_bst(self.created_at)
serialized = { serialized = {
"row_number": '' if self.job_row_number is None else self.job_row_number + 1, "row_number": '' if self.job_row_number is None else self.job_row_number + 1,
"recipient": self.to, "recipient": self.to,
@@ -1304,3 +1304,6 @@ class MonthlyBilling(db.Model):
"notification_type": self.notification_type, "notification_type": self.notification_type,
"monthly_totals": self.monthly_totals "monthly_totals": self.monthly_totals
} }
def __repr__(self):
return str(self.serialized())

View File

@@ -51,7 +51,7 @@ def get_midnight_for_day_before(date):
return get_london_midnight_in_utc(day_before) return get_london_midnight_in_utc(day_before)
def convert_utc_time_in_bst(utc_dt): def convert_utc_to_bst(utc_dt):
return pytz.utc.localize(utc_dt).astimezone(local_timezone).replace(tzinfo=None) return pytz.utc.localize(utc_dt).astimezone(local_timezone).replace(tzinfo=None)

View File

@@ -4,7 +4,7 @@ import pytest
from app.utils import ( from app.utils import (
get_london_midnight_in_utc, get_london_midnight_in_utc,
get_midnight_for_day_before, get_midnight_for_day_before,
convert_utc_time_in_bst, convert_utc_to_bst,
convert_bst_to_utc) convert_bst_to_utc)
@@ -35,7 +35,7 @@ def test_get_midnight_for_day_before_returns_expected_date(date, expected_date):
(datetime(2017, 5, 12, 14), datetime(2017, 5, 12, 15, 0)) (datetime(2017, 5, 12, 14), datetime(2017, 5, 12, 15, 0))
]) ])
def test_get_utc_in_bst_returns_expected_date(date, expected_date): def test_get_utc_in_bst_returns_expected_date(date, expected_date):
ret_date = convert_utc_time_in_bst(date) ret_date = convert_utc_to_bst(date)
assert ret_date == expected_date assert ret_date == expected_date