-
Notifications
You must be signed in to change notification settings - Fork 29
Phoenix - Lula San #13
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
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.
I've added comments about the implementation as submitted. Please review them, and let me know if you have any questions. There are a few things I'd like you to revisit before we move on from this project. My Slack communication has more detail about exactly what to focus on.
raise Exception("Test needs to be completed.") | ||
#raise Exception("Test needs to be completed.") | ||
# ******************************************************************************************* | ||
# ****** Add assertions here to test that the correct movie was added to "watched" ********** | ||
# ******************************************************************************************* |
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.
👀 The tests with these sorts of instructions are asking you to add your own code to complete what this test is trying to validate. The raise Exception("Test needs to be completed.")
statement did need to be commented out or removed (it was just there to draw your attention), but we're also looking for additional assertions. What needs to be checked to confirm that the data moved from the watchlist to the watched list was moved correctly?
raise Exception("Test needs to be completed.") | ||
# raise Exception("Test needs to be completed.") | ||
# ******************************************************************************************* | ||
# ****** Add assertions here to test that the correct movie was added to "watched" ********** | ||
# ******************************************************************************************* |
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.
👀 The tests with these sorts of instructions are asking you to add your own code to complete what this test is trying to validate. The raise Exception("Test needs to be completed.")
statement did need to be commented out or removed (it was just there to draw your attention), but we're also looking for additional assertions. What needs to be checked to confirm that the data moved from the watchlist to the watched list was moved correctly? How can we be sure the correct data was left in the watchlist?
raise Exception("Test needs to be completed.") | ||
# raise Exception("Test needs to be completed.") | ||
# ************************************************************************************************* | ||
# ****** Add assertions here to test that the correct movies are 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.
👀 The tests with these sorts of instructions are asking you to add your own code to complete what this test is trying to validate. The raise Exception("Test needs to be completed.")
statement did need to be commented out or removed (it was just there to draw your attention), but we're also looking for additional assertions. What needs to be checked to confirm that the expected 3 movies were returned?
tests/test_wave_05.py
Outdated
raise Exception("Test needs to be completed.") | ||
#raise Exception("Test needs to be completed.") | ||
# ********************************************************************* | ||
# ****** Complete the Act and Assert Portions of these tests ********** | ||
# ********************************************************************* |
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.
👀 The tests with these sorts of instructions are asking you to add your own code to complete what this test is trying to validate. The raise Exception("Test needs to be completed.")
statement did need to be commented out or removed (it was just there to draw your attention), but we're also looking for additional assertions. This test only provides the arrange part, and the name of the test tells us what it should be checking. What action do we need to generate a genre-based recommendation? And what do we expect the result to be when the friends haven't watched anything?
viewing_party/party.py
Outdated
@@ -1,23 +1,155 @@ | |||
# ------------- WAVE 1 -------------------- | |||
from tests.test_constants import * |
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.
👀 The "real" code of our project should not depend on code/constants from the tests. Imagine in a real scenario, we don't ship the tests to customers (for example, we don't have the tests that Google uses for Chrome on our system. We only have the main code. As a result, test code can (in fact, must) depend on the real code (it's the code that's being tested after all), but real code must never depend on test code.
viewing_party/party.py
Outdated
all_friends_movies = get_all_friends_movies(user_data) | ||
|
||
for movie in all_friends_movies: | ||
if movie["host"] in user_data["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.
A small optimization could be creating a set holding the user subscriptions, then checking whether the host is in the set values.
viewing_party/party.py
Outdated
for movie in user_data["watched"]: | ||
if movie in recommended_movie_list: | ||
recommended_movie_list.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.
Notice that this whole step of filtering out the movies watched by the user is something we did earlier in get_friends_unique_watched
. Can we reuse that function to help here?
|
||
# ----------------------------------------- | ||
# ------------- WAVE 5 -------------------- | ||
# ----------------------------------------- | ||
|
||
def get_new_rec_by_genre(user_data): | ||
favorite_genre = get_most_watched_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.
👍 Great reuse of this function. We don't want to duplicate this logic again here!
viewing_party/party.py
Outdated
for movie in user_data["watched"]: | ||
if movie in recommended_genre: | ||
recommended_genre.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.
Could we avoid needing to do this removal if we started with a list of movies the friends watched, but the user hadn't? Can we use a previous wave function to help with this?
viewing_party/party.py
Outdated
for movie in user_data["favorites"]: | ||
if movie not in all_friends_movies: | ||
recommended_movies.append(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.
What if we started with a list of movies the user watched, but the friends hadn't? Can we use a previous wave function to help with this? Could that result be filtered against the movies in the favorite list? If so, consider using a set of favorite movie titles to filter the user movies efficiently. Notice that since we already have other functions that are making new data, this may more clearly help us favor an approach using a set or dict for efficient lookups, even though it would required additional memory. But once we've used some, what's a little more? 😁
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.
Thanks for updating your submission. There are still a few points about the tests to consider, but overall this looks good!
@@ -158,13 +158,14 @@ def test_moves_movie_from_watchlist_to_empty_watched(): | |||
# Assert | |||
assert len(updated_data["watchlist"]) == 0 | |||
assert len(updated_data["watched"]) == 1 | |||
assert MOVIE_TITLE_1 in updated_data["watched"][0].values() |
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.
Rather than checking against all values, we'd still want to compare against the value stored under the "title"
key
assert MOVIE_TITLE_1 == updated_data["watched"][0]["title"]
But really, we'd want to ensure that all the data is there as expected. To do so , we can make our own dictionary to compare with
assert updated_data["watched"][0] == {
"title": MOVIE_TITLE_1,
"genre": GENRE_1,
"rating": RATING_1
}
And though we know there's only a single movie in the list this time, since the specification doesn't require that movies be moved to a particular location in the watched list, we could use an in
check so the location doesn't matter.
expected_movie = {
"title": MOVIE_TITLE_1,
"genre": GENRE_1,
"rating": RATING_1
}
assert expected_movie in updated_data["watched"]
@@ -182,13 +183,14 @@ def test_moves_movie_from_watchlist_to_watched(): | |||
# Assert | |||
assert len(updated_data["watchlist"]) == 1 | |||
assert len(updated_data["watched"]) == 2 | |||
assert movie_to_watch in updated_data["watched"] |
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.
👍 Here, it would also be a good idea to check that the movie we didn't expect to move is still in the watchlist, and the other movie that was already in the watched list is still there.
@@ -54,13 +54,14 @@ def test_friends_unique_movies_not_duplicated(): | |||
|
|||
# Assert | |||
assert len(friends_unique_movies) == 3 | |||
assert INTRIGUE_3 in amandas_data["friends"][0]["watched"] |
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.
👍 Here, we should also ensure that the other two movies that we'd expect to have reported are also there. Essnetially, the same checks that were done for the previous test (test_friends_unique_movies
) would apply here as well.
assert not recommendations | ||
assert len(sonyas_data["watched"]) == 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.
👍 Here, the function is specified as returning a list. Though in regular code, we would tend to write if not my_list:
to check for an empty list, we can be more strict here to enforce the function requirements by literally comparing to []
.
assert recommendations == []
Further, we don't expect the get_new_rec_by_genre
function to modify the data structure (in any case), so we don't need to check that the watched list is unchanged.
movie_dict["title"] = title | ||
movie_dict["genre"] = genre | ||
movie_dict["rating"] = 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.
👍 Yep, this is what we were looking for.
No description provided.