Commit b4ac990a authored by Michal Čihař's avatar Michal Čihař

Test Google translate API as well

parent 31f867b6
...@@ -31,7 +31,7 @@ from trans.machine.opentran import OpenTranTranslation ...@@ -31,7 +31,7 @@ from trans.machine.opentran import OpenTranTranslation
from trans.machine.apertium import ApertiumTranslation from trans.machine.apertium import ApertiumTranslation
from trans.machine.tmserver import AmagamaTranslation from trans.machine.tmserver import AmagamaTranslation
from trans.machine.microsoft import MicrosoftTranslation from trans.machine.microsoft import MicrosoftTranslation
from trans.machine.google import GoogleWebTranslation from trans.machine.google import GoogleWebTranslation, GoogleTranslation
from trans.machine.weblatetm import ( from trans.machine.weblatetm import (
WeblateSimilarTranslation, WeblateTranslation WeblateSimilarTranslation, WeblateTranslation
) )
...@@ -221,7 +221,7 @@ class MachineTranslationTest(TestCase): ...@@ -221,7 +221,7 @@ class MachineTranslationTest(TestCase):
self.assertTranslate(machine) self.assertTranslate(machine)
@httpretty.activate @httpretty.activate
def test_google(self): def test_googleweb(self):
httpretty.register_uri( httpretty.register_uri(
httpretty.GET, httpretty.GET,
'http://translate.google.com/translate_a/t', 'http://translate.google.com/translate_a/t',
...@@ -230,6 +230,21 @@ class MachineTranslationTest(TestCase): ...@@ -230,6 +230,21 @@ class MachineTranslationTest(TestCase):
machine = GoogleWebTranslation() machine = GoogleWebTranslation()
self.assertTranslate(machine) self.assertTranslate(machine)
@httpretty.activate
def test_google(self):
httpretty.register_uri(
httpretty.GET,
'https://www.googleapis.com/language/translate/v2/languages',
body='{"data": {"languages": [ { "language": "cs" }]}}'
)
httpretty.register_uri(
httpretty.GET,
'https://www.googleapis.com/language/translate/v2/',
body='{"data":{"translations":[{"translatedText":"svet"}]}}'
)
machine = GoogleTranslation()
self.assertTranslate(machine)
@httpretty.activate @httpretty.activate
def test_amagama(self): def test_amagama(self):
httpretty.register_uri( httpretty.register_uri(
......
...@@ -34,6 +34,9 @@ SOUTH_TESTS_MIGRATE = False ...@@ -34,6 +34,9 @@ SOUTH_TESTS_MIGRATE = False
MT_MICROSOFT_ID = 'ID' MT_MICROSOFT_ID = 'ID'
MT_MICROSOFT_SECRET = 'SECRET' MT_MICROSOFT_SECRET = 'SECRET'
# Fake Google translate API key
MT_GOOGLE_KEY = 'KEY'
# To get higher limit for testing # To get higher limit for testing
MT_MYMEMORY_EMAIL = 'test@weblate.org' MT_MYMEMORY_EMAIL = 'test@weblate.org'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment