Skip to content

Ocelots - Dalia Ali#10

Open
dnabilali wants to merge 15 commits into
ada-ac2:masterfrom
dnabilali:master
Open

Ocelots - Dalia Ali#10
dnabilali wants to merge 15 commits into
ada-ac2:masterfrom
dnabilali:master

Conversation

@dnabilali
Copy link
Copy Markdown

completed viewing party assignment

@dnabilali dnabilali closed this Nov 9, 2022
@dnabilali dnabilali reopened this Nov 9, 2022
Copy link
Copy Markdown

@kelsey-steven-ada kelsey-steven-ada left a comment

Choose a reason for hiding this comment

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

🎉 Congrats on completing your first project at Ada! 🎉 I’ve added some suggestions & questions, let me know if there's anything I can clarify.

Comment thread tests/test_wave_01.py
# Assert
assert len(updated_data["watchlist"]) == 0
assert len(updated_data["watched"]) == 1
assert updated_data["watched"][0]["title"] == MOVIE_TITLE_1
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice assertion! In this case where the code is checking individual keys of a dictionary, I recommend including assertions for all of the relevant keys.

    watched_movie = updated_data["watched"][0]
    assert watched_movie["title”] == MOVIE_TITLE_1
    assert watched_movie["rating"] == RATING_1
    assert watched_movie["genre"] == GENRE_1

Comment thread tests/test_wave_01.py
# Assert
assert len(updated_data["watchlist"]) == 1
assert len(updated_data["watched"]) == 2
assert updated_data["watched"][1]["title"] == "It Came from the Stack Trace"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The README isn't explicit about what order we should add movies to the list watched. If we want our tests to be independent from a specific implementation that adds movies to a particular location in the watched list, we could use the in keyword to check if the variable movie_to_watch is in the watched list instead of looking at a specific index. By checking for the whole dictionary, there's a side benefit that we don't need to check each key independently:

assert movie_to_watch in updated_data["watched"]

# Another option:
assert HORROR_1 in updated_data["watched"]

Comment thread tests/test_wave_03.py
Comment on lines +57 to +59
assert INTRIGUE_3 in friends_unique_movies
assert HORROR_1 in friends_unique_movies
assert FANTASY_4 in friends_unique_movies
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great checks for all the relevant data!

Comment thread tests/test_wave_05.py
Comment on lines +57 to +60
recommendations = get_new_rec_by_genre(sonyas_data)

#Assert
assert len(recommendations) == 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great act & assert steps!

Comment thread viewing_party/party.py
def create_movie(title, genre, rating):
pass
def create_movie(movie_title, genre, rating):
movies = {}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I suggest moving the movies declaration under the invalid data check so that we don't allocate space for movies unless we know it will be used.

I would also suggest a singular name like movie for this variable. A plural name in programming generally implies that the variable holds a collection of several items. Since this variable holds the data for a single movie, a singular name would better represent what it holds.

Comment thread viewing_party/party.py
# -----------------------------------------
# ------------- WAVE 3 --------------------
# -----------------------------------------
def get_collective_friends_movies(user_data):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Really nice use of a helper function!

Comment thread viewing_party/party.py
return unique_movies


def get_friends_unique_watched(user_data):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice implementations for this wave! 😄

Comment thread viewing_party/party.py
# ------------- WAVE 4 --------------------
# -----------------------------------------
def get_available_recs(user_data):
friends_unique_movies = get_friends_unique_watched(user_data)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Love the code reuse!

Comment thread viewing_party/party.py
Comment on lines +115 to +117
for movie in friends_unique_movies:
if movie["host"] in user_data["subscriptions"]:
available_recommendations.append(movie)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice algorithm! Another way we could approach filtering the unique_watched list is with a list comprehension:

# list comprehension
result = [movie for movie in friends_unique_movies if movie["host"] in user_data["subscriptions"]]

This line is a bit long, in practice we would split a statement like this across lines, use some extra variables, or shorten some naming to keep under the PEP8 guide of 79 characters max per line:

# list comprehension
result = [movie for movie in friends_unique_movies 
         if movie["host"] in user_data["subscriptions"]]

Comment thread viewing_party/party.py
Comment on lines +137 to +144
friends_movies_list = get_collective_friends_movies(user_data)
recommendations = []

for movie in user_data["favorites"]:
if movie not in friends_movies_list:
recommendations.append(movie)

return recommendations
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I like this approach and that it uses your previous helper function! Another approach could use the result of get_unique_watched:

unique_movies = get_unique_watched(user_data)

recommendations = []
for movie in unique_movies:
    if movie in user_data['favorites']:
        recommendations.append(movie)

return recommendations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants