Spaces:
Sleeping
Sleeping
Sanjeeth commited on
Update test_app.py
Browse files- test_app.py +19 -11
test_app.py
CHANGED
|
@@ -3,21 +3,29 @@ from app import translate
|
|
| 3 |
|
| 4 |
class TestTranslationFunction(unittest.TestCase):
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
def test_translate_to_french(self):
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
| 10 |
def test_translate_to_german(self):
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
| 14 |
def test_translate_to_romanian(self):
|
| 15 |
-
|
| 16 |
-
|
|
|
|
| 17 |
|
| 18 |
def test_unsupported_language(self):
|
| 19 |
-
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
-
if __name__ ==
|
| 23 |
unittest.main()
|
|
|
|
| 3 |
|
| 4 |
class TestTranslationFunction(unittest.TestCase):
|
| 5 |
|
| 6 |
+
def setUp(self):
|
| 7 |
+
# Default model type to Local-Based for testing purposes
|
| 8 |
+
self.model_type = "Local-Based"
|
| 9 |
+
|
| 10 |
def test_translate_to_french(self):
|
| 11 |
+
# Test translation to French using the Local-Based model
|
| 12 |
+
result = translate("Hello", "French", self.model_type)
|
| 13 |
+
self.assertEqual(result, "Bonjour")
|
| 14 |
+
|
| 15 |
def test_translate_to_german(self):
|
| 16 |
+
# Test translation to German using the Local-Based model
|
| 17 |
+
result = translate("Hello", "German", self.model_type)
|
| 18 |
+
self.assertEqual(result, "Hallo")
|
| 19 |
+
|
| 20 |
def test_translate_to_romanian(self):
|
| 21 |
+
# Test translation to Romanian using the Local-Based model
|
| 22 |
+
result = translate("Hello", "Romanian", self.model_type)
|
| 23 |
+
self.assertEqual(result, "Bună ziua")
|
| 24 |
|
| 25 |
def test_unsupported_language(self):
|
| 26 |
+
# Test translation to unsupported language using the Local-Based model
|
| 27 |
+
result = translate("Hello", "Spanish", self.model_type)
|
| 28 |
+
self.assertEqual(result, "Sorry, this language is not supported.")
|
| 29 |
|
| 30 |
+
if __name__ == '__main__':
|
| 31 |
unittest.main()
|