Spaces:
Sleeping
Sleeping
Sanjeeth commited on
Add files via upload
Browse files- test_app.py +23 -0
test_app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import unittest
|
| 2 |
+
from app import translate
|
| 3 |
+
|
| 4 |
+
class TestTranslationFunction(unittest.TestCase):
|
| 5 |
+
|
| 6 |
+
def test_translate_to_french(self):
|
| 7 |
+
result = translate("Hello", "French")
|
| 8 |
+
self.assertIn("Bonjour", result, "Translation to French failed")
|
| 9 |
+
|
| 10 |
+
def test_translate_to_german(self):
|
| 11 |
+
result = translate("Hello", "German")
|
| 12 |
+
self.assertIn("Hallo", result, "Translation to German failed")
|
| 13 |
+
|
| 14 |
+
def test_translate_to_romanian(self):
|
| 15 |
+
result = translate("Hello", "Romanian")
|
| 16 |
+
self.assertTrue("Bună" in result or "Salut" in result, "Translation to Romanian failed")
|
| 17 |
+
|
| 18 |
+
def test_unsupported_language(self):
|
| 19 |
+
result = translate("Hello", "Spanish")
|
| 20 |
+
self.assertEqual(result, "Sorry, this language is not supported.", "Unsupported language test failed")
|
| 21 |
+
|
| 22 |
+
if __name__ == "__main__":
|
| 23 |
+
unittest.main()
|