mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-10 10:03:38 -04:00
Merge pull request #3167 from alphagov/broadcast_services_history
Add service versioning to broadcast account type change
This commit is contained in:
@@ -3,11 +3,19 @@ from datetime import datetime
|
|||||||
from flask import current_app
|
from flask import current_app
|
||||||
|
|
||||||
from app import db
|
from app import db
|
||||||
from app.models import ServiceBroadcastSettings, ServicePermission, Organisation, BROADCAST_TYPE, EMAIL_AUTH_TYPE
|
from app.dao.dao_utils import transactional, version_class
|
||||||
from app.dao.dao_utils import transactional
|
from app.models import (
|
||||||
|
Service,
|
||||||
|
ServiceBroadcastSettings,
|
||||||
|
ServicePermission,
|
||||||
|
Organisation,
|
||||||
|
BROADCAST_TYPE,
|
||||||
|
EMAIL_AUTH_TYPE
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@transactional
|
@transactional
|
||||||
|
@version_class(Service)
|
||||||
def set_broadcast_service_type(service, service_mode, broadcast_channel, provider_restriction):
|
def set_broadcast_service_type(service, service_mode, broadcast_channel, provider_restriction):
|
||||||
insert_or_update_service_broadcast_settings(
|
insert_or_update_service_broadcast_settings(
|
||||||
service, channel=broadcast_channel, provider_restriction=provider_restriction
|
service, channel=broadcast_channel, provider_restriction=provider_restriction
|
||||||
|
|||||||
@@ -4059,3 +4059,23 @@ def test_set_as_broadcast_service_errors_if_no_mobile_provider_restriction(
|
|||||||
_data=data,
|
_data=data,
|
||||||
_expected_status=400,
|
_expected_status=400,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_set_as_broadcast_service_updates_services_history(
|
||||||
|
admin_request, sample_service, broadcast_organisation
|
||||||
|
):
|
||||||
|
old_history_records = Service.get_history_model().query.filter_by(id=sample_service.id).all()
|
||||||
|
data = {
|
||||||
|
'broadcast_channel': 'test',
|
||||||
|
'service_mode': 'live',
|
||||||
|
'provider_restriction': None,
|
||||||
|
}
|
||||||
|
|
||||||
|
admin_request.post(
|
||||||
|
'service.set_as_broadcast_service',
|
||||||
|
service_id=sample_service.id,
|
||||||
|
_data=data,
|
||||||
|
)
|
||||||
|
|
||||||
|
new_history_records = Service.get_history_model().query.filter_by(id=sample_service.id).all()
|
||||||
|
assert len(new_history_records) == len(old_history_records) + 1
|
||||||
|
|||||||
Reference in New Issue
Block a user