Useful when creating virtual environments for several Python versions
(e.g. `.venv38`, `.venv312`), which otherwise are linted by tools like
black, isort and flake8.
Sorry, I guess the idea was to not have to build a full MockApp ?
Realisitically all tasks access the database at this point.
I suppose we could make the decorators more specific if necessary ?
fixes#16947
also adds a setter to `MockApp` in order to fix the following
which was shown during tests
```
/home/berntm/projects/galaxy/.venv/lib/python3.10/site-packages/_pytest/threadexception.py:73: PytestUnhandledThreadExceptionWarning: Exception in thread Thread-7 (check)
Traceback (most recent call last):
File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/usr/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/home/berntm/projects/galaxy/lib/galaxy/tool_util/toolbox/watcher.py", line 153, in check
self.reload_callback()
File "/home/berntm/projects/galaxy/lib/galaxy/app_unittest_utils/toolbox_support.py", line 44, in <lambda>
app.watchers.tool_config_watcher.reload_callback = lambda: reload_callback(test_case)
File "/home/berntm/projects/galaxy/lib/galaxy/app_unittest_utils/toolbox_support.py", line 193, in reload_callback
test_case._toolbox = test_case.app.toolbox = SimplifiedToolBox(test_case)
AttributeError: can't set attribute 'toolbox'
warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))
```
Rationale:
We use an in-memory sqlite database for quota tests. With SA 2.0 (or
with the `future` flag enabled on the engine), the following conflict
happens: (this is a simplified model)
foo = Foo()
session.add(foo)
session.flush()
engine = session.get_bind()
with engine.connect() as conn:
conn.execute(some-sql)
foo.bar = "new value"
session.commit() # BOOM!!!! sqlalchemy.orm.exc.StaleDataError: UPDATE statement on table 'galaxy_user' expected to update 1 row(s); 0 were matched.
Reason for BOOM:
With an in-memory database, the underlying dbapi_connection object is
the same for the session and the engine.connect(). Here's what happens:
line 10: foo is flushed to the db tmp buffer
line 14: conn is closed on exit from context manager, which issues a
rollback, which rolls back whatever is in the tmp buffer - so foo is
never inserted.
line 16: foo is updated
line 17: error happens: the session thinks it's updating foo's record in
the db, but that record does not exist therefore, "0 rows matched".
Solution: commit instead of flushing - then foo is inserted.