Skip to content

Ocelots - Diana A.#20

Open
diarreola wants to merge 16 commits into
ada-ac2:masterfrom
diarreola:master
Open

Ocelots - Diana A.#20
diarreola wants to merge 16 commits into
ada-ac2:masterfrom
diarreola:master

Conversation

@diarreola

Copy link
Copy Markdown

No description provided.

Comment thread tests/test_constants.py
GENRE_1 = "Horror"
RATING_1 = 3.5

MOVIE_TITLE_2 = "Ratatouille"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Way to go, even adding additional testing data!

Comment thread tests/test_wave_01.py

# Assert
assert len(updated_data["watched"]) == 2
assert updated_data["watched"][1]["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.

Excellent thoroughness, testing all of the attributes here for completeness

Comment thread viewing_party/party.py

def create_movie(title, genre, rating):
pass
if not bool(title) or not bool(genre) or not bool(rating):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Interesting use of casting to bool to cover "" and None

Comment thread viewing_party/party.py


def watch_movie(user_data, title):
for movie in user_data["watchlist"]:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is working here, but an important note is that it is generally dangerous practice to modify a data structure that you are using to loop over. This can lead to bugs in more complex code. One alternative could be making a copy of what you get from " movie in user_data["watchlist"]:" so that that collection does not change while you modify user_data["watchlist]" from inside the loop.

Comment thread viewing_party/party.py

watched_genres = {}
for movie in user_data["watched"]:
watched_genres[movie["genre"]] = watched_genres.get(movie["genre"], 0) + 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.

Why was 1 added here?

Comment thread viewing_party/party.py
def get_unique_watched(user_data):
watched_movies_list = user_data["watched"]
friends_watched_movies_list = get_friends_watched_movies(user_data)
return [movie for movie in watched_movies_list if movie not in friends_watched_movies_list]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is a really clever single line! I would say that in general it's more useful for yourself or other developers to write out the steps, so that it's easier to understand-- and to debug and maintain in the future.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Also, now that we've had some more experience, can you think about how sets could have been used here, and in similar code in your project?

Comment thread viewing_party/party.py

def remove_movie_duplicates(friends_watched_movies_list):
friends_watched_movie_titles = {}
for movie in friends_watched_movies_list:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Similar comments about the dangers of modifying a collection while you are iterating over it

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