feat: add support for Wutta <-> Wutta import/export
This commit is contained in:
parent
bfc45bd0f0
commit
ae282ab468
25 changed files with 719 additions and 21 deletions
|
|
@ -25,19 +25,55 @@ class TestImportCommandHandler(DataTestCase):
|
|||
# as spec
|
||||
handler = self.make_handler(import_handler=FromCsvToWutta.get_spec())
|
||||
self.assertIsInstance(handler.import_handler, FromCsvToWutta)
|
||||
self.assertFalse(hasattr(handler, "foo"))
|
||||
self.assertFalse(hasattr(handler.import_handler, "foo"))
|
||||
|
||||
# as spec, w/ kwargs
|
||||
handler = self.make_handler(import_handler=FromCsvToWutta.get_spec(), foo="bar")
|
||||
self.assertIsInstance(handler.import_handler, FromCsvToWutta)
|
||||
self.assertFalse(hasattr(handler, "foo"))
|
||||
self.assertTrue(hasattr(handler.import_handler, "foo"))
|
||||
self.assertEqual(handler.import_handler.foo, "bar")
|
||||
|
||||
# as factory
|
||||
handler = self.make_handler(import_handler=FromCsvToWutta)
|
||||
self.assertIsInstance(handler.import_handler, FromCsvToWutta)
|
||||
self.assertFalse(hasattr(handler, "foo"))
|
||||
self.assertFalse(hasattr(handler.import_handler, "foo"))
|
||||
|
||||
# as factory, w/ kwargs
|
||||
handler = self.make_handler(import_handler=FromCsvToWutta, foo="bar")
|
||||
self.assertIsInstance(handler.import_handler, FromCsvToWutta)
|
||||
self.assertFalse(hasattr(handler, "foo"))
|
||||
self.assertTrue(hasattr(handler.import_handler, "foo"))
|
||||
self.assertEqual(handler.import_handler.foo, "bar")
|
||||
|
||||
# as instance
|
||||
myhandler = FromCsvToWutta(self.config)
|
||||
handler = self.make_handler(import_handler=myhandler)
|
||||
self.assertIs(handler.import_handler, myhandler)
|
||||
self.assertFalse(hasattr(handler, "foo"))
|
||||
self.assertFalse(hasattr(handler.import_handler, "foo"))
|
||||
|
||||
# as instance, w/ kwargs (which are ignored)
|
||||
myhandler = FromCsvToWutta(self.config)
|
||||
handler = self.make_handler(import_handler=myhandler, foo="bar")
|
||||
self.assertIs(handler.import_handler, myhandler)
|
||||
self.assertFalse(hasattr(handler, "foo"))
|
||||
self.assertFalse(hasattr(handler.import_handler, "foo"))
|
||||
|
||||
# as key
|
||||
handler = self.make_handler(key="import.to_wutta.from_csv")
|
||||
self.assertIsInstance(handler.import_handler, FromCsvToWutta)
|
||||
self.assertFalse(hasattr(handler, "foo"))
|
||||
self.assertFalse(hasattr(handler.import_handler, "foo"))
|
||||
|
||||
# as key, w/ kwargs
|
||||
handler = self.make_handler(key="import.to_wutta.from_csv", foo="bar")
|
||||
self.assertIsInstance(handler.import_handler, FromCsvToWutta)
|
||||
self.assertFalse(hasattr(handler, "foo"))
|
||||
self.assertTrue(hasattr(handler.import_handler, "foo"))
|
||||
self.assertEqual(handler.import_handler.foo, "bar")
|
||||
|
||||
def test_run(self):
|
||||
handler = self.make_handler(
|
||||
|
|
|
|||
23
tests/cli/test_export_wutta.py
Normal file
23
tests/cli/test_export_wutta.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
|
||||
from unittest import TestCase
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from wuttasync.cli import export_wutta as mod, ImportCommandHandler
|
||||
|
||||
|
||||
class TestExportWutta(TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
params = {
|
||||
"dbkey": "another",
|
||||
"models": [],
|
||||
"create": True,
|
||||
"update": True,
|
||||
"delete": False,
|
||||
"dry_run": True,
|
||||
}
|
||||
ctx = MagicMock(params=params)
|
||||
with patch.object(ImportCommandHandler, "run") as run:
|
||||
mod.export_wutta(ctx)
|
||||
run.assert_called_once_with(ctx)
|
||||
23
tests/cli/test_import_wutta.py
Normal file
23
tests/cli/test_import_wutta.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
|
||||
from unittest import TestCase
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from wuttasync.cli import import_wutta as mod, ImportCommandHandler
|
||||
|
||||
|
||||
class TestImportWutta(TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
params = {
|
||||
"dbkey": "another",
|
||||
"models": [],
|
||||
"create": True,
|
||||
"update": True,
|
||||
"delete": False,
|
||||
"dry_run": True,
|
||||
}
|
||||
ctx = MagicMock(params=params)
|
||||
with patch.object(ImportCommandHandler, "run") as run:
|
||||
mod.import_wutta(ctx)
|
||||
run.assert_called_once_with(ctx)
|
||||
Loading…
Add table
Add a link
Reference in a new issue