feat: add TransactionMetaPlugin to save comments when applicable
This commit is contained in:
parent
09e4ef6a1e
commit
b19f565aa1
3 changed files with 87 additions and 3 deletions
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import socket
|
||||
|
||||
from unittest.mock import patch
|
||||
from unittest.mock import patch, Mock
|
||||
|
||||
from wuttjamaican.testing import ConfigTestCase, DataTestCase
|
||||
|
||||
|
|
@ -71,3 +71,20 @@ class TestWuttaContinuumPlugin(DataTestCase):
|
|||
plugin.transaction_args(None, self.session),
|
||||
{"remote_addr": "127.0.0.1", "user_id": "some-random-uuid"},
|
||||
)
|
||||
|
||||
def test_before_flush(self):
|
||||
plugin = self.make_plugin()
|
||||
|
||||
meta = {}
|
||||
txn = Mock(meta=meta)
|
||||
uow = Mock(current_transaction=txn)
|
||||
|
||||
# no comment in session or transaction
|
||||
plugin.before_flush(uow, self.session)
|
||||
self.assertNotIn("comment", meta)
|
||||
|
||||
# transaction comment matches session
|
||||
self.session.info["continuum_comment"] = "whaddyaknow"
|
||||
plugin.before_flush(uow, self.session)
|
||||
self.assertIn("comment", meta)
|
||||
self.assertEqual(meta["comment"], "whaddyaknow")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue