Merge branch 'master' into primary-provider

Conflicts:
	tests/app/dao/test_provider_rates_dao.py
This commit is contained in:
Martyn Inglis
2016-05-11 14:04:15 +01:00
15 changed files with 61 additions and 38 deletions

View File

@@ -121,7 +121,7 @@ def test_authentication_passes_when_service_has_multiple_keys_some_expired(
with notify_api.test_client() as client:
expired_key_data = {'service': sample_api_key.service,
'name': 'expired_key',
'expiry_date': datetime.now(),
'expiry_date': datetime.utcnow(),
'created_by': sample_api_key.created_by
}
expired_key = ApiKey(**expired_key_data)
@@ -166,7 +166,7 @@ def test_authentication_returns_token_expired_when_service_uses_expired_key_and_
expire_the_key = {'id': expired_api_key.id,
'service': sample_api_key.service,
'name': 'expired_key',
'expiry_date': datetime.now() + timedelta(hours=-2),
'expiry_date': datetime.utcnow() + timedelta(hours=-2),
'created_by': sample_api_key.created_by}
save_model_api_key(expired_api_key, expire_the_key)
response = client.get(

View File

@@ -813,7 +813,7 @@ def test_email_invited_user_should_send_email(notify_api, mocker):
'service_id': '123123',
'service_name': 'Blacksmith Service',
'token': 'the-token',
'expiry_date': str(datetime.now() + timedelta(days=1))
'expiry_date': str(datetime.utcnow() + timedelta(days=1))
}
mocker.patch('app.aws_ses_client.send_email')

View File

@@ -41,9 +41,10 @@ def test_create_invited_user(notify_api, sample_service, mocker):
assert json_resp['data']['permissions'] == 'send_messages,manage_service,manage_api_keys'
assert json_resp['data']['id']
invitation_expiration_days = notify_api.config['INVITATION_EXPIRATION_DAYS']
expiry_date = (datetime.now() + timedelta(days=invitation_expiration_days)).replace(hour=0, minute=0,
second=0,
microsecond=0)
expiry_date = (datetime.utcnow() + timedelta(days=invitation_expiration_days)).replace(hour=0,
minute=0,
second=0,
microsecond=0)
encrypted_invitation = {'to': email_address,
'user_name': invite_from.name,
'service_id': str(sample_service.id),

View File

@@ -71,6 +71,7 @@ def test_get_job_by_id(notify_api, sample_job):
assert response.status_code == 200
resp_json = json.loads(response.get_data(as_text=True))
assert resp_json['data']['id'] == job_id
assert resp_json['data']['created_by']['name'] == 'Test User'
def test_create_job(notify_api, sample_template, mocker, fake_uuid):

View File

@@ -19,7 +19,7 @@ def test_get_delivery_status_all_ok(notify_api, notify_db):
def test_get_delivery_status_with_undelivered_notification(notify_api, notify_db, sample_notification):
more_than_five_mins_ago = datetime.now() - timedelta(minutes=10)
more_than_five_mins_ago = datetime.utcnow() - timedelta(minutes=10)
sample_notification.created_at = more_than_five_mins_ago
notify_db.session.add(sample_notification)
notify_db.session.commit()

View File

@@ -1,11 +1,13 @@
import json
from datetime import (datetime, date)
from flask import url_for
from app.models import Template
from freezegun import freeze_time
from app.dao.templates_dao import dao_update_template
from tests import create_authorization_header
def test_template_history_version(notify_api, sample_template):
def test_template_history_version(notify_api, sample_user, sample_template):
with notify_api.test_request_context():
with notify_api.test_client() as client:
auth_header = create_authorization_header()
@@ -23,6 +25,8 @@ def test_template_history_version(notify_api, sample_template):
assert json_resp['data']['id'] == str(sample_template.id)
assert json_resp['data']['content'] == sample_template.content
assert json_resp['data']['version'] == 1
assert json_resp['data']['created_by']['name'] == sample_user.name
assert datetime.strptime(json_resp['data']['created_at'], '%Y-%m-%d %H:%M:%S.%f').date() == date.today()
def test_previous_template_history_version(notify_api, sample_template):

View File

@@ -110,7 +110,7 @@ def test_user_verify_code_email_expired_code(notify_api,
with notify_api.test_client() as client:
assert not VerifyCode.query.first().code_used
sample_email_code.expiry_datetime = (
datetime.now() - timedelta(hours=1))
datetime.utcnow() - timedelta(hours=1))
db.session.add(sample_email_code)
db.session.commit()
data = json.dumps({