move deactivate functionality into one database transactions

this means that any errors will cause the entire thing to roll back

unfortunately, to do this we have to circumvent our regular code, which calls commit a lot, and lazily loads a lot of things, which will flush, and cause the version decorators to fail. so we have to write a lot of stuff by hand and re-select the service (even though it's already been queried) just to populate the api_keys and templates relationship on it
This commit is contained in:
Leo Hemsted
2016-11-10 17:07:02 +00:00
parent 17cf582502
commit 9ae6e14140
5 changed files with 33 additions and 20 deletions

View File

@@ -57,7 +57,7 @@ def test_deactivating_service_revokes_api_keys(deactivated_service):
def test_deactivating_service_archives_templates(deactivated_service):
assert deactivated_service.templates.count() == 2
assert len(deactivated_service.templates) == 2
for template in deactivated_service.templates:
assert template.archived is True
assert template.version == 2