Repository navigation
Expand file tree
/
Copy pathtests.py
More file actions
43 lines (34 loc) · 1.47 KB
/
Copy pathtests.py
File metadata and controls
43 lines (34 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Copyright 2014 Will Filho <dookgulliver@willfilho.com>
#
# This file is part of BingTranslator.
#
# This program free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with BingTranslator. If not, see <http://www.gnu.org/licenses/>.
from BingTranslator import Translator
import unittest
CLIENT_ID = "BookAboutPyQt5"
CLIENT_SECRET = "RWfmb4O7eO3zbnlTqZaPu8cBmMthaXkonxQA9sQnQ+0="
class TestAll(unittest.TestCase):
def setUp(self):
self.translator = Translator(CLIENT_ID, CLIENT_SECRET)
def test_detect_language(self):
lang_detect = self.translator.detect("Hello World")
self.assertEqual("en", lang_detect)
def test_detect_languages(self):
langs_detected = self.translator.detect_texts(["Hello World","Voe sem parar."])
self.assertEqual(["en","pt"], langs_detected)
def test_translate_method(self):
trans = self.translator.translate("Oi", "en")
self.assertEqual("Hi", trans)
if __name__ == "__main__":
unittest.main()