Пример #1
0
 def test_hello(self):
     """
     Test to translate a single english word.
     """
     en_text = "Hello"
     de_translated = english_to_german(en_text)
     correct_de = "Hallo"
     self.assertEqual(correct_de, de_translated)
Пример #2
0
 def test_null(self):
     """
     Test to see if NULL values can be translated.
     Expected: IBM Watson will throw an exception if NULL is inputted.
                 This exception is avoided in the 'english_to_german()' fct.
     """
     en_text = ""
     de_translated = english_to_german(en_text)
     correct_de = "NULL"
     self.assertEqual(correct_de, de_translated)
Пример #3
0
 def test_multi_word(self):
     """
     Test to translate a single english statement.
     NOTE: Example of difference between IBM and Google Translate.
     """
     en_text = "Peace on Earth"
     de_translated = english_to_german(en_text)
     correct_de = "Frieden auf Erden"
     correct_de_ibm_api = "Frieden auf der Erde"
     self.assertNotEqual(correct_de, de_translated)
     self.assertEqual(correct_de_ibm_api, de_translated)
Пример #4
0
 def test_multi_line(self):
     """
     Test to translate two statements separated by a new line character.
     NOTE: See README.txt. IBM_Watson API will delete \n.
     NOTE: Example of difference between IBM and Google Translate.
     """
     en_text = "Blue square\nRed Circle"
     de_translated = english_to_german(en_text)
     correct_de = "blaues Quadrat\nroter Kreis"
     correct_de_ibm_api = "Blauer Quadrat Roter Kreis"
     self.assertNotEqual(correct_de, de_translated)
     self.assertEqual(correct_de_ibm_api, de_translated)
Пример #5
0
 def test_numbers(self):
     """
     Make sure numbers are not present in the input.
     """
     self.assertEqual(english_to_german("Print hello 47 times"),
                      "Please refrain from using numbers.")
Пример #6
0
 def test_case_sensitivity(self):
     """
     Make sure mismatched casing doesn't ruin translation.
     """
     self.assertEqual(english_to_german("WoMaN"), "Frau")
Пример #7
0
 def test_hello(self):
     """
     Test to see if it actually translates to French.
     """
     self.assertEqual(english_to_german("Hello"), "Hallo")
Пример #8
0
 def test_null(self):
     """
     If no input, return string stating as such.
     """
     self.assertEqual(english_to_german(""), "Lack of textual input.")
Пример #9
0
 def test4(self):
     self.assertNotEqual(english_to_german("hello world"), "hello world")
Пример #10
0
 def test3(self):
     self.assertEqual(english_to_german("How are you"), "Wie geht es Ihnen?")
Пример #11
0
 def test2(self):
     self.assertEqual(english_to_german("Hello"), "Hallo")
Пример #12
0
 def test1(self):
     with self.assertRaises(Exception):
         english_to_german("")