diff --git a/Code/recommenderapp/search.py b/Code/recommenderapp/search.py index dce873a2f..56ee49a6f 100644 --- a/Code/recommenderapp/search.py +++ b/Code/recommenderapp/search.py @@ -67,5 +67,5 @@ def results_top_ten(self, word): return self.results(word)[:10] -if __name__ == "__main__": - app.run() +#if __name__ == "__main__": +# app.run() diff --git a/test/test_search.py b/test/test_search.py index 6fc5b1188..e5c8cb788 100644 --- a/test/test_search.py +++ b/test/test_search.py @@ -1,3 +1,7 @@ +""" +Test suit for search feature +""" + import unittest import warnings import sys @@ -8,12 +12,18 @@ warnings.filterwarnings("ignore") - class Tests(unittest.TestCase): - def testSearchToy(self): + """ + Test cases for search feature + """ + + def test_search_toy(self): + """ + Test case 1 + """ search_word = "toy" - search = Search() - filtered_dict = search.resultsTop10(search_word) + finder = Search() + filtered_dict = finder.results_top_ten(search_word) expected_resp = [ "Toy Story (1995)", "Toys (1992)", @@ -26,10 +36,13 @@ def testSearchToy(self): ] self.assertTrue(filtered_dict == expected_resp) - def testSearchLove(self): + def test_search_love(self): + """ + Test case 2 + """ search_word = "love" - search = Search() - filtered_dict = search.resultsTop10(search_word) + finder = Search() + filtered_dict = finder.results_top_ten(search_word) expected_resp = [ "Love & Human Remains (1993)", "Love Affair (1994)", @@ -44,17 +57,23 @@ def testSearchLove(self): ] self.assertTrue(filtered_dict == expected_resp) - def testSearchGibberish(self): + def test_search_gibberish(self): + """ + Test case 3 + """ search_word = "gibberish" - search = Search() - filtered_dict = search.resultsTop10(search_word) + finder = Search() + filtered_dict = finder.results_top_ten(search_word) expected_resp = [] self.assertTrue(filtered_dict == expected_resp) - def testSearch1995(self): + def test_search_1995(self): + """ + Test case 4 + """ search_word = "1995" - search = Search() - filtered_dict = search.resultsTop10(search_word) + finder = Search() + filtered_dict = finder.results_top_ten(search_word) expected_resp = [ "Toy Story (1995)", "Jumanji (1995)", diff --git a/test/tests.py b/test/tests.py index c7d784455..82d3fc552 100644 --- a/test/tests.py +++ b/test/tests.py @@ -1,120 +1,173 @@ +""" +Test suite for recommender system +""" + import unittest import warnings import sys sys.path.append("../") -from Code.prediction_scripts.item_based import recommendForNewUser +from Code.prediction_scripts.item_based import recommend_for_new_user warnings.filterwarnings("ignore") class Tests(unittest.TestCase): - def testToyStory(self): + """ + Test cases for recommender system + """ + + def test_toy_story(self): + """ + Test case 1 + """ ts = [ {"title": "Toy Story (1995)", "rating": 5.0}, ] - recommendations = recommendForNewUser(ts) + recommendations = recommend_for_new_user(ts) self.assertTrue("Toy Story 3 (2010)" in recommendations) - def testKunfuPanda(self): + def test_kunfu_panda(self): + """ + Test case 2 + """ ts = [ {"title": "Kung Fu Panda (2008)", "rating": 5.0}, ] - recommendations = recommendForNewUser(ts) + recommendations = recommend_for_new_user(ts) self.assertTrue("Toy Story (1995)" in recommendations) - def testHorrorWithCartoon(self): + def test_horror_with_cartoon(self): + """ + Test case 3 + """ ts = [ {"title": "Strangers, The (2008)", "rating": 5.0}, ] - recommendations = recommendForNewUser(ts) + recommendations = recommend_for_new_user(ts) self.assertTrue(("Toy Story (1995)" in recommendations) == False) - def testIronMan(self): + def test_iron_man(self): + """ + Test case 4 + """ ts = [ {"title": "Iron Man (2008)", "rating": 5.0}, ] - recommendations = recommendForNewUser(ts) + recommendations = recommend_for_new_user(ts) self.assertTrue(("Avengers: Infinity War - Part I (2018)" in recommendations)) - def testRoboCop(self): + def test_robo_cop(self): + """ + Test case 5 + """ ts = [ {"title": "RoboCop (1987)", "rating": 5.0}, ] - recommendations = recommendForNewUser(ts) + recommendations = recommend_for_new_user(ts) self.assertTrue(("RoboCop 2 (1990)" in recommendations)) - def testNolan(self): + def test_nolan(self): + """ + Test case 6 + """ ts = [ {"title": "Inception (2010)", "rating": 5.0}, ] - recommendations = recommendForNewUser(ts) + recommendations = recommend_for_new_user(ts) self.assertTrue(("Dark Knight, The (2008)" in recommendations)) - def testDC(self): + def test_dc(self): + """ + Test case 7 + """ ts = [ {"title": "Man of Steel (2013)", "rating": 5.0}, ] - recommendations = recommendForNewUser(ts) + recommendations = recommend_for_new_user(ts) self.assertTrue( ("Batman v Superman: Dawn of Justice (2016)" in recommendations) ) - def testArmageddon(self): + def test_armageddon(self): + """ + Test case 8 + """ ts = [ {"title": "Armageddon (1998)", "rating": 5.0}, ] - recommendations = recommendForNewUser(ts) + recommendations = recommend_for_new_user(ts) self.assertTrue(("2012 (2009)" in recommendations)) - def testLethalWeapon(self): + def test_lethal_weapon(self): + """ + Test case 9 + """ ts = [ {"title": "Lethal Weapon (1987)", "rating": 5.0}, ] - recommendations = recommendForNewUser(ts) + recommendations = recommend_for_new_user(ts) self.assertTrue(("Lethal Weapon 3 (1992)" in recommendations)) - def testDarkAction(self): + def test_dark_action(self): + """ + Test case 10 + """ ts = [ {"title": "Batman: The Killing Joke (2016)", "rating": 5.0}, ] - recommendations = recommendForNewUser(ts) + recommendations = recommend_for_new_user(ts) self.assertTrue(("Punisher: War Zone (2008)" in recommendations)) - def testDark(self): + def test_dark(self): + """ + Test case 11 + """ ts = [ {"title": "Puppet Master (1989)", "rating": 5.0}, ] - recommendations = recommendForNewUser(ts) + recommendations = recommend_for_new_user(ts) self.assertTrue(("Black Mirror: White Christmas (2014)" in recommendations)) - def testHorrorComedy(self): + def test_horror_comedy(self): + """ + Test case 12 + """ ts = [ {"title": "Scary Movie (2000)", "rating": 5.0}, ] - recommendations = recommendForNewUser(ts) + recommendations = recommend_for_new_user(ts) self.assertTrue(("I Sell the Dead (2008)" in recommendations)) - def testSuperHeroes(self): + def test_super_heroes(self): + """ + Test case 13 + """ ts = [ {"title": "Spider-Man (2002)", "rating": 5.0}, ] - recommendations = recommendForNewUser(ts) + recommendations = recommend_for_new_user(ts) self.assertTrue(("Iron Man 2 (2010)" in recommendations)) - def testCartoon(self): + def test_cartoon(self): + """ + Test case 14 + """ ts = [ {"title": "Moana (2016)", "rating": 5.0}, ] - recommendations = recommendForNewUser(ts) + recommendations = recommend_for_new_user(ts) self.assertTrue(("Monsters, Inc. (2001)" in recommendations)) - def testMultipleMovies(self): + def test_multiple_movies(self): + """ + Test case 15 + """ ts = [ {"title": "Harry Potter and the Goblet of Fire (2005)", "rating": 5.0}, {"title": "Twilight Saga: New Moon, The (2009)", "rating": 5.0}, ] - recommendations = recommendForNewUser(ts) + recommendations = recommend_for_new_user(ts) self.assertTrue(("Twilight (2008)" in recommendations))