Skip to content

Commit

Permalink
Adds all three test cases for bag of words.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmechali committed Oct 28, 2024
1 parent 2754ef8 commit 0774a82
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions server/tests/routes/api/autocomplete_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,21 @@ def mock_predict_effect(query, lang):
response_dict = json.loads(response.data.decode("utf-8"))
self.assertEqual(len(response_dict["predictions"]), 5)

def test_off_by_one_true(self):
text = "Hello"
off_by_one_text = "Hallo"
self.assertTrue(helpers.off_by_one_letter(text, off_by_one_text))
# Tests for helpers within autocomplete.
def test_bag_of_words_same(self):
"""Tests that bag of words passes for same letters."""
text = "San"
reordered_text = "Sna"
self.assertTrue(helpers.off_by_one_letter(text, reordered_text))

def test_bag_of_words_off_by_one(self):
"""Tests that bag of words passes when off by one."""
text = "Diego"
off_by_one_text = "Digo"
self.assertTrue(helpers.off_by_one_letter(text, off_by_one_text))

def test_bag_of_words_off_by_two(self):
"""Tests that bag of words passes when off by two."""
text = "Diego"
off_by_one_text = "Diaga"
self.assertFalse(helpers.off_by_one_letter(text, off_by_one_text))

0 comments on commit 0774a82

Please sign in to comment.