Skip to content

Phoenix - Lula San#13

Open
machilula wants to merge 26 commits intoAda-C22:mainfrom
machilula:main
Open

Phoenix - Lula San#13
machilula wants to merge 26 commits intoAda-C22:mainfrom
machilula:main

Conversation

@machilula
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@anselrognlie anselrognlie left a 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.

Comment thread tests/test_wave_01.py
Comment on lines 162 to 165

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" **********
# *******************************************************************************************
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 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?

Comment thread tests/test_wave_01.py
Comment on lines 186 to 189

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" **********
# *******************************************************************************************
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 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?

Comment thread tests/test_wave_03.py
Comment on lines 58 to 61

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 **********
# **************************************************************************************************
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 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?

Comment thread tests/test_wave_05.py
Comment on lines 56 to 59

raise Exception("Test needs to be completed.")
#raise Exception("Test needs to be completed.")
# *********************************************************************
# ****** Complete the Act and Assert Portions of these tests **********
# *********************************************************************
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 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?

Comment thread viewing_party/party.py Outdated
@@ -1,23 +1,155 @@
# ------------- WAVE 1 --------------------
from tests.test_constants import *
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 "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.

Comment thread 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"]:
Copy link
Copy Markdown

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.

Comment thread viewing_party/party.py Outdated
Comment on lines +122 to +124
for movie in user_data["watched"]:
if movie in recommended_movie_list:
recommended_movie_list.remove(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.

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?

Comment thread viewing_party/party.py
# -----------------------------------------

def get_new_rec_by_genre(user_data):
favorite_genre = get_most_watched_genre(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.

👍 Great reuse of this function. We don't want to duplicate this logic again here!

Comment thread viewing_party/party.py Outdated
Comment on lines +140 to +142
for movie in user_data["watched"]:
if movie in recommended_genre:
recommended_genre.remove(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.

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?

Comment thread viewing_party/party.py Outdated
Comment on lines +149 to +151
for movie in user_data["favorites"]:
if movie not in all_friends_movies:
recommended_movies.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.

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? 😁

Copy link
Copy Markdown

@anselrognlie anselrognlie left a 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!

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

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"]

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

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.

Comment thread tests/test_wave_03.py

# Assert
assert len(friends_unique_movies) == 3
assert INTRIGUE_3 in amandas_data["friends"][0]["watched"]
Copy link
Copy Markdown

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.

Comment thread tests/test_wave_05.py
Comment on lines +58 to +59
assert not recommendations
assert len(sonyas_data["watched"]) == 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.

👍 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.

Comment thread viewing_party/party.py
Comment on lines +8 to +10
movie_dict["title"] = title
movie_dict["genre"] = genre
movie_dict["rating"] = 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.

👍 Yep, this is what we were looking for.

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.

3 participants