import unittest from edmond.tests.test_plugin import get_plugin_patcher from ..translate import TranslatePlugin class TestTranslatePlugin(unittest.TestCase): def test_parse_words(self): with get_plugin_patcher(TranslatePlugin): plugin = TranslatePlugin() plugin.config = { "default_dest": "en", "param_source": "from", "param_dest": "to", } # No params. result = plugin.parse_words("test".split()) self.assertEqual(result, ("autodetect", "en", "test")) # Source param (alone, so wrong). result = plugin.parse_words("from fr test".split()) self.assertEqual(result, ("autodetect", "en", "from fr test")) # Destination param (alone, so wrong). result = plugin.parse_words("to fr test".split()) self.assertEqual(result, ("autodetect", "en", "to fr test")) # Both source and dest params, OK. result = plugin.parse_words("from it to fr test".split()) self.assertEqual(result, ("it", "fr", "test")) # Badly placed param. result = plugin.parse_words("from it test to fr".split()) self.assertEqual(result, ("autodetect", "en", "from it test to fr"))