-
Notifications
You must be signed in to change notification settings - Fork 81
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
Ruby - Jasmine S. and Thea V #51
base: main
Are you sure you want to change the base?
Conversation
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! There are some comments below on places to make the code cleaner/simpler. Great job on making commits often!
assert updated_data["watched"][0] == { | ||
"title": MOVIE_TITLE_1, | ||
"genre": GENRE_1, | ||
"rating": RATING_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 assert does the same thing as the three below. There's no need to check each individual key if you've already checked all of them!
# ******************************************************************************************* | ||
# ****** Add assertions here to test that the correct movie was added to "watched" ********** | ||
# ******************************************************************************************* | ||
assert updated_data["watched"][1] == movie_to_watch |
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!
@@ -54,13 +58,10 @@ def test_friends_unique_movies_not_duplicated(): | |||
|
|||
# Assert | |||
assert len(friends_unique_movies) == 3 | |||
assert friends_unique_movies == [FANTASY_4, HORROR_1, INTRIGUE_3] |
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.
Be careful using ==
for asserts on lists. If, for some reason, the movies end up in a different order, this test would fail even if all of the elements are the same. ==
requires that the ordering of the elements be the same as well. Instead, consider statements like assert FANTASY_4 in friends_unique_movies
. That way it doesn't matter what order the list is in, as long as those movies are in the list somewhere.
@@ -86,4 +87,4 @@ def test_friends_not_unique_movies(): | |||
friends_unique_movies = get_friends_unique_watched(amandas_data) | |||
|
|||
# Assert | |||
assert len(friends_unique_movies) == 0 | |||
assert len(friends_unique_movies) == 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.
Excellent!
result_recommendation = get_new_rec_by_genre(sonyas_data) | ||
|
||
@pytest.mark.skip() | ||
# Assert | ||
assert len(result_recommendation) == 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.
Excellent!
if movie in unique_watched: | ||
unique_watched.remove(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.
It is more efficient to start with an empty list that we add to instead of having a full list that we remove from. The .remove()
function is O(n) time. That makes this if statement O(n^2) time since the in
function is also O(n). Overall, this for loop is O(m * n^2) time, where m is the length of all of the friends movies and n is the length of the user's movies.
return unique_watched | ||
|
||
|
||
def get_friends_unique_watched(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!
|
||
# ----------------------------------------- | ||
def get_available_recs(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!
|
||
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!
return final_recs | ||
|
||
|
||
def get_rec_from_favorites(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!
No description provided.