Spaces:
Sleeping
Sleeping
File size: 1,261 Bytes
cc5ca08 dbb5aed cc5ca08 dbb5aed cc5ca08 dbb5aed cc5ca08 dbb5aed cd600c4 cc5ca08 dbb5aed cc5ca08 dbb5aed cc5ca08 | 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 | import unittest
from app import translate
class TestTranslationFunction(unittest.TestCase):
def setUp(self):
# Default model type to Local-Based for testing purposes
self.model_type = "Local-Based"
def test_translate_to_french(self):
# Test translation to French using the Local-Based model
result = translate("Hello", "French", self.model_type)
self.assertEqual(result, "Bonjour")
def test_translate_to_german(self):
# Test translation to German using the Local-Based model
result = translate("Hello", "German", self.model_type)
self.assertEqual(result, "Hallo")
def test_translate_to_romanian(self):
# Test translation to Romanian using the Local-Based model
result = translate("Hello", "Romanian", self.model_type)
self.assertTrue(result in ["Salut", "Bună ziua"]) # Accept both "Salut" and "Bună ziua"
def test_unsupported_language(self):
# Test translation to unsupported language using the Local-Based model
result = translate("Hello", "Spanish", self.model_type)
self.assertEqual(result, "Sorry, this language is not supported.")
if __name__ == '__main__':
unittest.main()
|