Spaces:
Sleeping
Sleeping
update tests
Browse files- tests/model_tests.py +7 -11
tests/model_tests.py
CHANGED
@@ -1,11 +1,10 @@
|
|
1 |
import unittest
|
2 |
|
3 |
-
from src.main import
|
4 |
|
5 |
|
6 |
class TestClassifier(unittest.TestCase):
|
7 |
def setUp(self) -> None:
|
8 |
-
self.client = app.test_client()
|
9 |
self.dialects = ['Egypt', 'Iraq', 'Saudi_Arabia', 'Mauritania', 'Algeria', 'Syria',
|
10 |
'Oman', 'Tunisia', 'Lebanon', 'Morocco', 'Djibouti','United_Arab_Emirates','Kuwait',
|
11 |
'Libya', 'Bahrain', 'Qatar', 'Yemen', 'Palestine', 'Jordan', 'Somalia', 'Sudan']
|
@@ -17,19 +16,16 @@ class TestClassifier(unittest.TestCase):
|
|
17 |
}
|
18 |
|
19 |
def test_response(self):
|
20 |
-
"""Test if the response of the
|
21 |
-
|
22 |
-
response =
|
23 |
-
self.
|
24 |
-
self.assertIn("class", response.json)
|
25 |
-
self.assertIn(response.json["class"], self.dialects)
|
26 |
|
27 |
def test_model_output(self):
|
28 |
"""Test that the model correctly classifies obvious dialects"""
|
29 |
for country, text, in self.test_set.items():
|
30 |
-
|
31 |
-
|
32 |
-
self.assertEqual(response.json["class"], country)
|
33 |
|
34 |
|
35 |
if __name__ == "__main__":
|
|
|
1 |
import unittest
|
2 |
|
3 |
+
from src.main import classify_arabic_dialect
|
4 |
|
5 |
|
6 |
class TestClassifier(unittest.TestCase):
|
7 |
def setUp(self) -> None:
|
|
|
8 |
self.dialects = ['Egypt', 'Iraq', 'Saudi_Arabia', 'Mauritania', 'Algeria', 'Syria',
|
9 |
'Oman', 'Tunisia', 'Lebanon', 'Morocco', 'Djibouti','United_Arab_Emirates','Kuwait',
|
10 |
'Libya', 'Bahrain', 'Qatar', 'Yemen', 'Palestine', 'Jordan', 'Somalia', 'Sudan']
|
|
|
16 |
}
|
17 |
|
18 |
def test_response(self):
|
19 |
+
"""Test if the response of the main function is correct"""
|
20 |
+
text = "حاجة حلوة اكيد"
|
21 |
+
response = classify_arabic_dialect(text)
|
22 |
+
self.assertIn(response, self.dialects)
|
|
|
|
|
23 |
|
24 |
def test_model_output(self):
|
25 |
"""Test that the model correctly classifies obvious dialects"""
|
26 |
for country, text, in self.test_set.items():
|
27 |
+
response = classify_arabic_dialect(text)
|
28 |
+
self.assertEqual(response, country)
|
|
|
29 |
|
30 |
|
31 |
if __name__ == "__main__":
|