def test_exists_full(self): translator = GoogleTranslator() self.assertTrue(translator.word_exists("computer")) self.assertTrue(translator.word_exists("σπιτι", "el")) self.assertFalse(translator.word_exists("bockpack", "en")) self.assertFalse(translator.word_exists("σπίτι", "en"))
def test_exists(self, mock_do_work, mock_val_lang): translator = GoogleTranslator() self.assertEqual(translator.word_exists("test"), mock_do_work.return_value) mock_val_lang.assert_called_once_with("en", allow_auto=False) mock_do_work.assert_called_once_with(translator._word_exists, "test", mock_val_lang.return_value, "text") mock_do_work.reset_mock() mock_val_lang.reset_mock() self.assertEqual( translator.word_exists("test", lang="ru", output="dict"), mock_do_work.return_value) mock_val_lang.assert_called_once_with("ru", allow_auto=False) mock_do_work.assert_called_once_with(translator._word_exists, "test", mock_val_lang.return_value, "dict")