Add service versioning to broadcast account type change

We are using the `set_broadcast_service_type` route to make changes to
service objects. However, we had forgotten to add the `version_class`
decorator to it which will mean the changing of a service going from
training to live mode will also be recorded in the services_history
table for free. Whilst not essential, this easy change makes things more
consistent for how we update other services.
This commit is contained in:
David McDonald
2021-03-04 17:23:09 +00:00
parent dabdc2c4ac
commit 8cf32d6f22
2 changed files with 30 additions and 2 deletions

View File

@@ -4059,3 +4059,23 @@ def test_set_as_broadcast_service_errors_if_no_mobile_provider_restriction(
_data=data,
_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