Update now to utcnow. All tests passing.

This commit is contained in:
Nicholas Staples
2016-05-11 10:56:24 +01:00
parent 1b82612ea3
commit 03f15d6af9
11 changed files with 21 additions and 21 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

@@ -781,7 +781,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

@@ -5,7 +5,7 @@ from app.models import ProviderRates
def test_create_provider_rates(notify_db, notify_db_session, mmg_provider_name):
now = datetime.now()
now = datetime.utcnow()
rate = Decimal("1.00000")
create_provider_rates(mmg_provider_name, now, rate)
assert ProviderRates.query.count() == 1

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

@@ -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

@@ -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({