def test_load_item_df( size, num_movies, movie_example, title_example, genres_example, year_example, tmp, ): """Test movielens item data load (not rating data) """ df = load_item_df(size, local_cache_path=tmp, title_col="title") assert len(df) == num_movies # movie_col and title_col should be loaded assert len(df.columns) == 2 assert df["title"][0] == title_example # Test title and genres df = load_item_df(size, local_cache_path=tmp, movie_col="item", genres_col="genres", year_col="year") assert len(df) == num_movies # movile_col, genres_col and year_col assert len(df.columns) == 3 assert df["item"][0] == movie_example assert df["genres"][0] == genres_example assert df["year"][0] == year_example
def test_load_item_df( size, num_movies, movie_example, title_example, genres_example, year_example, tmp, ): """Test movielens item data load (not rating data)""" df = load_item_df(size, local_cache_path=tmp, title_col="title") assert len(df) == num_movies # movie_col and title_col should be loaded assert len(df.columns) == 2 assert df["title"][0] == title_example # Test title and genres df = load_item_df( size, local_cache_path=tmp, movie_col="item", genres_col="genres", year_col="year", ) assert len(df) == num_movies # movile_col, genres_col and year_col assert len(df.columns) == 3 assert df["item"][0] == movie_example assert df["genres"][0] == genres_example assert df["year"][0] == year_example
def test_load_item_df(size, num_movies, movie_example, title_example, genres_example, year_example): """Test movielens item data load (not rating data) """ with TemporaryDirectory() as tmp_dir: df = load_item_df(size, local_cache_path=tmp_dir, movie_col=None, title_col="title") assert len(df) == num_movies assert len(df.columns) == 1 # Only title column should be loaded assert df["title"][0] == title_example # Test title and genres df = load_item_df(size, local_cache_path=tmp_dir, movie_col="item", genres_col="genres") assert len(df) == num_movies assert len(df.columns) == 2 # movile_col and genres_col assert df["item"][0] == movie_example assert df["genres"][0] == genres_example # Test release year df = load_item_df(size, local_cache_path=tmp_dir, year_col="year") assert len(df) == num_movies assert len(df.columns) == 2 # movile_col (default) and year_col assert df["year"][0] == year_example