Edm0nd/edmond/plugins/tests/test_translate.py

36 lines
1.4 KiB
Python
Raw Normal View History

2020-11-04 17:21:52 +01:00
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"))