diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index 920e7400d..f475e448a 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -25,4 +25,6 @@ jobs: run: python test/tests.py - name: Running test cases for searching run: python test/test_search.py + - name: Running test cases for util + run: python test/test_util.py diff --git a/test/test_util.py b/test/test_util.py index 32e8ceac4..5c4186533 100644 --- a/test/test_util.py +++ b/test/test_util.py @@ -5,10 +5,12 @@ import sys import unittest import warnings +from pathlib import Path import pandas as pd -sys.path.append("../") +sys.path.append(str(Path(__file__).resolve().parents[1])) #pylint: disable=wrong-import-position -from src.recommenderapp.utils import create_colored_tags, beautify_feedback_data, create_movie_genres, send_email_to_user +from src.recommenderapp.utils import create_colored_tags, \ + beautify_feedback_data, create_movie_genres, send_email_to_user #pylint: enable=wrong-import-position warnings.filterwarnings("ignore") @@ -35,7 +37,8 @@ def test_create_colored_tags(self): """ Test case 2 """ - expected_result = 'Musical' + expected_result = 'Musical' result = create_colored_tags(['Musical']) self.assertTrue(result == expected_result) @@ -43,9 +46,18 @@ def test_create_movie_genres(self): """ Test case 3 """ - expected_result = {'Toy Story (1995)': ['Animation', 'Comedy', 'Family'], 'Jumanji (1995)': [ + expected_result = {'Toy Story (1995)': ['Animation', 'Comedy', 'Family'], \ + 'Jumanji (1995)': [ 'Adventure', 'Fantasy', 'Family']} - movie_genre_df = pd.read_csv('../data/movies.csv').head(n=2) + + data = [["862", "Toy Story (1995)", "Animation|Comedy|Family", \ + "tt0114709", " ", "/rhIRbceoE9lR4veEXuwCC2wARtG.jpg", "81"], \ + ["8844", "Jumanji (1995)", "Adventure|Fantasy|Family", "tt0113497", " ", \ + "/vzmL6fP7aPKNKPRTFnZmiUfciyV.jpg", "104"]] + + movie_genre_df = pd.DataFrame(data, columns=[ + 'movieId', 'title', 'genres', 'imdb_id', 'overview', 'poster_path', 'runtime']) + result = create_movie_genres(movie_genre_df) self.assertTrue(result == expected_result)