From 849c89327316c4a957842bf864bbbb1d6aa1639b Mon Sep 17 00:00:00 2001 From: tiffany Date: Mon, 26 Sep 2022 21:45:31 -0400 Subject: [PATCH 1/2] wave 1 and 2 --- README.md | 3 +++ play_tester.py | 12 ++++----- tests/test_wave_01.py | 28 +++++++++++-------- tests/test_wave_02.py | 8 +++--- tests/test_wave_03.py | 2 +- viewing_party/party.py | 61 +++++++++++++++++++++++++++++++++++++++--- 6 files changed, 88 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 187cdb442..bd087f03d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # Viewing Party + +## Command to start Virtual Enviornment +source ven/bin/activate ## Skills Assessed Solving problems with... diff --git a/play_tester.py b/play_tester.py index 9e2aecf48..ca9614de1 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_01.py b/tests/test_wave_01.py index 6be6994a5..1de776eaf 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() 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() 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() 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() 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() 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() def test_adds_movie_to_user_watchlist(): # Arrange movie = { @@ -100,7 +100,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() def test_moves_movie_from_watchlist_to_empty_watched(): # Arrange janes_data = { @@ -119,12 +119,15 @@ 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.") + assert updated_data["watched"][0]["title"] == MOVIE_TITLE_1 + assert updated_data["watched"][0]["genre"] == GENRE_1 + assert updated_data["watched"][0]["rating"] == RATING_1 + # ******************************************************************************************* # ****** Add assertions here to test that the correct movie was added to "watched" ********** # ******************************************************************************************* -@pytest.mark.skip() +# @pytest.mark.skip() def test_moves_movie_from_watchlist_to_watched(): # Arrange movie_to_watch = HORROR_1 @@ -143,12 +146,15 @@ 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.") + assert updated_data["watched"][1]["title"] == MOVIE_TITLE_1 + assert updated_data["watched"][1]["genre"] == GENRE_1 + assert updated_data["watched"][1]["rating"] == RATING_1 + # ******************************************************************************************* # ****** Add assertions here to test that the correct movie was added to "watched" ********** # ******************************************************************************************* -@pytest.mark.skip() +# @pytest.mark.skip() def test_does_nothing_if_movie_not_in_watchlist(): # Arrange movie_to_watch = HORROR_1 diff --git a/tests/test_wave_02.py b/tests/test_wave_02.py index 3a588299e..198e395b3 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 = { @@ -27,7 +27,7 @@ def test_empty_watched_average_rating_is_zero(): # Assert assert average == pytest.approx(0.0) -@pytest.mark.skip() +# @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() +# @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 046429360..1d7d3f654 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() +# @pytest.mark.skip() def test_my_unique_movies(): # Arrange amandas_data = clean_wave_3_data() diff --git a/viewing_party/party.py b/viewing_party/party.py index 6d34a6b5f..94681dad3 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -1,16 +1,70 @@ # ------------- WAVE 1 -------------------- +import statistics +from statistics import mode def create_movie(title, genre, rating): - pass + movies = { + 'title':title, + 'genre':genre, + 'rating':rating, + } + if not title or not genre or not rating: + return None + else: + return movies + + +def add_to_watched(user_data, movie): + user_data["watched"].append(movie) + + return user_data + + +def add_to_watchlist(user_data,movie): + user_data["watchlist"].append(movie) + + return user_data + + +def watch_movie(user_data, title): + movie_to_watch = user_data["watchlist"] + for movie in movie_to_watch: + if title == movie["title"]: + user_data["watched"].append(movie) + user_data["watchlist"].remove(movie) + return user_data # ----------------------------------------- # ------------- WAVE 2 -------------------- # ----------------------------------------- +def get_watched_avg_rating(user_data): + sum = 0 + for i in range (len(user_data['watched'])): + movie = user_data['watched'][i] + movie_r = movie['rating'] + sum += movie_r + if (len(user_data['watched'])) == 0: + return 0.0 + else: + return sum / len(user_data['watched']) -# ----------------------------------------- +def get_most_watched_genre(user_data): + movie_g_list = [] + for i in range (len(user_data['watched'])): + movie = user_data['watched'][i] + movie_g = movie['genre'] + movie_g_list.append(movie_g) + if user_data['watched'] == []: + return None + else: + return(mode(movie_g_list)) + + # ----------------------------------------- # ------------- WAVE 3 -------------------- # ----------------------------------------- +# def get_unique_watched(user_data): + # ----------------------------------------- @@ -19,5 +73,4 @@ def create_movie(title, genre, rating): # ----------------------------------------- # ------------- WAVE 5 -------------------- -# ----------------------------------------- - +# ----------------------------------------- \ No newline at end of file From e9e8e9ee3a0eb7f378934837f5e75de026732fc8 Mon Sep 17 00:00:00 2001 From: tiffany Date: Thu, 29 Sep 2022 15:18:42 -0400 Subject: [PATCH 2/2] 1,2,3 --- tests/test_wave_03.py | 12 +++++++----- viewing_party/party.py | 39 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/tests/test_wave_03.py b/tests/test_wave_03.py index 1d7d3f654..54c18b678 100644 --- a/tests/test_wave_03.py +++ b/tests/test_wave_03.py @@ -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() +# @pytest.mark.skip() def test_my_not_unique_movies(): # Arrange amandas_data = clean_wave_3_data() @@ -28,7 +28,7 @@ def test_my_not_unique_movies(): # Assert assert len(amandas_unique_movies) == 0 -@pytest.mark.skip() +# @pytest.mark.skip() def test_friends_unique_movies(): # Arrange amandas_data = clean_wave_3_data() @@ -43,7 +43,7 @@ def test_friends_unique_movies(): assert FANTASY_4 in friends_unique_movies assert amandas_data == clean_wave_3_data() -@pytest.mark.skip() +# @pytest.mark.skip() def test_friends_unique_movies_not_duplicated(): # Arrange amandas_data = clean_wave_3_data() @@ -55,12 +55,14 @@ def test_friends_unique_movies_not_duplicated(): # Assert assert len(friends_unique_movies) == 3 - raise Exception("Test needs to be completed.") + assert INTRIGUE_3 in friends_unique_movies + assert HORROR_1 in friends_unique_movies + assert FANTASY_4 in friends_unique_movies # ************************************************************************************************* # ****** 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/viewing_party/party.py b/viewing_party/party.py index 94681dad3..19f9bc0eb 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -2,6 +2,7 @@ import statistics from statistics import mode + def create_movie(title, genre, rating): movies = { 'title':title, @@ -63,7 +64,43 @@ def get_most_watched_genre(user_data): # ----------------------------------------- # ------------- WAVE 3 -------------------- # ----------------------------------------- -# def get_unique_watched(user_data): +def get_unique_watched(user_data): + friends = user_data['friends'] + friends_mediocre_movies = [] + my_watched = user_data['watched'] + cool_movies_watched = [] + unique_movies = [] + for my_movies in my_watched: + cool_movies_watched.append(my_movies) + + for friends_watched in friends: + for friends_movies in friends_watched['watched']: + friends_mediocre_movies.append(friends_movies) + + for movie in cool_movies_watched: + if not movie in friends_mediocre_movies and movie not in unique_movies: + unique_movies.append(movie) + return unique_movies + + +def get_friends_unique_watched(user_data): + friends = user_data['friends'] + friends_mediocre_movies = [] + my_watched = user_data['watched'] + cool_movies_watched = [] + unique_movies = [] + for my_movies in my_watched: + cool_movies_watched.append(my_movies) + + for friends_watched in friends: + for friends_movies in friends_watched['watched']: + friends_mediocre_movies.append(friends_movies) + + for movie in friends_mediocre_movies: + if not movie in cool_movies_watched and movie not in unique_movies: + unique_movies.append(movie) + return unique_movies +