import unittest
from office.api.tools import transtools
class TestTranstools(unittest.TestCase):
def test_translation_to_english(self):
translated = transtools(to_lang='en', content='你好')
self.assertIn('hello', translated.lower())
def test_translation_to_chinese(self):
translated = transtools(to_lang='zh', content='hello')
self.assertIn('你好', translated)
def test_translation_with_default_language(self):
translated = transtools(to_lang='en', content='你好')
self.assertIn('hello', translated.lower())
def test_translation_with_specific_language(self):
translated = transtools(to_lang='en', content='Bonjour', from_lang='fr')
self.assertIn('hello', translated.lower())
def test_empty_content(self):
translated = transtools(to_lang='en', content='')
self.assertEqual(translated, '')
def test_none_content(self):
with self.assertRaises(TypeError):
transtools(to_lang='en', content=None)
if __name__ == '__main__':
unittest.main()