How to test transactions

Hard agree on this, a decorator is a very nice way to handle a transaction - then your business logic functions should boil down to the series of named queries you are running in a row essentially.

Here's an example I've posted before about a decorator that handles a transaction and returns a GUI-agnostic response object so that you can then decide what to do with the results -

There's a few other examples as well across the forum with decorators handling transactions, and you may want to modify it for your use case, but this is the gist of it.