test: fix test for designated import handlers

This commit is contained in:
Lance Edgar 2025-12-20 20:38:40 -06:00
parent 8c5918b9fb
commit e037aece6a

View file

@ -1,5 +1,7 @@
# -*- coding: utf-8; -*-
from unittest.mock import patch
from wuttjamaican.testing import ConfigTestCase
from wuttasync import app as mod
@ -16,6 +18,16 @@ class FromCsvToPoser(FromCsvToWutta):
pass
class FromFooToBaz1(ImportHandler):
source_key = "foo"
target_key = "baz"
class FromFooToBaz2(ImportHandler):
source_key = "foo"
target_key = "baz"
class TestWuttaSyncAppProvider(ConfigTestCase):
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])
)
# 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):
# make sure a basic fetch works