fix: add --comment param for import-versions command

This commit is contained in:
Lance Edgar 2025-12-18 22:57:04 -06:00
parent fc250a433c
commit 1e7722de91
3 changed files with 46 additions and 10 deletions

View file

@ -14,17 +14,40 @@ class TestFromWuttaToVersions(VersionTestCase):
def make_handler(self, **kwargs):
return mod.FromWuttaToVersions(self.config, **kwargs)
def test_consume_kwargs(self):
# no comment by default
handler = self.make_handler()
kw = handler.consume_kwargs({})
self.assertEqual(kw, {})
self.assertIsNone(handler.continuum_comment)
# but can provide one
handler = self.make_handler()
kw = handler.consume_kwargs({"comment": "yeehaw"})
self.assertEqual(kw, {})
self.assertEqual(handler.continuum_comment, "yeehaw")
def test_begin_target_transaction(self):
model = self.app.model
txncls = continuum.transaction_class(model.User)
# basic / defaults
handler = self.make_handler()
self.assertIsNone(handler.continuum_uow)
self.assertIsNone(handler.continuum_txn)
handler.begin_target_transaction()
self.assertIsInstance(handler.continuum_uow, continuum.UnitOfWork)
self.assertIsInstance(handler.continuum_txn, txncls)
# nb. no comment
self.assertIsNone(handler.continuum_txn.meta.get("comment"))
# with comment
handler = self.make_handler()
handler.continuum_comment = "yeehaw"
handler.begin_target_transaction()
self.assertIn("comment", handler.continuum_txn.meta)
self.assertEqual(handler.continuum_txn.meta["comment"], "yeehaw")
def test_get_importer_kwargs(self):
handler = self.make_handler()
@ -57,14 +80,6 @@ class TestFromWuttaToVersions(VersionTestCase):
self.assertNotIn("Upgrade", importers)
class UserImporter(mod.FromWuttaToVersionBase):
@property
def model_class(self):
model = self.app.model
return model.User
class TestFromWuttaToVersionBase(VersionTestCase):
def make_importer(self, model_class=None, **kwargs):