From d734a6af7e8bfb299f88f88cf261aaabaf860aab Mon Sep 17 00:00:00 2001 From: Jauzimm Date: Fri, 23 Aug 2024 10:50:59 -0300 Subject: [PATCH] Adicao do teste da funcao de recomendacao a partir de video --- tests/test_recomendation.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_recomendation.py b/tests/test_recomendation.py index ebbce07..8ba462a 100644 --- a/tests/test_recomendation.py +++ b/tests/test_recomendation.py @@ -72,3 +72,15 @@ def mock_get_recommendations(video_id): assert response.status_code == 200 # ok assert response.json() == {"recommend_videos": [2, 1, 3, 4, 5]} + +def test_get_recommendation_from_video(): + # Patch para a função get_recommendations + with patch('pandas.read_csv', return_value=mock_df): + # Patch para a função open e o carregamento do pickle + with patch('builtins.open', mock_open(read_data=pickle.dumps(mock_cosine_sim))): + with patch('recommendation_model.get_video_recommendation.get_recommendations', return_value=mock_recommendations): + response = client.get("/api/recommendation/get_recommendation_video/?video_id=1") + + assert response.status_code == 200 # ok + + assert response.json() == {"recommend_videos": mock_recommendations} \ No newline at end of file