mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
separate service deserialization from validation
Marshmallow validates and deserialises - BUT, when it deserialises,
it explicitly sets `sms_sender=None`, even when you haven't passed
sms_sender in. This is problematic, because we wanted to take advantage
of sqlalchemy's default value to set sms_sender to `GOVUK` when the
actual DB commit happens.
Instead, still use marshmallow for validating, but manually carry out
the json deserialisation in the model class.
This fixes a bug that only manifested when the database was upgraded,
but the code hadn't updated. 🎉
This commit is contained in:
@@ -20,7 +20,7 @@ from tests.app.conftest import (
|
||||
sample_notification_history as create_notification_history,
|
||||
sample_notification_with_job
|
||||
)
|
||||
from app.models import KEY_TYPE_NORMAL, KEY_TYPE_TEAM, KEY_TYPE_TEST
|
||||
from app.models import Service, KEY_TYPE_NORMAL, KEY_TYPE_TEAM, KEY_TYPE_TEST
|
||||
|
||||
from tests.app.db import create_user
|
||||
|
||||
@@ -216,6 +216,10 @@ def test_create_service(client, sample_user):
|
||||
assert json_resp['data']['dvla_organisation'] == '001'
|
||||
assert json_resp['data']['sms_sender'] == current_app.config['FROM_NUMBER']
|
||||
|
||||
service_db = Service.query.get(json_resp['data']['id'])
|
||||
assert service_db.name == 'created service'
|
||||
assert service_db.sms_sender == current_app.config['FROM_NUMBER']
|
||||
|
||||
auth_header_fetch = create_authorization_header()
|
||||
|
||||
resp = client.get(
|
||||
|
||||
Reference in New Issue
Block a user