[gedit-plugins] Fixes #39
- From: Jordi Mas <jmas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit-plugins] Fixes #39
- Date: Tue, 27 Oct 2020 08:45:02 +0000 (UTC)
commit 4d5a29ed794972980467db3f78213756de5bb18e
Author: Jordi Mas <jmas softcatala org>
Date: Tue Oct 27 09:44:55 2020 +0100
Fixes #39
plugins/translate/tests/testapertium.py | 13 +++++++++----
plugins/translate/translate/services/yandex.py | 3 +++
2 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/plugins/translate/tests/testapertium.py b/plugins/translate/tests/testapertium.py
index dbce83c..f293e99 100644
--- a/plugins/translate/tests/testapertium.py
+++ b/plugins/translate/tests/testapertium.py
@@ -29,6 +29,11 @@ class TestApertium(unittest.TestCase):
def setUp(self):
Apertium._clean_for_ut()
+ def _get_apertium(self):
+ apertium = Apertium()
+ apertium.set_server("https://www.apertium.org/apy")
+ return apertium
+
@patch('urllib.request.urlopen')
def test_translate_text(self, mock_urlopen):
cm = MagicMock()
@@ -37,13 +42,13 @@ class TestApertium(unittest.TestCase):
cm.__enter__.return_value = cm
mock_urlopen.return_value = cm
- apertium = Apertium()
+ apertium = self._get_apertium()
translated = apertium.translate_text('You should have received a copy', 'eng|cat')
self.assertEqual('Hauries d\'haver-hi rebut una còpia', translated)
mock_urlopen.assert_called_with("https://www.apertium.org/apy/translate?langpair=eng|cat&markUnknown=no&q=You+should+have+received+a+copy")
def test_fetch_remote_language_names_and_pairs_localized(self):
- mockObject = Apertium()
+ mockObject = self._get_apertium()
mockObject._get_user_locale = Mock(return_value='ca')
mockObject._get_remote_language_pairs = Mock(return_value=[['es'], ['en'], ['es', 'en'], ['es|en']])
mockObject._get_remote_language_names = Mock(return_value={'es': 'Espanyol', 'en': 'Anglès'})
@@ -54,7 +59,7 @@ class TestApertium(unittest.TestCase):
self.assertEqual(['es|en'], Apertium.g_language_codes)
def test_fetch_remote_language_names_and_pairs_non_localized(self):
- mockObject = Apertium()
+ mockObject = self._get_apertium()
mockObject._get_user_locale = Mock(return_value='ca_ES')
mockObject._get_remote_language_pairs = Mock(return_value=[['ca'], ['en'], ['ca', 'en'], ['ca|en']])
mockObject._get_remote_language_names = Mock(return_value={'es': 'Espanyol', 'en': 'Anglès'})
@@ -73,7 +78,7 @@ class TestApertium(unittest.TestCase):
cm.__enter__.return_value = cm
mock_urlopen.return_value = cm
- apertium = Apertium()
+ apertium = self._get_apertium()
language_pair_source, language_pair_target, locales, language_codes =
apertium._get_remote_language_pairs()
self.assertEqual(['oci_aran'], language_pair_source)
self.assertEqual(['cat'], language_pair_target)
diff --git a/plugins/translate/translate/services/yandex.py b/plugins/translate/translate/services/yandex.py
index c50065d..8aaa8f9 100644
--- a/plugins/translate/translate/services/yandex.py
+++ b/plugins/translate/translate/services/yandex.py
@@ -70,6 +70,9 @@ class Yandex(Service):
def set_api_key(self, key):
self._key = key
+ def set_server(self, server):
+ pass
+
def init(self):
self._fetch_remote_language_names()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]