From 0774a8234d2464dddc919e3dbf7d4e8f49e75711 Mon Sep 17 00:00:00 2001 From: Gabriel Mechali Date: Mon, 28 Oct 2024 14:28:00 -0400 Subject: [PATCH] Adds all three test cases for bag of words. --- server/tests/routes/api/autocomplete_test.py | 22 ++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/server/tests/routes/api/autocomplete_test.py b/server/tests/routes/api/autocomplete_test.py index 0e1d130267..ee19c7f9ca 100644 --- a/server/tests/routes/api/autocomplete_test.py +++ b/server/tests/routes/api/autocomplete_test.py @@ -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)) \ No newline at end of file + # 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))