test: fix test for designated import handlers
This commit is contained in:
parent
8c5918b9fb
commit
e037aece6a
1 changed files with 24 additions and 0 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
# -*- coding: utf-8; -*-
|
# -*- coding: utf-8; -*-
|
||||||
|
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
from wuttjamaican.testing import ConfigTestCase
|
from wuttjamaican.testing import ConfigTestCase
|
||||||
|
|
||||||
from wuttasync import app as mod
|
from wuttasync import app as mod
|
||||||
|
|
@ -16,6 +18,16 @@ class FromCsvToPoser(FromCsvToWutta):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class FromFooToBaz1(ImportHandler):
|
||||||
|
source_key = "foo"
|
||||||
|
target_key = "baz"
|
||||||
|
|
||||||
|
|
||||||
|
class FromFooToBaz2(ImportHandler):
|
||||||
|
source_key = "foo"
|
||||||
|
target_key = "baz"
|
||||||
|
|
||||||
|
|
||||||
class TestWuttaSyncAppProvider(ConfigTestCase):
|
class TestWuttaSyncAppProvider(ConfigTestCase):
|
||||||
|
|
||||||
def test_get_all_import_handlers(self):
|
def test_get_all_import_handlers(self):
|
||||||
|
|
@ -100,6 +112,18 @@ class TestWuttaSyncAppProvider(ConfigTestCase):
|
||||||
any([h.get_key() == "import.to_versions.from_wutta" for h in handlers])
|
any([h.get_key() == "import.to_versions.from_wutta" for h in handlers])
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# nothing returned if multiple handlers found but none are designated
|
||||||
|
with patch.object(
|
||||||
|
self.app.providers["wuttasync"],
|
||||||
|
"get_all_import_handlers",
|
||||||
|
return_value=[FromFooToBaz1, FromFooToBaz2],
|
||||||
|
):
|
||||||
|
handlers = self.app.get_designated_import_handlers()
|
||||||
|
baz_handlers = [
|
||||||
|
h for h in handlers if h.get_key() == "import.to_baz.from_foo"
|
||||||
|
]
|
||||||
|
self.assertEqual(len(baz_handlers), 0)
|
||||||
|
|
||||||
def test_get_import_handler(self):
|
def test_get_import_handler(self):
|
||||||
|
|
||||||
# make sure a basic fetch works
|
# make sure a basic fetch works
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue