Example #1
0
    def test_romanize_full(self):
        translator = GoogleTranslator()

        self.assertEqual(translator.romanize("σπίτι"), "spíti")
        self.assertEqual(translator.romanize("дом"), "dom")
        self.assertEqual(translator.romanize("家", "japanese"), "Ie")
        self.assertEqual(translator.romanize("house"), "house")
        self.assertEqual(translator.romanize("hello"), "hello")
        self.assertIsNone(translator.romanize("σπίτη"))  # With typo
Example #2
0
    def test_romanize(self, mock_do_work, mock_val_lang):
        translator = GoogleTranslator()

        self.assertEqual(translator.romanize("test"),
                         mock_do_work.return_value)
        mock_val_lang.assert_called_once_with("auto")
        mock_do_work.assert_called_once_with(translator._romanize, "test",
                                             mock_val_lang.return_value,
                                             "text")

        mock_do_work.reset_mock()
        mock_val_lang.reset_mock()

        self.assertEqual(translator.romanize("test", "en", "json"),
                         mock_do_work.return_value)
        mock_val_lang.assert_called_once_with("en")
        mock_do_work.assert_called_once_with(translator._romanize, "test",
                                             mock_val_lang.return_value,
                                             "json")