Make set_as_broadcast_service use a single DB commit

We don't want things in a half state if there is an error during the
method. Therefore, we move it all into a single function that is wrapped
in a transaction.

Note, we copy the approach of
https://github.com/alphagov/notifications-api/blob/master/app/dao/services_dao.py#L293
by having a single new dao function that does all the DB work.
This commit is contained in:
David McDonald
2021-02-15 14:54:36 +00:00
parent f9c87bafa3
commit 6fcda6debb
5 changed files with 73 additions and 57 deletions

View File

@@ -37,7 +37,6 @@ from app.models import (
INBOUND_SMS_TYPE,
NOTIFICATION_RETURNED_LETTER,
UPLOAD_LETTERS,
ServiceBroadcastSettings,
)
from tests import create_authorization_header
from tests.app.db import (