zaidmehdi commited on
Commit
c1192ba
1 Parent(s): 916fa06

update tests

Browse files
Files changed (1) hide show
  1. tests/model_tests.py +7 -11
tests/model_tests.py CHANGED
@@ -1,11 +1,10 @@
1
  import unittest
2
 
3
- from src.main import app
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 /classify API endpoint is correct"""
21
- request_data = {"text": "حاجة حلوة اكيد"}
22
- response = self.client.post("/classify", json=request_data)
23
- self.assertEqual(response.status_code, 200)
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
- request_data = {"text": text}
31
- response = self.client.post("/classify", json=request_data)
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__":