zaidmehdi commited on
Commit
1656836
1 Parent(s): 9a3b7ae

test obvious dialects

Browse files
Files changed (1) hide show
  1. tests/model_tests.py +13 -0
tests/model_tests.py CHANGED
@@ -8,6 +8,12 @@ class TestClassifier(unittest.TestCase):
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']
 
 
 
 
 
 
11
 
12
  def test_response(self):
13
  """Test if the response of the /classify API endpoint is correct"""
@@ -17,6 +23,13 @@ class TestClassifier(unittest.TestCase):
17
  self.assertIn("class", response.json())
18
  self.assertIn(response.json()["class"], self.dialects)
19
 
 
 
 
 
 
 
20
 
 
21
  if __name__ == "__main__":
22
  unittest.main()
 
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']
11
+ self.test_set = {
12
+ "Egypt": "حضرتك بروح زي كدا؟ على طول النهار ده",
13
+ "Iraq": "همين: شلون، زين، خوش، هواية، كلش، شقد",
14
+ "Algeria": "بصح راك فاهم لازم الزيت",
15
+ "Morocco": "واش نتا خدام ولا لا"
16
+ }
17
 
18
  def test_response(self):
19
  """Test if the response of the /classify API endpoint is correct"""
 
23
  self.assertIn("class", response.json())
24
  self.assertIn(response.json()["class"], self.dialects)
25
 
26
+ def test_model_output(self):
27
+ """Test that the model correctly classifies obvious dialects"""
28
+ for country, text, in self.test_set.items():
29
+ request_data = {"text": text}
30
+ response = requests.post(self.API_URL, json=request_data)
31
+ self.assertEqual(response.json()["class"], country)
32
 
33
+
34
  if __name__ == "__main__":
35
  unittest.main()