You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.4 KiB

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"])
self.assertEqual(result, ("autodetect", "en", "test"))
# Source param.
result = plugin.parse_words(["!from:fr", "test"])
self.assertEqual(result, ("fr", "en", "test"))
# Destination param.
result = plugin.parse_words(["!to:fr", "test"])
self.assertEqual(result, ("autodetect", "fr", "test"))
# Both source and dest params.
result = plugin.parse_words(["!from:it", "!to:fr", "test"])
self.assertEqual(result, ("it", "fr", "test"))
# Badly placed param.
result = plugin.parse_words(["!from:it", "test", "!to:fr"])
self.assertEqual(result, ("it", "en", "test !to:fr"))
# Unknown param.
result = plugin.parse_words(["!zzz", "test"])
self.assertEqual(result, ("autodetect", "en", "test"))