From e037aece6abb0a82c4aad7f8f99fc778a003057c Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 20 Dec 2025 20:38:40 -0600 Subject: [PATCH] test: fix test for designated import handlers --- tests/test_app.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test_app.py b/tests/test_app.py index ea2b5e6..560d89d 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -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