-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Franklyn Rod. Snow Leopards #145
base: master
Are you sure you want to change the base?
Conversation
@@ -118,13 +118,14 @@ def test_moves_movie_from_watchlist_to_empty_watched(): | |||
# Assert | |||
assert len(updated_data["watchlist"]) == 0 | |||
assert len(updated_data["watched"]) == 1 | |||
assert updated_data["watched"][0]["title"] == MOVIE_TITLE_1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job here! We could also test for the other key/values in the dictionary:
assert updated_data["watched"][0]["rating"] == RATING_1
assert updated_data["watched"][0]["genre"] == GENRE_1
@@ -142,13 +143,15 @@ def test_moves_movie_from_watchlist_to_watched(): | |||
# Assert | |||
assert len(updated_data["watchlist"]) == 1 | |||
assert len(updated_data["watched"]) == 2 | |||
assert updated_data["watched"][1]["title"] == MOVIE_TITLE_1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works well but you can also test to see if the movie is in the watched list as well as some other assertions to ensure no unwanted list modifications have occurred:
assert movie_to_watch in updated_data["watched"]
assert FANTASY_2 in updated_data["watched"]
assert FANTASY_1 in updated_data["watchlist"]
assert movie_to_watch not in updated_data["watchlist"]
|
||
raise Exception("Test needs to be completed.") | ||
assert HORROR_1 in friends_unique_movies | ||
assert FANTASY_4 in friends_unique_movies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job here! You could also add the assertion to check for the 3rd movie as well.
|
||
raise Exception("Test needs to be completed.") | ||
# Assert | ||
assert rec_from_empty_friends == [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done 👍
def create_movie(title, genre, rating): | ||
pass | ||
if not title or not genre or not rating: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent use of the guard clause pattern! Early return here means no unnecessary code execution!
new_dict["title"] = title | ||
new_dict["genre"] = genre | ||
new_dict["rating"] = rating | ||
# if not new_dict["key"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's generally not a great practice to leave commented out code in Pull Requests. Also, you can return a dictionary literal like so, rather than creating an empty dict and adding key/values one by one:
return {
"title": title,
"rating": rating,
"genre": genre
}
for movie in user_data["watchlist"]: | ||
if movie["title"] == title: | ||
user_data["watched"].append(movie) | ||
i = user_data["watchlist"].index(movie) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works just fine, but we can use remove with the item since we know the item exists (since we're iterating over them directly). If we're worried about modifying the list we're iterating over, it's fine to add a break
like so:
...
user_data["watchlist"].remove(movie)
break
|
||
rating_list=[] | ||
for movie in user_data["watched"]: | ||
if movie["rating"]> 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job not calculating zero ratings. I was initially concerned that they might have been not accounted for in the average, but you took care of it using len
!
for genre in frequent_genre_counter: | ||
if frequent_genre_counter[genre]== max_genre: | ||
return genre | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job with this function! One word about using max
. When pulling in code from beyond what we've talked about, it's great if you could include a comment about the research that you did, and how you think it works. And it's still worth implementing similar functionality a few times yourself, as it can help practice building our fundamental skills. For now, our goal should be getting as much coding practice as possible!
for movies in user_data["watched"]: | ||
if movies not in same_movies: | ||
my_movies.append(movies) | ||
return my_movies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job with this function! I'd echo my concern above that submitting a PR with extraneous comments and commented out code is challenging for the reader.
for movie in friend["watched"]: | ||
if movie not in user_data["watched"] and movie not in friend_movies: | ||
friend_movies.append(movie) | ||
print(f"MOVIE{movie}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work on this function! I see this print
statement was left in, which is usually, though not always, an unintentional debug statement. It's not a great idea to let reviewers find these, so good to get in the habit of reading your submitted PR to make sure it doesn't contain unwanted debug print statements. Totally fine once in a while, but good to be aware of.
friends_watched = get_friends_unique_watched(user_data) | ||
rec_movie_list=[] | ||
for friend in friends_watched: | ||
if friend["host"] in user_data.get("subscriptions"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job using the dictionary get
method!
def get_rec_from_favorites(user_data): | ||
my_watched=get_unique_watched(user_data) | ||
my_faves=user_data.get("favorites") | ||
intersection=[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
intersection
is a bit generic of a name, something like recs
is more descriptive, which is generally a better strategy for naming variables.
# ------------- WAVE 5 -------------------- | ||
# ----------------------------------------- | ||
def get_new_rec_by_genre(user_data): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent job with the Wave 5 functions!
Great job on your first Unit project, Franklyn! 🟢 for Viewing Party! |
No description provided.