mirror of
https://github.com/GSA/notifications-api.git
synced 2026-05-04 00:00:27 -04:00
Remove from_request method on the Notification db model, was not needed anymore.
Use Notifications.query.one(), rather than assert count is 1 and query for all and get first item in list.
This commit is contained in:
@@ -10,65 +10,6 @@ from app.models import (
|
||||
MOBILE_TYPE, EMAIL_TYPE)
|
||||
|
||||
|
||||
def test_should_build_notification_from_minimal_set_of_api_derived_params(notify_api):
|
||||
now = datetime.utcnow()
|
||||
|
||||
notification = Notification.from_request(
|
||||
template_id='template',
|
||||
template_version='1',
|
||||
recipient='someone',
|
||||
service_id='service_id',
|
||||
notification_type='SMS',
|
||||
created_at=now,
|
||||
api_key_id='api_key_id',
|
||||
key_type='key_type',
|
||||
personalisation={},
|
||||
job_id=None,
|
||||
job_row_number=None
|
||||
)
|
||||
assert notification.created_at == now
|
||||
assert notification.template_id == 'template'
|
||||
assert notification.template_version == '1'
|
||||
assert not notification.job_row_number
|
||||
assert not notification.job_id
|
||||
assert notification.to == 'someone'
|
||||
assert notification.service_id == 'service_id'
|
||||
assert notification.status == 'created'
|
||||
assert not notification.personalisation
|
||||
assert notification.notification_type == 'SMS'
|
||||
assert notification.api_key_id == 'api_key_id'
|
||||
assert notification.key_type == 'key_type'
|
||||
|
||||
|
||||
def test_should_build_notification_from_full_set_of_api_derived_params(notify_api):
|
||||
now = datetime.utcnow()
|
||||
notification = Notification.from_request(template_id='template',
|
||||
template_version=1,
|
||||
recipient='someone',
|
||||
service_id='service_id',
|
||||
personalisation={'key': 'value'},
|
||||
notification_type='SMS',
|
||||
api_key_id='api_key_id',
|
||||
key_type='key_type',
|
||||
job_id='job_id',
|
||||
job_row_number=100,
|
||||
created_at=now
|
||||
)
|
||||
assert notification.created_at == now
|
||||
assert notification.id is None
|
||||
assert notification.template_id == 'template'
|
||||
assert notification.template_version == 1
|
||||
assert notification.job_row_number == 100
|
||||
assert notification.job_id == 'job_id'
|
||||
assert notification.to == 'someone'
|
||||
assert notification.service_id == 'service_id'
|
||||
assert notification.status == 'created'
|
||||
assert notification.personalisation == {'key': 'value'}
|
||||
assert notification.notification_type == 'SMS'
|
||||
assert notification.api_key_id == 'api_key_id'
|
||||
assert notification.key_type == 'key_type'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('mobile_number', [
|
||||
'07700 900678',
|
||||
'+44 7700 900678'
|
||||
|
||||
Reference in New Issue
Block a user