From a815d3677fc0ad6d77e50067c2d43fbaacc5b2d9 Mon Sep 17 00:00:00 2001 From: Charlie Date: Mon, 27 Mar 2023 12:16:53 -0700 Subject: [PATCH 01/23] created notes to build first function --- viewing_party/party.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/viewing_party/party.py b/viewing_party/party.py index 6d34a6b5f..30b4ef0c6 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -1,6 +1,13 @@ # ------------- WAVE 1 -------------------- def create_movie(title, genre, rating): + """ + first function create movie + function takes 3 paramaters/attributes, titles, genre, rating + if three attributers are truthy, return dictionary + if title falsy, genre is falsy or rating is falsy, these should return none + + """ pass # ----------------------------------------- From dacd5a46094eb0b6c7ccaf6ba6a3db283dba9933 Mon Sep 17 00:00:00 2001 From: Charlie Date: Mon, 27 Mar 2023 12:44:11 -0700 Subject: [PATCH 02/23] started first function for title, genre, rating --- viewing_party/party.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 30b4ef0c6..c1533aaf8 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -6,8 +6,17 @@ def create_movie(title, genre, rating): function takes 3 paramaters/attributes, titles, genre, rating if three attributers are truthy, return dictionary if title falsy, genre is falsy or rating is falsy, these should return none - + """ + #new_movie = {} + + if not title | genre: + return true + if rating != int: + return none + + return title, genre, rating + pass # ----------------------------------------- From ddfb2d3460469e27732549d48510e234d05ede54 Mon Sep 17 00:00:00 2001 From: Charlie Date: Mon, 27 Mar 2023 13:48:03 -0700 Subject: [PATCH 03/23] wrote notes as to whats not working in first if statment --- viewing_party/party.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index c1533aaf8..753f0b7c7 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -1,23 +1,33 @@ # ------------- WAVE 1 -------------------- -def create_movie(title, genre, rating): - """ +""" first function create movie function takes 3 paramaters/attributes, titles, genre, rating if three attributers are truthy, return dictionary if title falsy, genre is falsy or rating is falsy, these should return none - """ - #new_movie = {} +""" + +def create_movie(title, genre, rating): + + #possible us of isinstance method + #not accounting for opposite condition of none + new_movie = {} - if not title | genre: - return true + if title or genre != str: + return None if rating != int: - return none + return None + + else: + new_movie["title"] = title + new_movie["genre"] = genre + new_movie["rating"] = rating - return title, genre, rating + return new_movie + print(new_movie) - pass + # ----------------------------------------- # ------------- WAVE 2 -------------------- From 6d8a8d7a65f7c75b388e885a72716b9c2b6cf0cc Mon Sep 17 00:00:00 2001 From: Selene Castillo Date: Mon, 27 Mar 2023 14:43:09 -0700 Subject: [PATCH 04/23] started add_to_watched --- viewing_party/party.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 753f0b7c7..c9b509b04 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -25,10 +25,18 @@ def create_movie(title, genre, rating): new_movie["rating"] = rating return new_movie - print(new_movie) - - +def add_to_watched(user_data, movie): + """ + input: + user_data - a dict with "watched" as key + and a list of dictionaries as the value + movie - a dict with title, genre, rating keys + output: an updated version of user_data with + movie added. + """ + if not movie: + user_data["watched"].append(movie) # ----------------------------------------- # ------------- WAVE 2 -------------------- # ----------------------------------------- From 97ff677ac256f3dc1914389d9790b494c94af601 Mon Sep 17 00:00:00 2001 From: Charlie Date: Mon, 27 Mar 2023 14:45:37 -0700 Subject: [PATCH 05/23] finished first part of create_movie func --- viewing_party/party.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 753f0b7c7..832013434 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -11,21 +11,24 @@ def create_movie(title, genre, rating): #possible us of isinstance method - #not accounting for opposite condition of none - new_movie = {} - if title or genre != str: + if title is None or genre is None or rating is None: return None - if rating != int: - return None - + + new_movie = {"title": title, "genre": genre, "rating": rating} + + if isinstance(title, str) or isinstance(genre, str) or isinstance(rating, int): + return { + "title": title, + "genre": genre, + "rating": rating + } else: - new_movie["title"] = title - new_movie["genre"] = genre - new_movie["rating"] = rating + return None return new_movie - print(new_movie) + + From ab78437a71b6249bc4836082502d0ffea6372871 Mon Sep 17 00:00:00 2001 From: Selene Castillo Date: Mon, 27 Mar 2023 15:05:27 -0700 Subject: [PATCH 06/23] add_to_watched funk passed its 2 tests --- viewing_party/party.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 280b0bead..5a9741862 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -31,9 +31,8 @@ def create_movie(title, genre, rating): def add_to_watched(user_data, movie): - - if not movie: - user_data["watched"].append(movie) + (user_data["watched"]).append(movie) + return user_data # ----------------------------------------- # ------------- WAVE 2 -------------------- # ----------------------------------------- From 3f1652ce7afc0c8c6023b849b81a9d7466e6bacd Mon Sep 17 00:00:00 2001 From: Selene Castillo Date: Mon, 27 Mar 2023 17:08:43 -0700 Subject: [PATCH 07/23] 4th funk done, added assertions --- viewing_party/party.py | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 5a9741862..28495979b 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -7,7 +7,7 @@ if title falsy, genre is falsy or rating is falsy, these should return none """ - +# 1st function def create_movie(title, genre, rating): #possible us of isinstance method @@ -28,11 +28,44 @@ def create_movie(title, genre, rating): return new_movie - - +# 2nd function def add_to_watched(user_data, movie): (user_data["watched"]).append(movie) return user_data + +# watch_movie testing info, please leave commented incase it breaks +# user_data = { +# "watchlist": [ +# {"title": "Land Before Time"}, +# {"title": "Spirited Away"} +# ], +# "watched": [ +# {"title": "Lord of the Rings"}, +# {"title": "Parasyte"}, +# {"title": "Harry Potter"}, +# {"title": "Ready Player One"} +# ] +# } +# title = "Land Before Time" + +# 4th function +def watch_movie(user_data, title): + move_movie = False + index = 0 + movie = None + for index in range(len(user_data["watchlist"])): + if title == user_data["watchlist"][index]["title"]: + move_movie = True + movie_index = index + movie = user_data["watchlist"][index] + print(user_data["watchlist"][index]) + if move_movie: + (user_data["watched"]).append(movie) + del user_data["watchlist"][movie_index] + return user_data +# watch_movie testing info, please leave commented incase it breaks +# watch_movie(user_data, title) + # ----------------------------------------- # ------------- WAVE 2 -------------------- # ----------------------------------------- From d0e42a92998339c30573dfbf00b3a1ee633c53db Mon Sep 17 00:00:00 2001 From: Selene Castillo Date: Mon, 27 Mar 2023 17:09:38 -0700 Subject: [PATCH 08/23] added assertions to tests 9 and 10 --- tests/test_wave_01.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tests/test_wave_01.py b/tests/test_wave_01.py index 669efee6a..c9a91d61a 100644 --- a/tests/test_wave_01.py +++ b/tests/test_wave_01.py @@ -4,7 +4,7 @@ from viewing_party.party import * from tests.test_constants import * -@pytest.mark.skip() +# @pytest.mark.skip() test 1 def test_create_successful_movie(): # Arrange movie_title = MOVIE_TITLE_1 @@ -19,7 +19,7 @@ def test_create_successful_movie(): assert new_movie["genre"] == GENRE_1 assert new_movie["rating"] == pytest.approx(RATING_1) -@pytest.mark.skip() +# @pytest.mark.skip() test 2 def test_create_no_title_movie(): # Arrange movie_title = None @@ -32,7 +32,7 @@ def test_create_no_title_movie(): # Assert assert new_movie is None -@pytest.mark.skip() +# @pytest.mark.skip() test 3 def test_create_no_genre_movie(): # Arrange movie_title = "Title A" @@ -45,7 +45,7 @@ def test_create_no_genre_movie(): # Assert assert new_movie is None -@pytest.mark.skip() +# @pytest.mark.skip() test 4 def test_create_no_rating_movie(): # Arrange movie_title = "Title A" @@ -58,7 +58,7 @@ def test_create_no_rating_movie(): # Assert assert new_movie is None -@pytest.mark.skip() +# @pytest.mark.skip() test 5 def test_adds_movie_to_user_watched(): # Arrange movie = { @@ -79,7 +79,7 @@ def test_adds_movie_to_user_watched(): assert updated_data["watched"][0]["genre"] == GENRE_1 assert updated_data["watched"][0]["rating"] == RATING_1 -@pytest.mark.skip() +# @pytest.mark.skip() test 6 def test_adds_movie_to_non_empty_user_watched(): # Arrange movie = { @@ -99,7 +99,7 @@ def test_adds_movie_to_non_empty_user_watched(): assert movie in updated_data["watched"] assert FANTASY_2 in updated_data["watched"] -@pytest.mark.skip() +# @pytest.mark.skip() test 7 def test_adds_movie_to_user_watchlist(): # Arrange movie = { @@ -120,7 +120,7 @@ def test_adds_movie_to_user_watchlist(): assert updated_data["watchlist"][0]["genre"] == GENRE_1 assert updated_data["watchlist"][0]["rating"] == RATING_1 -@pytest.mark.skip() +# @pytest.mark.skip() test 8 def test_adds_movie_to_non_empty_user_watchlist(): # Arrange movie = { @@ -140,7 +140,7 @@ def test_adds_movie_to_non_empty_user_watchlist(): assert movie in updated_data["watchlist"] assert FANTASY_2 in updated_data["watchlist"] -@pytest.mark.skip() +# @pytest.mark.skip() test 9 def test_moves_movie_from_watchlist_to_empty_watched(): # Arrange janes_data = { @@ -159,12 +159,13 @@ def test_moves_movie_from_watchlist_to_empty_watched(): assert len(updated_data["watchlist"]) == 0 assert len(updated_data["watched"]) == 1 - raise Exception("Test needs to be completed.") + # raise Exception("Test needs to be completed.") + assert MOVIE_TITLE_1 == updated_data["watched"][0]["title"] # ******************************************************************************************* # ****** Add assertions here to test that the correct movie was added to "watched" ********** # ******************************************************************************************* -@pytest.mark.skip() +# @pytest.mark.skip() test 10 def test_moves_movie_from_watchlist_to_watched(): # Arrange movie_to_watch = HORROR_1 @@ -183,12 +184,13 @@ def test_moves_movie_from_watchlist_to_watched(): assert len(updated_data["watchlist"]) == 1 assert len(updated_data["watched"]) == 2 - raise Exception("Test needs to be completed.") + # raise Exception("Test needs to be completed.") + assert movie_to_watch["title"] not in updated_data["watchlist"] # ******************************************************************************************* # ****** Add assertions here to test that the correct movie was added to "watched" ********** # ******************************************************************************************* -@pytest.mark.skip() +# @pytest.mark.skip() test 11 def test_does_nothing_if_movie_not_in_watchlist(): # Arrange movie_to_watch = HORROR_1 From 691b50d41e379785676f58c39ecefe9b454c8b77 Mon Sep 17 00:00:00 2001 From: Charlie Date: Mon, 27 Mar 2023 19:08:57 -0700 Subject: [PATCH 09/23] created attempt at add_watch_list --- viewing_party/party.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/viewing_party/party.py b/viewing_party/party.py index 280b0bead..8907ef65d 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -34,6 +34,16 @@ def add_to_watched(user_data, movie): if not movie: user_data["watched"].append(movie) + +def add_to_watchlist(user_data, movie): + + watchlist = user_data.get("watchlist", []) + + watchlist.append(movie) + user_data["watchlist"] = watchlist + + return user_data + # ----------------------------------------- # ------------- WAVE 2 -------------------- # ----------------------------------------- From a1571773bebf30adee83d1f1272576c4926b2012 Mon Sep 17 00:00:00 2001 From: Charlie Date: Mon, 27 Mar 2023 19:09:58 -0700 Subject: [PATCH 10/23] removed pytest skip --- tests/test_wave_01.py | 4 ++-- tests/test_wave_03.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_wave_01.py b/tests/test_wave_01.py index 669efee6a..a55357057 100644 --- a/tests/test_wave_01.py +++ b/tests/test_wave_01.py @@ -4,7 +4,7 @@ from viewing_party.party import * from tests.test_constants import * -@pytest.mark.skip() + def test_create_successful_movie(): # Arrange movie_title = MOVIE_TITLE_1 @@ -19,7 +19,7 @@ def test_create_successful_movie(): assert new_movie["genre"] == GENRE_1 assert new_movie["rating"] == pytest.approx(RATING_1) -@pytest.mark.skip() + def test_create_no_title_movie(): # Arrange movie_title = None diff --git a/tests/test_wave_03.py b/tests/test_wave_03.py index 046429360..70325b172 100644 --- a/tests/test_wave_03.py +++ b/tests/test_wave_03.py @@ -2,7 +2,7 @@ from viewing_party.party import * from tests.test_constants import * -@pytest.mark.skip() + def test_my_unique_movies(): # Arrange amandas_data = clean_wave_3_data() @@ -16,7 +16,7 @@ def test_my_unique_movies(): assert INTRIGUE_2 in amandas_unique_movies assert amandas_data == clean_wave_3_data() -@pytest.mark.skip() + def test_my_not_unique_movies(): # Arrange amandas_data = clean_wave_3_data() From 6622d00b6a697359146da11d265dce8bf5377f47 Mon Sep 17 00:00:00 2001 From: Selene Castillo Date: Tue, 28 Mar 2023 10:40:25 -0700 Subject: [PATCH 11/23] uncommented wave2 tests --- tests/test_wave_02.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_wave_02.py b/tests/test_wave_02.py index 19f045c79..acd7c877c 100644 --- a/tests/test_wave_02.py +++ b/tests/test_wave_02.py @@ -2,7 +2,7 @@ from viewing_party.party import * from tests.test_constants import * -@pytest.mark.skip() +# @pytest.mark.skip() def test_calculates_watched_average_rating(): # Arrange janes_data = clean_wave_2_data() @@ -14,7 +14,7 @@ def test_calculates_watched_average_rating(): assert average == pytest.approx(3.58333) assert janes_data == clean_wave_2_data() -@pytest.mark.skip() +# @pytest.mark.skip() def test_empty_watched_average_rating_is_zero(): # Arrange janes_data = { From 2d350f84d33844b909b3b437b1b4b8cdf3ea4a55 Mon Sep 17 00:00:00 2001 From: Selene Castillo Date: Tue, 28 Mar 2023 10:41:30 -0700 Subject: [PATCH 12/23] 1st funk in wave 2 done --- viewing_party/party.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 09644cd3c..8ec3dcb2d 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -84,8 +84,38 @@ def watch_movie(user_data, title): # ----------------------------------------- # ------------- WAVE 2 -------------------- # ----------------------------------------- +# get_watched_avg_rating testing info, please leave commented incase it breaks +# user_data = { +# "watchlist": [ +# {"title": "Land Before Time", "rating": 2}, +# {"title": "Spirited Away", "rating": 3} +# ], +# "watched": [ +# {"title": "Lord of the Rings", "rating":4}, +# {"title": "Parasyte", "rating":3}, +# {"title": "Harry Potter", "rating":1}, +# {"title": "Ready Player One", "rating":5} +# ] +# } - +# 1st function in Wave 2 +def get_watched_avg_rating(user_data): +# created a variable for the sum of all ratings, the # of movies and the average + movie_count = 0 + ratings_sum = 0 + ratings_avg = 0 +# check if there are movies in "watched" + if user_data["watched"]: +# loop through movies in watched + for index in range(len(user_data["watched"])): +# update variables + movie_count += 1 + ratings_sum += user_data["watched"][index]["rating"] + ratings_avg = ratings_sum/movie_count + return ratings_avg + +# get_watched_avg_rating testing info, please leave commented incase it breaks +# get_watched_avg_rating(user_data) # ----------------------------------------- # ------------- WAVE 3 -------------------- # ----------------------------------------- From fa4f32da918ff3ec56945cd8ea85c87ffd75a0df Mon Sep 17 00:00:00 2001 From: Charlie Date: Tue, 28 Mar 2023 11:03:14 -0700 Subject: [PATCH 13/23] built second function for wave 2, removed pytest skip --- tests/test_wave_01.py | 9 +-------- tests/test_wave_02.py | 6 +++--- tests/test_wave_03.py | 2 +- viewing_party/party.py | 21 ++++++++++++++++++++- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/tests/test_wave_01.py b/tests/test_wave_01.py index 97652e9fa..c79361ea6 100644 --- a/tests/test_wave_01.py +++ b/tests/test_wave_01.py @@ -4,11 +4,7 @@ from viewing_party.party import * from tests.test_constants import * -<<<<<<< HEAD - -======= # @pytest.mark.skip() test 1 ->>>>>>> d0e42a92998339c30573dfbf00b3a1ee633c53db def test_create_successful_movie(): # Arrange movie_title = MOVIE_TITLE_1 @@ -23,11 +19,7 @@ def test_create_successful_movie(): assert new_movie["genre"] == GENRE_1 assert new_movie["rating"] == pytest.approx(RATING_1) -<<<<<<< HEAD -======= -# @pytest.mark.skip() test 2 ->>>>>>> d0e42a92998339c30573dfbf00b3a1ee633c53db def test_create_no_title_movie(): # Arrange movie_title = None @@ -215,3 +207,4 @@ def test_does_nothing_if_movie_not_in_watchlist(): assert len(updated_data["watched"]) == 1 assert movie_to_watch not in updated_data["watchlist"] assert movie_to_watch not in updated_data["watched"] + diff --git a/tests/test_wave_02.py b/tests/test_wave_02.py index 19f045c79..5ca7774e2 100644 --- a/tests/test_wave_02.py +++ b/tests/test_wave_02.py @@ -27,7 +27,7 @@ def test_empty_watched_average_rating_is_zero(): # Assert assert average == pytest.approx(0.0) -@pytest.mark.skip() + def test_most_watched_genre(): # Arrange janes_data = clean_wave_2_data() @@ -39,7 +39,7 @@ def test_most_watched_genre(): assert popular_genre == "Fantasy" assert janes_data == clean_wave_2_data() -@pytest.mark.skip() + def test_most_watched_genre_order_mixed(): # Arrange janes_data = clean_wave_2b_data() @@ -51,7 +51,7 @@ def test_most_watched_genre_order_mixed(): assert popular_genre == "Fantasy" assert janes_data == clean_wave_2b_data() -@pytest.mark.skip() + def test_genre_is_None_if_empty_watched(): # Arrange janes_data = { diff --git a/tests/test_wave_03.py b/tests/test_wave_03.py index 70325b172..3de7be003 100644 --- a/tests/test_wave_03.py +++ b/tests/test_wave_03.py @@ -55,7 +55,7 @@ def test_friends_unique_movies_not_duplicated(): # Assert assert len(friends_unique_movies) == 3 - raise Exception("Test needs to be completed.") + #raise Exception("Test needs to be completed.") # ************************************************************************************************* # ****** Add assertions here to test that the correct movies are in friends_unique_movies ********** # ************************************************************************************************** diff --git a/viewing_party/party.py b/viewing_party/party.py index 09644cd3c..15fde222b 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -51,7 +51,7 @@ def add_to_watchlist(user_data, movie): # user_data = { # "watchlist": [ # {"title": "Land Before Time"}, -# {"title": "Spirited Away"} +# {"title": "Spirited Away"}git # ], # "watched": [ # {"title": "Lord of the Rings"}, @@ -84,6 +84,25 @@ def watch_movie(user_data, title): # ----------------------------------------- # ------------- WAVE 2 -------------------- # ----------------------------------------- +def get_most_watched_genre(user_data): + + most_watched_genre = user_data.get("watched",[]) + + if not most_watched_genre: + return None + + + genres = {} + for movie in most_watched_genre: + genre = movie.get("genre") + if genre in genres: + genres[genre] += 1 + else: + genres[genre] = 1 + + most_watched_genre = max(genres, key=genres.get) + + return most_watched_genre #most viewed genre # ----------------------------------------- From 47e1b78d1e708a1d493b8cc6e904559b5b03fbbd Mon Sep 17 00:00:00 2001 From: Selene Castillo Date: Tue, 28 Mar 2023 18:27:40 -0700 Subject: [PATCH 14/23] some progress with 1st funk in wave 3 --- viewing_party/party.py | 101 ++++++++++++++++++++++++++++++++++------- 1 file changed, 84 insertions(+), 17 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 3bde4568b..e6b9f3083 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -80,6 +80,19 @@ def watch_movie(user_data, title): # watch_movie testing info, please leave commented incase it breaks # watch_movie(user_data, title) +# get_watched_avg_rating testing info, please leave commented incase it breaks +# user_data = { +# "watchlist": [ +# {"title": "Land Before Time", "rating": 2}, +# {"title": "Spirited Away", "rating": 3} +# ], +# "watched": [ +# {"title": "Lord of the Rings", "rating":4}, +# {"title": "Parasyte", "rating":3}, +# {"title": "Harry Potter", "rating":1}, +# {"title": "Ready Player One", "rating":5} +# ] +# } # 1st function in Wave 2 def get_watched_avg_rating(user_data): @@ -122,27 +135,81 @@ def get_most_watched_genre(user_data): return most_watched_genre #most viewed genre -# get_watched_avg_rating testing info, please leave commented incase it breaks -# user_data = { -# "watchlist": [ -# {"title": "Land Before Time", "rating": 2}, -# {"title": "Spirited Away", "rating": 3} -# ], -# "watched": [ -# {"title": "Lord of the Rings", "rating":4}, -# {"title": "Parasyte", "rating":3}, -# {"title": "Harry Potter", "rating":1}, -# {"title": "Ready Player One", "rating":5} -# ] -# } - - - # ----------------------------------------- # ------------- WAVE 3 -------------------- # ----------------------------------------- - +# get_unique_watched testing info, please leave commented incase it breaks +user_data = { 'friends': [ { 'watched': [ { 'genre': 'Fantasy', + 'rating': 4.8, + 'title': 'The Lord of the Functions: ' + 'The Fellowship of the ' + 'Function'}, + { 'genre': 'Fantasy', + 'rating': 4.0, + 'title': 'The Lord of the Functions: ' + 'The Return of the Value'}, + { 'genre': 'Fantasy', + 'rating': 4.0, + 'title': 'The Programmer: An ' + 'Unexpected Stack Trace'}, + { 'genre': 'Horror', + 'rating': 3.5, + 'title': 'It Came from the Stack ' + 'Trace'}]}, + { 'watched': [ { 'genre': 'Fantasy', + 'rating': 4.8, + 'title': 'The Lord of the Functions: ' + 'The Fellowship of the ' + 'Function'}, + { 'genre': 'Action', + 'rating': 2.2, + 'title': 'The JavaScript and the ' + 'React'}, + { 'genre': 'Intrigue', + 'rating': 2.0, + 'title': 'Recursion'}, + { 'genre': 'Intrigue', + 'rating': 3.0, + 'title': 'Zero Dark Python'}]}], +'watched': [ { 'genre': 'Fantasy', + 'rating': 4.8, + 'title': 'The Lord of the Functions: The Fellowship of ' + 'the Function'}, + { 'genre': 'Fantasy', + 'rating': 4.0, + 'title': 'The Lord of the Functions: The Two ' + 'Parameters'}, + { 'genre': 'Fantasy', + 'rating': 4.0, + 'title': 'The Lord of the Functions: The Return of the ' + 'Value'}, + { 'genre': 'Action', + 'rating': 2.2, + 'title': 'The JavaScript and the React'}, + {'genre': 'Intrigue', 'rating': 2.0, 'title': 'Recursion'}, + { 'genre': 'Intrigue', + 'rating': 4.5, + 'title': 'Instructor Student TA Manager'}]} + + +# 1st function in Wave 3 + +def get_unique_watched(user_data): +# code below does not work because of first if statement aint workin, try using sets + user_only_movies = [] + + for friend in user_data["friends"]: + for movie in user_data["watched"]: + if movie not in friend["watched"]: + if movie in user_only_movies: + continue + else: + user_only_movies.append(movie) + + return print(user_only_movies) + +get_unique_watched(user_data) # ----------------------------------------- # ------------- WAVE 4 -------------------- # ----------------------------------------- From 8e3a180acbefab2ffb898e55c8647f5c6e6cbf96 Mon Sep 17 00:00:00 2001 From: Charlie Date: Tue, 28 Mar 2023 21:27:40 -0700 Subject: [PATCH 15/23] fixed second function in wave3, adding notes written for wave 4 --- play_tester.py | 12 +++---- tests/test_wave_03.py | 12 +++++-- viewing_party/party.py | 81 +++++++++++++++++++++++++++++++++++++++--- 3 files changed, 92 insertions(+), 13 deletions(-) diff --git a/play_tester.py b/play_tester.py index 9e2aecf48..6928c964b 100644 --- a/play_tester.py +++ b/play_tester.py @@ -9,16 +9,16 @@ pp = pprint.PrettyPrinter(indent=4) # play testing section -print("\n-----Wave 01 test data-----") -pp.pprint(HORROR_1) -pp.pprint(FANTASY_1) -pp.pprint(FANTASY_2) +# print("\n-----Wave 01 test data-----") +# pp.pprint(HORROR_1) +# pp.pprint(FANTASY_1) +# pp.pprint(FANTASY_2) # print("\n-----Wave 02 user_data-----") # pp.pprint(clean_wave_2_data()) -#print("\n-----Wave 03 user_data-----") -#pp.pprint(clean_wave_3_data()) +print("\n-----Wave 03 user_data-----") +pp.pprint(clean_wave_3_data()) # Wave 04 user data #print("\n-----Wave 04 user_data-----") diff --git a/tests/test_wave_03.py b/tests/test_wave_03.py index 3de7be003..c54346fc2 100644 --- a/tests/test_wave_03.py +++ b/tests/test_wave_03.py @@ -3,6 +3,7 @@ from tests.test_constants import * +@pytest.mark.skip() def test_my_unique_movies(): # Arrange amandas_data = clean_wave_3_data() @@ -16,6 +17,7 @@ def test_my_unique_movies(): assert INTRIGUE_2 in amandas_unique_movies assert amandas_data == clean_wave_3_data() +@pytest.mark.skip() def test_my_not_unique_movies(): # Arrange @@ -28,7 +30,7 @@ def test_my_not_unique_movies(): # Assert assert len(amandas_unique_movies) == 0 -@pytest.mark.skip() + def test_friends_unique_movies(): # Arrange amandas_data = clean_wave_3_data() @@ -43,7 +45,7 @@ def test_friends_unique_movies(): assert FANTASY_4 in friends_unique_movies assert amandas_data == clean_wave_3_data() -@pytest.mark.skip() + def test_friends_unique_movies_not_duplicated(): # Arrange amandas_data = clean_wave_3_data() @@ -54,7 +56,11 @@ def test_friends_unique_movies_not_duplicated(): # Assert assert len(friends_unique_movies) == 3 - + assert FANTASY_4 in friends_unique_movies + assert HORROR_1 in friends_unique_movies + assert INTRIGUE_3 in friends_unique_movies + + #raise Exception("Test needs to be completed.") # ************************************************************************************************* # ****** Add assertions here to test that the correct movies are in friends_unique_movies ********** diff --git a/viewing_party/party.py b/viewing_party/party.py index 3bde4568b..34be9feb7 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -137,12 +137,85 @@ def get_most_watched_genre(user_data): # } +#wave 3 +#function 2 + + +def get_friends_unique_watched(user_data): + + user_watched = set([movie["title"] for movie in user_data["watched"]]) + friends_list = [] + + for friend in user_data["friends"]: + for movie in friend["watched"]: + if movie["title"] not in user_watched and movie not in friends_list: + friends_list.append(movie) + + return friends_list + +""" +does not remove duplicates + user = user_data["watched"] + friends = user_data["friends"] + + friends_list = [] + + #i = watched + for i_dict in friends: + movies_list = i_dict["watched"] + for movies_dict in movies_list: + if movies_dict not in user: + friends_list.append(movies_dict) + if key,value in friends_list["title"] + return friends_list +""" + + +#wave 4 +#function 1 + +# def get_available_recs(user_data): +# """ +# takes 1 parameter user_data +# user_data field subcscriptions +# value of subscriptions is list of string +# represents the names of ea streaming service user has access +# ea friend in friends has watched list +# ea movie in watched list has host +# host is string that says what streaming service is hosted on +# determine list of recs nmovies +# movie should be added to list only if +# user has not watched +# atleast one user friend has watched +# host of movie is service thats in users subscription +# return list of rec movies +# """ +# amandas_data = { +# "subscriptions": ["hulu", "disney+"], +# "watched": [], +# "friends": [ +# { +# "watched": [HORROR_1b] +# }, +# { +# "watched": [FANTASY_3b] +# } +# ] +# } +# #subscription ['netflix','hulu','crunchyroll'] +# friends = [friend:[movie : "host"(watched list)]] +# list_of_rec_movies = [] + +# users_subscriptions = user_data[0] +# #[friends][0][watched] +# movies add to list if +# user has not watched +# one friend has watched +# host is a service users owns +# return list_of_rec_movies + -# ----------------------------------------- -# ------------- WAVE 3 -------------------- -# ----------------------------------------- - # ----------------------------------------- # ------------- WAVE 4 -------------------- # ----------------------------------------- From ccb7473954edbe3efdf1dda0cbba842792ae5804 Mon Sep 17 00:00:00 2001 From: Selene Castillo Date: Wed, 29 Mar 2023 14:59:56 -0700 Subject: [PATCH 16/23] added pseudocode for funk in wave 4 --- viewing_party/party.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 446fa0eb5..af0a6d001 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -256,7 +256,7 @@ def get_friends_unique_watched(user_data): #wave 4 #function 1 -# def get_available_recs(user_data): +def get_available_recs(user_data): # """ # takes 1 parameter user_data # user_data field subcscriptions @@ -285,7 +285,7 @@ def get_friends_unique_watched(user_data): # ] # } # #subscription ['netflix','hulu','crunchyroll'] -# friends = [friend:[movie : "host"(watched list)]] + # friends = [friend:[movie : "host"(watched list)]] # list_of_rec_movies = [] # users_subscriptions = user_data[0] @@ -295,7 +295,22 @@ def get_friends_unique_watched(user_data): # one friend has watched # host is a service users owns # return list_of_rec_movies - + +# Selenes psudo code below +import copy + +list_of_movies_not_seen_by_user = get_friends_unique_watched(user_data) +list_of_subscriptions_host_has = user_data["subscriptions"] +list_of_movies_not_seen_on_users_subscriptions = [] +loop through each movie in list_of_movies_not_seen_by_user: + if movie[host] is in list_of_subscriptions_host_has: + new_movie = copy.deepcopy(movie) + list_of_movies_not_seen_on_users_subscriptions.append(new_movie) + else: + continue +return list_of_movies_not_seen_on_users_subscriptions + + # ----------------------------------------- From 8cbc6e48d513a0e8ef96431495c52abf22c3bab7 Mon Sep 17 00:00:00 2001 From: Selene Castillo Date: Wed, 29 Mar 2023 15:56:25 -0700 Subject: [PATCH 17/23] 1st funk in Wave 3 complete --- viewing_party/party.py | 167 +++++++++++++++++++++-------------------- 1 file changed, 86 insertions(+), 81 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index af0a6d001..ab849ccef 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -47,7 +47,7 @@ def add_to_watchlist(user_data, movie): return user_data -# watch_movie testing info, please leave commented incase it breaks +# watch_movie testing info, please leave commented in case it breaks # user_data = { # "watchlist": [ # {"title": "Land Before Time"}, @@ -80,7 +80,7 @@ def watch_movie(user_data, title): # watch_movie testing info, please leave commented incase it breaks # watch_movie(user_data, title) -# get_watched_avg_rating testing info, please leave commented incase it breaks +# get_watched_avg_rating testing info, please leave commented in case it breaks # user_data = { # "watchlist": [ # {"title": "Land Before Time", "rating": 2}, @@ -110,7 +110,7 @@ def get_watched_avg_rating(user_data): ratings_avg = ratings_sum/movie_count return ratings_avg -# get_watched_avg_rating testing info, please leave commented incase it breaks +# get_watched_avg_rating testing info, please leave commented in case it breaks # get_watched_avg_rating(user_data) #wave 2 @@ -135,7 +135,7 @@ def get_most_watched_genre(user_data): return most_watched_genre #most viewed genre -# get_watched_avg_rating testing info, please leave commented incase it breaks +# get_watched_avg_rating testing info, please leave commented in case it breaks # user_data = { # "watchlist": [ # {"title": "Land Before Time", "rating": 2}, @@ -148,77 +148,80 @@ def get_most_watched_genre(user_data): # {"title": "Ready Player One", "rating":5} # ] # } -# get_unique_watched testing info, please leave commented incase it breaks -user_data = { 'friends': [ { 'watched': [ { 'genre': 'Fantasy', - 'rating': 4.8, - 'title': 'The Lord of the Functions: ' - 'The Fellowship of the ' - 'Function'}, - { 'genre': 'Fantasy', - 'rating': 4.0, - 'title': 'The Lord of the Functions: ' - 'The Return of the Value'}, - { 'genre': 'Fantasy', - 'rating': 4.0, - 'title': 'The Programmer: An ' - 'Unexpected Stack Trace'}, - { 'genre': 'Horror', - 'rating': 3.5, - 'title': 'It Came from the Stack ' - 'Trace'}]}, - { 'watched': [ { 'genre': 'Fantasy', - 'rating': 4.8, - 'title': 'The Lord of the Functions: ' - 'The Fellowship of the ' - 'Function'}, - { 'genre': 'Action', - 'rating': 2.2, - 'title': 'The JavaScript and the ' - 'React'}, - { 'genre': 'Intrigue', - 'rating': 2.0, - 'title': 'Recursion'}, - { 'genre': 'Intrigue', - 'rating': 3.0, - 'title': 'Zero Dark Python'}]}], -'watched': [ { 'genre': 'Fantasy', - 'rating': 4.8, - 'title': 'The Lord of the Functions: The Fellowship of ' - 'the Function'}, - { 'genre': 'Fantasy', - 'rating': 4.0, - 'title': 'The Lord of the Functions: The Two ' - 'Parameters'}, - { 'genre': 'Fantasy', - 'rating': 4.0, - 'title': 'The Lord of the Functions: The Return of the ' - 'Value'}, - { 'genre': 'Action', - 'rating': 2.2, - 'title': 'The JavaScript and the React'}, - {'genre': 'Intrigue', 'rating': 2.0, 'title': 'Recursion'}, - { 'genre': 'Intrigue', - 'rating': 4.5, - 'title': 'Instructor Student TA Manager'}]} +# get_unique_watched testing info, please leave commented in case it breaks +# user_data = { 'friends': [ { 'watched': [ { 'genre': 'Fantasy', +# 'rating': 4.8, +# 'title': 'The Lord of the Functions: ' +# 'The Fellowship of the ' +# 'Function'}, +# { 'genre': 'Fantasy', +# 'rating': 4.0, +# 'title': 'The Lord of the Functions: ' +# 'The Return of the Value'}, +# { 'genre': 'Fantasy', +# 'rating': 4.0, +# 'title': 'The Programmer: An ' +# 'Unexpected Stack Trace'}, +# { 'genre': 'Horror', +# 'rating': 3.5, +# 'title': 'It Came from the Stack ' +# 'Trace'}]}, +# { 'watched': [ { 'genre': 'Fantasy', +# 'rating': 4.8, +# 'title': 'The Lord of the Functions: ' +# 'The Fellowship of the ' +# 'Function'}, +# { 'genre': 'Action', +# 'rating': 2.2, +# 'title': 'The JavaScript and the ' +# 'React'}, +# { 'genre': 'Intrigue', +# 'rating': 2.0, +# 'title': 'Recursion'}, +# { 'genre': 'Intrigue', +# 'rating': 3.0, +# 'title': 'Zero Dark Python'}]}], +# 'watched': [ { 'genre': 'Fantasy', +# 'rating': 4.8, +# 'title': 'The Lord of the Functions: The Fellowship of ' +# 'the Function'}, +# { 'genre': 'Fantasy', +# 'rating': 4.0, +# 'title': 'The Lord of the Functions: The Two ' +# 'Parameters'}, +# { 'genre': 'Fantasy', +# 'rating': 4.0, +# 'title': 'The Lord of the Functions: The Return of the ' +# 'Value'}, +# { 'genre': 'Action', +# 'rating': 2.2, +# 'title': 'The JavaScript and the React'}, +# {'genre': 'Intrigue', 'rating': 2.0, 'title': 'Recursion'}, +# { 'genre': 'Intrigue', +# 'rating': 4.5, +# 'title': 'Instructor Student TA Manager'}]} # 1st function in Wave 3 def get_unique_watched(user_data): -# code below does not work because of first if statement aint workin, try using sets - user_only_movies = [] +# code below is adaptation of funk 2 in wave 3, can be refactored + friends_watched_list = [] + friends_watched_set = None + friends_list = [] for friend in user_data["friends"]: - for movie in user_data["watched"]: - if movie not in friend["watched"]: - if movie in user_only_movies: - continue - else: - user_only_movies.append(movie) - - return print(user_only_movies) + for movie in friend["watched"]: + friends_watched_list.append(movie["title"]) + friends_watched_set = set(friends_watched_list) + # print(friends_watched_set) + for movie in user_data["watched"]: + if movie["title"] not in friends_watched_set and movie not in friends_list: + friends_list.append(movie) -get_unique_watched(user_data) + return friends_list +# get_unique_watched testing info, please leave commented in case it breaks +# get_unique_watched(user_data) #wave 3 @@ -227,7 +230,7 @@ def get_friends_unique_watched(user_data): user_watched = set([movie["title"] for movie in user_data["watched"]]) friends_list = [] - + print(user_watched) for friend in user_data["friends"]: for movie in friend["watched"]: if movie["title"] not in user_watched and movie not in friends_list: @@ -235,6 +238,7 @@ def get_friends_unique_watched(user_data): return friends_list + """ does not remove duplicates user = user_data["watched"] @@ -256,7 +260,7 @@ def get_friends_unique_watched(user_data): #wave 4 #function 1 -def get_available_recs(user_data): +# def get_available_recs(user_data): # """ # takes 1 parameter user_data # user_data field subcscriptions @@ -297,18 +301,19 @@ def get_available_recs(user_data): # return list_of_rec_movies # Selenes psudo code below -import copy - -list_of_movies_not_seen_by_user = get_friends_unique_watched(user_data) -list_of_subscriptions_host_has = user_data["subscriptions"] -list_of_movies_not_seen_on_users_subscriptions = [] -loop through each movie in list_of_movies_not_seen_by_user: - if movie[host] is in list_of_subscriptions_host_has: - new_movie = copy.deepcopy(movie) - list_of_movies_not_seen_on_users_subscriptions.append(new_movie) - else: - continue -return list_of_movies_not_seen_on_users_subscriptions +# import copy + +# list_of_movies_not_seen_by_user = get_friends_unique_watched(user_data) +# # will this list^ have the host info in it? +# list_of_subscriptions_host_has = user_data["subscriptions"] +# list_of_movies_not_seen_on_users_subscriptions = [] +# loop through each movie in list_of_movies_not_seen_by_user: +# if movie[host] is in list_of_subscriptions_host_has: +# new_movie = copy.deepcopy(movie) +# list_of_movies_not_seen_on_users_subscriptions.append(new_movie) +# else: +# continue +# return list_of_movies_not_seen_on_users_subscriptions From 2a85ffda07dd134aad20ff1daa386aa1bdbb2626 Mon Sep 17 00:00:00 2001 From: Selene Castillo Date: Wed, 29 Mar 2023 16:15:42 -0700 Subject: [PATCH 18/23] wave 4 complete --- viewing_party/party.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index ab849ccef..b00622fac 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -201,6 +201,9 @@ def get_most_watched_genre(user_data): # 'rating': 4.5, # 'title': 'Instructor Student TA Manager'}]} +# ----------------------------------------- +# ------------- WAVE 3 -------------------- +# ----------------------------------------- # 1st function in Wave 3 @@ -255,7 +258,9 @@ def get_friends_unique_watched(user_data): if key,value in friends_list["title"] return friends_list """ - +# ----------------------------------------- +# ------------- WAVE 4 -------------------- +# ----------------------------------------- #wave 4 #function 1 @@ -306,7 +311,7 @@ def get_friends_unique_watched(user_data): # list_of_movies_not_seen_by_user = get_friends_unique_watched(user_data) # # will this list^ have the host info in it? # list_of_subscriptions_host_has = user_data["subscriptions"] -# list_of_movies_not_seen_on_users_subscriptions = [] +# list_of_movies_not_seen_but_on_users_subscriptions = [] # loop through each movie in list_of_movies_not_seen_by_user: # if movie[host] is in list_of_subscriptions_host_has: # new_movie = copy.deepcopy(movie) @@ -315,18 +320,17 @@ def get_friends_unique_watched(user_data): # continue # return list_of_movies_not_seen_on_users_subscriptions +# working code below +def get_available_recs(user_data): + unseen_by_user = get_friends_unique_watched(user_data) + user_subscriptions = user_data["subscriptions"] + available_recs = [] + for movie in unseen_by_user: + if movie["host"] in user_subscriptions: + available_recs.append(movie) + return available_recs - -# ----------------------------------------- -# ------------- WAVE 3 -------------------- -# ----------------------------------------- - - -# ----------------------------------------- -# ------------- WAVE 4 -------------------- -# ----------------------------------------- - # ----------------------------------------- # ------------- WAVE 5 -------------------- # ----------------------------------------- From 7711b779728f1c5bc295ce057fc6c399de63dfd5 Mon Sep 17 00:00:00 2001 From: Selene Castillo Date: Thu, 30 Mar 2023 14:02:28 -0700 Subject: [PATCH 19/23] 2nd function in wave 5 complete --- viewing_party/party.py | 167 ++++++++--------------------------------- 1 file changed, 30 insertions(+), 137 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index b00622fac..aa163903c 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -7,7 +7,7 @@ if title falsy, genre is falsy or rating is falsy, these should return none """ -# 1st function +# 1st function in Wave 1 def create_movie(title, genre, rating): #possible us of isinstance method @@ -25,18 +25,19 @@ def create_movie(title, genre, rating): } else: return None +# COMMENTED LINE BELOW LOOKS LIKE IT CAN BE DELETED****************************** + # return new_movie - return new_movie - -# 2nd function +# 2nd function in Wave 1 def add_to_watched(user_data, movie): (user_data["watched"]).append(movie) return user_data - if not movie: - user_data["watched"].append(movie) +# TWO COMMENTED LINES BELOW LOOK LIKE THEY CAN BE DELETED****************************** + # if not movie: + # user_data["watched"].append(movie) -#3rd function +# 3rd function in Wave 1 def add_to_watchlist(user_data, movie): watchlist = user_data.get("watchlist", []) @@ -47,22 +48,7 @@ def add_to_watchlist(user_data, movie): return user_data -# watch_movie testing info, please leave commented in case it breaks -# user_data = { -# "watchlist": [ -# {"title": "Land Before Time"}, -# {"title": "Spirited Away"}git -# ], -# "watched": [ -# {"title": "Lord of the Rings"}, -# {"title": "Parasyte"}, -# {"title": "Harry Potter"}, -# {"title": "Ready Player One"} -# ] -# } -# title = "Land Before Time" - -# 4th function +# 4th function in Wave 1 def watch_movie(user_data, title): move_movie = False index = 0 @@ -77,22 +63,8 @@ def watch_movie(user_data, title): (user_data["watched"]).append(movie) del user_data["watchlist"][movie_index] return user_data -# watch_movie testing info, please leave commented incase it breaks -# watch_movie(user_data, title) - -# get_watched_avg_rating testing info, please leave commented in case it breaks -# user_data = { -# "watchlist": [ -# {"title": "Land Before Time", "rating": 2}, -# {"title": "Spirited Away", "rating": 3} -# ], -# "watched": [ -# {"title": "Lord of the Rings", "rating":4}, -# {"title": "Parasyte", "rating":3}, -# {"title": "Harry Potter", "rating":1}, -# {"title": "Ready Player One", "rating":5} -# ] -# } + +# ------------- WAVE 2 -------------------- # 1st function in Wave 2 def get_watched_avg_rating(user_data): @@ -110,11 +82,8 @@ def get_watched_avg_rating(user_data): ratings_avg = ratings_sum/movie_count return ratings_avg -# get_watched_avg_rating testing info, please leave commented in case it breaks -# get_watched_avg_rating(user_data) -#wave 2 -#function 2 +# 2nd function in Wave 2 def get_most_watched_genre(user_data): most_watched_genre = user_data.get("watched",[]) @@ -135,78 +104,9 @@ def get_most_watched_genre(user_data): return most_watched_genre #most viewed genre -# get_watched_avg_rating testing info, please leave commented in case it breaks -# user_data = { -# "watchlist": [ -# {"title": "Land Before Time", "rating": 2}, -# {"title": "Spirited Away", "rating": 3} -# ], -# "watched": [ -# {"title": "Lord of the Rings", "rating":4}, -# {"title": "Parasyte", "rating":3}, -# {"title": "Harry Potter", "rating":1}, -# {"title": "Ready Player One", "rating":5} -# ] -# } -# get_unique_watched testing info, please leave commented in case it breaks -# user_data = { 'friends': [ { 'watched': [ { 'genre': 'Fantasy', -# 'rating': 4.8, -# 'title': 'The Lord of the Functions: ' -# 'The Fellowship of the ' -# 'Function'}, -# { 'genre': 'Fantasy', -# 'rating': 4.0, -# 'title': 'The Lord of the Functions: ' -# 'The Return of the Value'}, -# { 'genre': 'Fantasy', -# 'rating': 4.0, -# 'title': 'The Programmer: An ' -# 'Unexpected Stack Trace'}, -# { 'genre': 'Horror', -# 'rating': 3.5, -# 'title': 'It Came from the Stack ' -# 'Trace'}]}, -# { 'watched': [ { 'genre': 'Fantasy', -# 'rating': 4.8, -# 'title': 'The Lord of the Functions: ' -# 'The Fellowship of the ' -# 'Function'}, -# { 'genre': 'Action', -# 'rating': 2.2, -# 'title': 'The JavaScript and the ' -# 'React'}, -# { 'genre': 'Intrigue', -# 'rating': 2.0, -# 'title': 'Recursion'}, -# { 'genre': 'Intrigue', -# 'rating': 3.0, -# 'title': 'Zero Dark Python'}]}], -# 'watched': [ { 'genre': 'Fantasy', -# 'rating': 4.8, -# 'title': 'The Lord of the Functions: The Fellowship of ' -# 'the Function'}, -# { 'genre': 'Fantasy', -# 'rating': 4.0, -# 'title': 'The Lord of the Functions: The Two ' -# 'Parameters'}, -# { 'genre': 'Fantasy', -# 'rating': 4.0, -# 'title': 'The Lord of the Functions: The Return of the ' -# 'Value'}, -# { 'genre': 'Action', -# 'rating': 2.2, -# 'title': 'The JavaScript and the React'}, -# {'genre': 'Intrigue', 'rating': 2.0, 'title': 'Recursion'}, -# { 'genre': 'Intrigue', -# 'rating': 4.5, -# 'title': 'Instructor Student TA Manager'}]} - -# ----------------------------------------- # ------------- WAVE 3 -------------------- -# ----------------------------------------- # 1st function in Wave 3 - def get_unique_watched(user_data): # code below is adaptation of funk 2 in wave 3, can be refactored friends_watched_list = [] @@ -223,12 +123,8 @@ def get_unique_watched(user_data): friends_list.append(movie) return friends_list -# get_unique_watched testing info, please leave commented in case it breaks -# get_unique_watched(user_data) - -#wave 3 -#function 2 +# 2nd function in Wave 3 def get_friends_unique_watched(user_data): user_watched = set([movie["title"] for movie in user_data["watched"]]) @@ -258,9 +154,9 @@ def get_friends_unique_watched(user_data): if key,value in friends_list["title"] return friends_list """ -# ----------------------------------------- + # ------------- WAVE 4 -------------------- -# ----------------------------------------- + #wave 4 #function 1 @@ -305,22 +201,7 @@ def get_friends_unique_watched(user_data): # host is a service users owns # return list_of_rec_movies -# Selenes psudo code below -# import copy - -# list_of_movies_not_seen_by_user = get_friends_unique_watched(user_data) -# # will this list^ have the host info in it? -# list_of_subscriptions_host_has = user_data["subscriptions"] -# list_of_movies_not_seen_but_on_users_subscriptions = [] -# loop through each movie in list_of_movies_not_seen_by_user: -# if movie[host] is in list_of_subscriptions_host_has: -# new_movie = copy.deepcopy(movie) -# list_of_movies_not_seen_on_users_subscriptions.append(new_movie) -# else: -# continue -# return list_of_movies_not_seen_on_users_subscriptions - -# working code below +# 1st function in Wave 4 def get_available_recs(user_data): unseen_by_user = get_friends_unique_watched(user_data) user_subscriptions = user_data["subscriptions"] @@ -331,7 +212,19 @@ def get_available_recs(user_data): return available_recs -# ----------------------------------------- # ------------- WAVE 5 -------------------- -# ----------------------------------------- + +# 2ND FUNCTION IN WAVE 5 +def get_rec_from_favorites(user_data): + user_favorites = user_data["favorites"] + recommended_movies = [] + + if user_data["friends"] == []: + return user_favorites + else: + unseen_by_friends = get_unique_watched(user_data) + for movie in unseen_by_friends: + if movie in user_favorites: + recommended_movies.append(movie) + return recommended_movies \ No newline at end of file From c57281a0aa3b0bbd8cd62ed80864e9063d6a652c Mon Sep 17 00:00:00 2001 From: Charlie Date: Thu, 30 Mar 2023 14:09:32 -0700 Subject: [PATCH 20/23] started 1st part of wave5 function, pulling for finished 2nd func --- viewing_party/party.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index b00622fac..4db34e75f 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -233,7 +233,7 @@ def get_friends_unique_watched(user_data): user_watched = set([movie["title"] for movie in user_data["watched"]]) friends_list = [] - print(user_watched) + #print(user_watched) for friend in user_data["friends"]: for movie in friend["watched"]: if movie["title"] not in user_watched and movie not in friends_list: @@ -330,8 +330,23 @@ def get_available_recs(user_data): available_recs.append(movie) return available_recs +#wave 5 +#function 1 -# ----------------------------------------- -# ------------- WAVE 5 -------------------- -# ----------------------------------------- +def get_new_rec_by_genre(user_data): + + #first find user's most watched genre + #from this genre find the movie that meets these requirments + #user has not watched + #1< views from friends + + user_most_watched_genre = "" + recommended_movies = [] + + if genre in + if genre in movie and movie listed more then once: + recommended_movies.append(movie) + + + return recommended_movies From 0b7c4f41a1228c9c8bc8897e5b7bad85e7cb420c Mon Sep 17 00:00:00 2001 From: Charlie Date: Thu, 30 Mar 2023 14:56:54 -0700 Subject: [PATCH 21/23] finished up all waves and cleaned up format --- viewing_party/party.py | 58 +++++++++++++----------------------------- 1 file changed, 18 insertions(+), 40 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index bd15c58dd..3add948f2 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -1,16 +1,5 @@ -# ------------- WAVE 1 -------------------- - -""" - first function create movie - function takes 3 paramaters/attributes, titles, genre, rating - if three attributers are truthy, return dictionary - if title falsy, genre is falsy or rating is falsy, these should return none - -""" # 1st function in Wave 1 def create_movie(title, genre, rating): - - #possible us of isinstance method if title is None or genre is None or rating is None: return None @@ -25,17 +14,14 @@ def create_movie(title, genre, rating): } else: return None -# COMMENTED LINE BELOW LOOKS LIKE IT CAN BE DELETED****************************** - # return new_movie + # 2nd function in Wave 1 def add_to_watched(user_data, movie): (user_data["watched"]).append(movie) return user_data -# TWO COMMENTED LINES BELOW LOOK LIKE THEY CAN BE DELETED****************************** - # if not movie: - # user_data["watched"].append(movie) + # 3rd function in Wave 1 def add_to_watchlist(user_data, movie): @@ -50,9 +36,11 @@ def add_to_watchlist(user_data, movie): # 4th function in Wave 1 def watch_movie(user_data, title): + move_movie = False index = 0 movie = None + for index in range(len(user_data["watchlist"])): if title == user_data["watchlist"][index]["title"]: move_movie = True @@ -64,19 +52,18 @@ def watch_movie(user_data, title): del user_data["watchlist"][movie_index] return user_data -# ------------- WAVE 2 -------------------- # 1st function in Wave 2 def get_watched_avg_rating(user_data): -# created a variable for the sum of all ratings, the # of movies and the average + movie_count = 0 ratings_sum = 0 ratings_avg = 0 -# check if there are movies in "watched" + if user_data["watched"]: -# loop through movies in watched + for index in range(len(user_data["watched"])): -# update variables + movie_count += 1 ratings_sum += user_data["watched"][index]["rating"] ratings_avg = ratings_sum/movie_count @@ -91,7 +78,6 @@ def get_most_watched_genre(user_data): if not most_watched_genre: return None - genres = {} for movie in most_watched_genre: genre = movie.get("genre") @@ -102,13 +88,12 @@ def get_most_watched_genre(user_data): most_watched_genre = max(genres, key=genres.get) - return most_watched_genre #most viewed genre + return most_watched_genre -# ------------- WAVE 3 -------------------- # 1st function in Wave 3 def get_unique_watched(user_data): -# code below is adaptation of funk 2 in wave 3, can be refactored + friends_watched_list = [] friends_watched_set = None friends_list = [] @@ -117,13 +102,14 @@ def get_unique_watched(user_data): for movie in friend["watched"]: friends_watched_list.append(movie["title"]) friends_watched_set = set(friends_watched_list) - # print(friends_watched_set) + for movie in user_data["watched"]: if movie["title"] not in friends_watched_set and movie not in friends_list: friends_list.append(movie) return friends_list + # 2nd function in Wave 3 def get_friends_unique_watched(user_data): @@ -137,30 +123,26 @@ def get_friends_unique_watched(user_data): return friends_list + # 1st function in Wave 4 def get_available_recs(user_data): + unseen_by_user = get_friends_unique_watched(user_data) user_subscriptions = user_data["subscriptions"] available_recs = [] + for movie in unseen_by_user: if movie["host"] in user_subscriptions: available_recs.append(movie) return available_recs -#wave 5 -#function 1 +#1st function Wave 5 def get_new_rec_by_genre(user_data): - #first find user's most watched genre - #from this genre find the movie that meets these requirments - #possible use of get friend unique - #user has not watched - #1< views from friends user_watched = set([movie["title"] for movie in user_data["watched"]]) friends_unique_watched = get_friends_unique_watched(user_data) - #most watched genre genre_count = {} for movie in user_data["watched"]: genre = movie["genre"] @@ -172,7 +154,6 @@ def get_new_rec_by_genre(user_data): best_genre = genre best_genre_count = count - #recommended movies with same genre recommended_movies = [] for movie in friends_unique_watched: if movie["title"] not in user_watched and movie["genre"] == best_genre: @@ -181,12 +162,9 @@ def get_new_rec_by_genre(user_data): return recommended_movies - - - - -# 2ND FUNCTION IN WAVE 5 +# 2ND function in Wave 5 def get_rec_from_favorites(user_data): + user_favorites = user_data["favorites"] recommended_movies = [] From a822aaa35a6dcc20549f17782f38355d544f1e01 Mon Sep 17 00:00:00 2001 From: Selene Castillo Date: Thu, 30 Mar 2023 15:35:36 -0700 Subject: [PATCH 22/23] completed wave 5 test update --- tests/test_wave_05.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_wave_05.py b/tests/test_wave_05.py index 34d06464b..eeab32419 100644 --- a/tests/test_wave_05.py +++ b/tests/test_wave_05.py @@ -52,8 +52,12 @@ def test_new_genre_rec_from_empty_friends(): } ] } + # Act + recommended_movies = get_new_rec_by_genre(sonyas_data) - raise Exception("Test needs to be completed.") + # Assert + assert len(recommended_movies) == 0 + # raise Exception("Test needs to be completed.") # ********************************************************************* # ****** Complete the Act and Assert Portions of these tests ********** # ********************************************************************* From a9e1dc89b0b782486d6eb5724385b9490366a238 Mon Sep 17 00:00:00 2001 From: Charlie Date: Thu, 30 Mar 2023 15:50:43 -0700 Subject: [PATCH 23/23] removed skips on tests and retested.all good --- tests/test_wave_03.py | 6 +++--- tests/test_wave_04.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_wave_03.py b/tests/test_wave_03.py index c54346fc2..105cb8174 100644 --- a/tests/test_wave_03.py +++ b/tests/test_wave_03.py @@ -3,7 +3,7 @@ from tests.test_constants import * -@pytest.mark.skip() +#@pytest.mark.skip() def test_my_unique_movies(): # Arrange amandas_data = clean_wave_3_data() @@ -17,7 +17,7 @@ def test_my_unique_movies(): assert INTRIGUE_2 in amandas_unique_movies assert amandas_data == clean_wave_3_data() -@pytest.mark.skip() +#@pytest.mark.skip() def test_my_not_unique_movies(): # Arrange @@ -66,7 +66,7 @@ def test_friends_unique_movies_not_duplicated(): # ****** Add assertions here to test that the correct movies are in friends_unique_movies ********** # ************************************************************************************************** -@pytest.mark.skip() +#@pytest.mark.skip() def test_friends_not_unique_movies(): # Arrange amandas_data = { diff --git a/tests/test_wave_04.py b/tests/test_wave_04.py index 499669077..79ab18ff7 100644 --- a/tests/test_wave_04.py +++ b/tests/test_wave_04.py @@ -2,7 +2,7 @@ from viewing_party.party import * from tests.test_constants import * -@pytest.mark.skip() +#@pytest.mark.skip() def test_get_available_friend_rec(): # Arrange amandas_data = clean_wave_4_data() @@ -16,7 +16,7 @@ def test_get_available_friend_rec(): assert FANTASY_4b in recommendations assert amandas_data == clean_wave_4_data() -@pytest.mark.skip() +#@pytest.mark.skip() def test_no_available_friend_recs(): # Arrange amandas_data = { @@ -38,7 +38,7 @@ def test_no_available_friend_recs(): # Assert assert len(recommendations) == 0 -@pytest.mark.skip() +#@pytest.mark.skip() def test_no_available_friend_recs_watched_all(): # Arrange amandas_data = {