Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 26 additions & 11 deletions tests/test_wave_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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 = {
Expand All @@ -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 = {
Expand All @@ -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 = {
Expand All @@ -119,15 +119,22 @@ 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
Comment on lines +122 to +124

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonderful assertion statements! ✨

# *******************************************************************************************
# ****** 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
# assign a HORR0R_1 to movie_to_watch
movie_to_watch = HORROR_1
# janes_data is a dictionary that has two key values
# watchlist
# watched
# They each have a list as the value of the keys
janes_data = {
"watchlist": [
FANTASY_1,
Expand All @@ -143,25 +150,33 @@ 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] == movie_to_watch

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 👍🏻

# *******************************************************************************************
# ****** 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
# The variable movie_to_watch is assigned to HORROR_1
movie_to_watch = HORROR_1
# the dictionary about janes_data that has two keys
# "watchlist" and "watched"
janes_data = {
"watchlist": [FANTASY_1],
"watched": [FANTASY_2]
}

# Act
# name of the person janes_data and the name of the movie "Non-Existent Movie Title")
updated_data = watch_movie(janes_data, "Non-Existent Movie Title")

# Assert
assert len(updated_data["watchlist"]) == 1
assert len(updated_data["watched"]) == 1

# Is this checking for none of the varaibles are iny the updated dictionary
# checks if movie_to_watch variable is not in updated_data["watchlist"]
assert movie_to_watch not in updated_data["watchlist"]
# checks if movie_to_watch variable is not in updated_data["watched"]
assert movie_to_watch not in updated_data["watched"]
8 changes: 4 additions & 4 deletions tests/test_wave_02.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 = {
Expand All @@ -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()
Expand All @@ -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 = {
Expand Down
18 changes: 9 additions & 9 deletions tests/test_wave_03.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -43,24 +43,24 @@ 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()
# amandas_data in dictionary "friends" in first friend added a movie to watched list
amandas_data["friends"][0]["watched"].append(INTRIGUE_3)

# Act
friends_unique_movies = get_friends_unique_watched(amandas_data)

# Assert
assert len(friends_unique_movies) == 3
assert INTRIGUE_3 in friends_unique_movies
assert HORROR_1 in friends_unique_movies
assert FANTASY_4 in friends_unique_movies
Comment on lines +58 to +60

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonderful! 💯


raise Exception("Test needs to be completed.")
# *************************************************************************************************
# ****** 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 = {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_wave_04.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
125 changes: 123 additions & 2 deletions viewing_party/party.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,144 @@
# ------------- WAVE 1 --------------------

from distutils.file_util import move_file
from pickle import FALSE

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to clear any import statements that we don't need before submission! 😉



def create_movie(title, genre, rating):
pass
new_movie = {}
if title == None or genre == None or rating == None:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great chained logic in this conditional!

return None
else:
new_movie["title"] = title
new_movie["genre"] = genre
new_movie["rating"] = rating

return new_movie

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):

if user_data["watchlist"] == None:
return user_data
else:
movie_to_move = None
# dict_movie name of each dictionary in "watchlist"
for dict_movie in user_data["watchlist"]:
# if the tittle in that dictionary evaluate to the same then do the following
if title == dict_movie["title"]:
# create a new varaible it becomes none when user_data["watchlist"] is removed
movie_to_move = dict_movie
# need to add this to a diffrent dictionary
# error here because condition needs to be true
if movie_to_move:
user_data["watched"].append(movie_to_move)
user_data["watchlist"].remove(movie_to_move)
Comment on lines +31 to +42

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job working through this bit of logic and manipulating user_data outside the iteration loop! 🥇

return user_data

# -----------------------------------------
# ------------- WAVE 2 --------------------
# -----------------------------------------

def get_watched_avg_rating(user_data):

all_ratings_added = 0
if user_data["watched"] == []:
return 0
for movie in user_data["watched"]:
rating = 0
rating = movie["rating"]
all_ratings_added += rating
Comment on lines +55 to +57

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be shortened to all_ratings_added += movie["rating"]


average_rating = all_ratings_added/len(user_data["watched"])
return average_rating
Comment on lines +59 to +60

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job combining division with the length calculation!


def get_most_watched_genre(user_data):
genres_map = {}
for movie in user_data["watched"]:
if movie["genre"] not in genres_map:
genres_map[movie["genre"]] = 1
else:
genres_map[movie["genre"]] += 1

maximum_key = None
maximum_value = 0
Comment on lines +70 to +71

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, could we have more descriptive variable names? Maybe best_genre_name and best_genre_count?

for genre, quanity in genres_map.items():
if quanity > maximum_value:
maximum_value = quanity
maximum_key = genre
return maximum_key


# -----------------------------------------
# ------------- WAVE 3 --------------------
# -----------------------------------------


def get_unique_watched(user_data):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nit/preference: I like to initialize all my known variables right after defining the function so I can keep track of them easier! For example, I (personally, meaning you don't have to do this!) would put L88 and L93 right after each other around L88.

# # compare movies of friends with user
# # create a list of dictionaries of the movies that have not been seen by the friends
# # return the list of dictionaries that friends have not watched

friends_movies = []
for friend in user_data["friends"]:
for movie in friend["watched"]:
friends_movies.append(movie["title"])

movie_list = []
for movie in user_data["watched"]:
if movie["title"] not in friends_movies:
movie_list.append(movie)

return movie_list

def get_friends_unique_watched(user_data):
movie_list = []
for movie in user_data["watched"]:
movie_list.append(movie["title"])
Comment on lines +101 to +103

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can get rid of this and refer to user_data["watched"] directly in L108.


friends_movies = []
for friend in user_data["friends"]:
for movie in friend["watched"]:
if movie["title"] not in movie_list:
if movie not in friends_movies:
friends_movies.append(movie)
return friends_movies
# -----------------------------------------
# ------------- WAVE 4 --------------------
# -----------------------------------------

def get_available_recs(user_data):
# user has access to
# iterate over subscriptions access a string
movie_list = []
for movie in user_data["watched"]:
movie_list.append(movie["title"])

for subscription in user_data["subscriptions"]:
pass
# each friend has watched list

friends_movies = []
for friend in user_data["friends"]:
for movie in friend["watched"]:
for host in movie["host"]:
if movie["title"] not in movie_list:
if movie not in friends_movies:
if host in movie_list:
friends_movies.append(movie)

Comment on lines +128 to +135

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀 OOOO, interested in where you might be going here! Let me know if you want to walk through this Wave in our 1:1s!


# -----------------------------------------
# ------------- WAVE 5 --------------------
# -----------------------------------------