New strategy for transaction management.

Introduce a contextmanger function to handle exceptions and nested
transactions. Using the nested_transaction will start a
nested transaction with `db.session.begin_nested`, once the nested
transaction is complete the commit will happen.
`@transactional` has been updated to commit unless in a nested
transaction.
This commit is contained in:
Rebecca Law
2021-04-13 15:02:46 +01:00
parent cf35135605
commit 93908bacda
9 changed files with 29 additions and 52 deletions

View File

@@ -233,7 +233,7 @@ def test_add_service_to_organisation(sample_service, sample_organisation):
sample_organisation.crown = False
dao_add_service_to_organisation(sample_service, sample_organisation.id)
db.session.commit()
assert len(sample_organisation.services) == 1
assert sample_organisation.services[0].id == sample_service.id