Format date correctly for upload + refactor tests

This commit is contained in:
Imdad Ahad
2017-02-03 13:32:19 +00:00
parent 53b6cdcfab
commit 99cc2f5897
2 changed files with 8 additions and 10 deletions

View File

@@ -1,8 +1,7 @@
import base64
import json
import requests
from datetime import datetime
from requests import request
from flask import current_app
from app.utils import (
@@ -30,7 +29,7 @@ class PerformancePlatformClient:
def send_performance_stats(self, date, channel, count, period):
if self.active:
payload = {
'_timestamp': str(date),
'_timestamp': date.isoformat(),
'service': 'govuk-notify',
'channel': channel,
'count': count,
@@ -62,10 +61,9 @@ class PerformancePlatformClient:
'Content-Type': "application/json",
'Authorization': 'Bearer {}'.format(self.bearer_token)
}
resp = request(
"POST",
resp = requests.post(
self.performance_platform_url,
data=json.dumps(payload),
json=payload,
headers=headers
)