Spaces:
Sleeping
Sleeping
Download test_app.py from sanjeethnc/MLops_case_study_1: direct link, hf CLI and curl.
- Browser
- Download file 1.26 kB
-
https://huggingface.co/spaces/sanjeethnc/MLops_case_study_1/resolve/main/test_app.py
- Command line
-
hf download hf://spaces/sanjeethnc/MLops_case_study_1/test_app.py
-
curl -L -o test_app.py https://huggingface.co/spaces/sanjeethnc/MLops_case_study_1/resolve/main/test_app.py
1.26 kB
| 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() | |