Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Viewing Party
# Viewing Party - Maria

## Skills Assessed

Expand Down Expand Up @@ -28,11 +28,11 @@ Follow these directions once, a the beginning of your project:
$ cd ~/Developer/projects
```

2. In Github click on the "Fork" button in github and fork the repository to your Github account. This will make a copy of the project in your github account.
2. In Github click on the "Fork" button in github and fork the repository to your Github account. This will make a copy of the project in your github account.

![Fork Button](images/fork.png)

3. "Clone" (download a copy of this project) into your projects folder. This command makes a new folder called `viewing-party`, and then puts the project into this new folder. Make sure you are cloning from your copy of the project and not the class version (ada-cX).
3. "Clone" (download a copy of this project) into your projects folder. This command makes a new folder called `viewing-party`, and then puts the project into this new folder. Make sure you are cloning from your copy of the project and not the class version (ada-cX).

```bash
$ git clone ...
Expand Down Expand Up @@ -92,22 +92,23 @@ $ source venv/bin/activate
2. Check the `tests` folder, and find the test file you want to run

- In that test file, read through each test case
- If it is incomplete, complete the test.
- *Is this a nominal or edge case?*
- *What type of input do we need to test this case?*
- *What is the expected output for the given input?*
- If it is incomplete, complete the test.
- _Is this a nominal or edge case?_
- _What type of input do we need to test this case?_
- _What is the expected output for the given input?_
- Remove the lines that contain `@pytest.mark.skip()` for the test(s) you want to run.

3. Run the test(s)!
- *See the [Details About How to Run Tests](#details-about-how-to-run-tests) section below for more information on how to run test(s).*
- _See the [Details About How to Run Tests](#details-about-how-to-run-tests) section below for more information on how to run test(s)._

```bash
# Must be in activated virtual environment in the project-root directory
$ pytest
```

4. Read through the test failure, and understand why the failure is happening. Confirm your findings with a classmate.
- If it is a test you wrote, consider whether you are actually testing what you intend to test. Does the test need modification?
4. Read through the test failure, and understand why the failure is happening. Confirm your findings with a classmate.

- If it is a test you wrote, consider whether you are actually testing what you intend to test. Does the test need modification?

5. Make a plan to implement code to pass the test.

Expand All @@ -122,8 +123,9 @@ $ pytest
10. Consider looking for opportunities to improve your code.

11. Before moving to the next wave, make sure you haven't missed any skipped tests.
- *Search the file (**Cmd** **F**) for `@pytest.mark.skip`*
- *To search all files in the project, use **Cmd** **Shift** **F***

- _Search the file (**Cmd** **F**) for `@pytest.mark.skip`_
- \*To search all files in the project, use **Cmd** **Shift** **F\***

12. Begin using the test file of the next wave!

Expand All @@ -135,8 +137,6 @@ $ deactivate

Finally, at submission time, **no matter where you are**, submit the project via Learn.



This will let us give feedback on what you've finished so that you can be better prepared for the next project.

## Details About How to Run Tests
Expand Down Expand Up @@ -186,13 +186,13 @@ To run this file, use:
python3 play_tester.py
```

There is some starter code provided in `play_tester.py`. This code prints the test data that is used for many of the tests. Looking closely at this data can help us think critically about the expected output for given input for each function. Then, calling each function with this data allows us to observe the **actual** output for given input.
There is some starter code provided in `play_tester.py`. This code prints the test data that is used for many of the tests. Looking closely at this data can help us think critically about the expected output for given input for each function. Then, calling each function with this data allows us to observe the **actual** output for given input.

## Test Data

We will note that much of the test data for this project is provided by the file `test_constants.py`. As test data gets more and more complex, it is helpful to organize this data in its own file to enhance consistency and readability. Pytest, like many testing libraries, provide a special too for test data called **fixtures**. We will learn about fixtures later in the curriculum.
We will note that much of the test data for this project is provided by the file `test_constants.py`. As test data gets more and more complex, it is helpful to organize this data in its own file to enhance consistency and readability. Pytest, like many testing libraries, provide a special too for test data called **fixtures**. We will learn about fixtures later in the curriculum.

For the time being, we need to make sure that the data provided to each test is clean and free of any changes that running another test may have introduced. Recall the *Modifying Mutable Objects* section of the *Variables Are References lesson.* To ensure that the data for each test is storied in a unique place in memory, there are functions implemented in `test_constants.py` that provide clean test data (i.e. `clean_wave_3_data`) by using `copy.deepcopy`.
For the time being, we need to make sure that the data provided to each test is clean and free of any changes that running another test may have introduced. Recall the _Modifying Mutable Objects_ section of the _Variables Are References lesson._ To ensure that the data for each test is storied in a unique place in memory, there are functions implemented in `test_constants.py` that provide clean test data (i.e. `clean_wave_3_data`) by using `copy.deepcopy`.

## Project Directions

Expand All @@ -202,7 +202,7 @@ When our test failures leave us confused and stuck, let's use the detailed proje

### Wave 1

1. Create a function named `create_movie`. This function and all subsequent functions should be in `party.py`. `create_movie` should...
1. Create a function named `create_movie`. This function and all subsequent functions should be in `party.py`. `create_movie` should...

- take three parameters: `title`, `genre`, `rating`
- If those three attributes are truthy, then return a dictionary. This dictionary should...
Expand Down Expand Up @@ -320,7 +320,7 @@ Note: For Waves 2, 3, 4, and 5, your implementation of each of the functions sho

### Wave 5

1. Create a function named `get_new_rec_by_genre`. This function should...
1. Create a function named `get_new_rec_by_genre`. This function should...

- take one parameter: `user_data`
- Consider the user's most frequently watched genre. Then, determine a list of recommended movies. A movie should be added to this list if and only if:
Expand All @@ -329,7 +329,7 @@ Note: For Waves 2, 3, 4, and 5, your implementation of each of the functions sho
- The `"genre"` of the movie is the same as the user's most frequent genre
- Return the list of recommended movies

2. Create a function named `get_rec_from_favorites`. This function should...
2. Create a function named `get_rec_from_favorites`. This function should...

- take one parameter: `user_data`
- `user_data` will have a field `"favorites"`. The value of `"favorites"` is a list of movie dictionaries
Expand Down
8 changes: 4 additions & 4 deletions play_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
# print("\n-----Wave 02 user_data-----")
# pp.pprint(clean_wave_2_data())

#print("\n-----Wave 03 user_data-----")
#pp.pprint(clean_wave_3_data())
# print("\n-----Wave 03 user_data-----")
# pp.pprint(clean_wave_3_data())

# Wave 04 user data
#print("\n-----Wave 04 user_data-----")
#pp.pprint(clean_wave_4_data())
print("\n-----Wave 04 user_data-----")
pp.pprint(clean_wave_4_data())

# Wave 05 user data
#print("\n-----Wave 05 user_data-----")
Expand Down
27 changes: 14 additions & 13 deletions tests/test_wave_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from viewing_party.party import *
from tests.test_constants import *

@pytest.mark.skip()
# @pytest.mark.skip()

Choose a reason for hiding this comment

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

Minor style preference: I would just delete these skip decorators rather than comment them out. Just helps keep the code cleaner.

There's a few other skip decorators that are like this, but I'll only say it once.

Having talked to other students, they ran into issues trying to delete rather than comment, but I tried it myself and it seemed to work OK.

def test_create_successful_movie():
# Arrange
movie_title = MOVIE_TITLE_1
Expand All @@ -19,7 +19,7 @@ def test_create_successful_movie():
assert new_movie["genre"] == GENRE_1
assert new_movie["rating"] == pytest.approx(RATING_1)

@pytest.mark.skip()
# @pytest.mark.skip()
def test_create_no_title_movie():
# Arrange
movie_title = None
Expand All @@ -32,7 +32,7 @@ def test_create_no_title_movie():
# Assert
assert new_movie is None

@pytest.mark.skip()
# @pytest.mark.skip()
def test_create_no_genre_movie():
# Arrange
movie_title = "Title A"
Expand All @@ -45,7 +45,7 @@ def test_create_no_genre_movie():
# Assert
assert new_movie is None

@pytest.mark.skip()
# @pytest.mark.skip()
def test_create_no_rating_movie():
# Arrange
movie_title = "Title A"
Expand All @@ -58,7 +58,7 @@ def test_create_no_rating_movie():
# Assert
assert new_movie is None

@pytest.mark.skip()
# @pytest.mark.skip()
def test_adds_movie_to_user_watched():
# Arrange
movie = {
Expand All @@ -79,7 +79,7 @@ def test_adds_movie_to_user_watched():
assert updated_data["watched"][0]["genre"] == GENRE_1
assert updated_data["watched"][0]["rating"] == RATING_1

@pytest.mark.skip()
# @pytest.mark.skip()
def test_adds_movie_to_user_watchlist():
# Arrange
movie = {
Expand All @@ -100,7 +100,7 @@ def test_adds_movie_to_user_watchlist():
assert updated_data["watchlist"][0]["genre"] == GENRE_1
assert updated_data["watchlist"][0]["rating"] == RATING_1

@pytest.mark.skip()
# @pytest.mark.skip()
def test_moves_movie_from_watchlist_to_empty_watched():
# Arrange
janes_data = {
Expand All @@ -119,15 +119,16 @@ def test_moves_movie_from_watchlist_to_empty_watched():
assert len(updated_data["watchlist"]) == 0
assert len(updated_data["watched"]) == 1

raise Exception("Test needs to be completed.")
# raise Exception("Test needs to be completed.")

Choose a reason for hiding this comment

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

As a minor style preference, I recommend just getting rid of commented out code in general unless there's a clear reason to keep it, which should be explained in a comment. This also applies to the comments below where we described how we wanted you to extend the tests, but more just in the sense of keeping code clean.

Deleting these comments would have the additional benefit of keeping the assert on line 126 closer to the other asserts in this function.

I'm sure there's a few other cases where this applies, but I'll only point it out once to avoid repeating myself.

# *******************************************************************************************
# ****** Add assertions here to test that the correct movie was added to "watched" **********
# *******************************************************************************************

@pytest.mark.skip()
assert updated_data["watched"][0]["title"] == MOVIE_TITLE_1

Choose a reason for hiding this comment

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

This test is OK as a quick check, but as a minor test design thing, I would recommend checking all the keys of the movie that got watched, not just the title. The easiest way to do this would likely to save the expected dictionary and use == to compare the entire dictionary, but admittedly, the arrange part of this code that we wrote would have to change...

# @pytest.mark.skip()
def test_moves_movie_from_watchlist_to_watched():
# Arrange
movie_to_watch = HORROR_1

janes_data = {
"watchlist": [
FANTASY_1,
Expand All @@ -143,12 +144,12 @@ def test_moves_movie_from_watchlist_to_watched():
assert len(updated_data["watchlist"]) == 1
assert len(updated_data["watched"]) == 2

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

@pytest.mark.skip()
assert updated_data["watched"][1] == HORROR_1

Choose a reason for hiding this comment

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

Following on the last test design issue, yes, this is a good way to check all keys, not just the title, so good work!

# @pytest.mark.skip()
def test_does_nothing_if_movie_not_in_watchlist():
# Arrange
movie_to_watch = HORROR_1
Expand Down
8 changes: 4 additions & 4 deletions tests/test_wave_02.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from viewing_party.party import *
from tests.test_constants import *

@pytest.mark.skip()
# @pytest.mark.skip()
def test_calculates_watched_average_rating():
# Arrange
janes_data = clean_wave_2_data()
Expand All @@ -14,7 +14,7 @@ def test_calculates_watched_average_rating():
assert average == pytest.approx(3.58333)
assert janes_data == clean_wave_2_data()

@pytest.mark.skip()
# @pytest.mark.skip()
def test_empty_watched_average_rating_is_zero():
# Arrange
janes_data = {
Expand All @@ -27,7 +27,7 @@ def test_empty_watched_average_rating_is_zero():
# Assert
assert average == pytest.approx(0.0)

@pytest.mark.skip()
# @pytest.mark.skip()
def test_most_watched_genre():
# Arrange
janes_data = clean_wave_2_data()
Expand All @@ -39,7 +39,7 @@ def test_most_watched_genre():
assert popular_genre == "Fantasy"
assert janes_data == clean_wave_2_data()

@pytest.mark.skip()
# @pytest.mark.skip()
def test_genre_is_None_if_empty_watched():
# Arrange
janes_data = {
Expand Down
14 changes: 7 additions & 7 deletions tests/test_wave_03.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from viewing_party.party import *
from tests.test_constants import *

@pytest.mark.skip()
# @pytest.mark.skip()
def test_my_unique_movies():
# Arrange
amandas_data = clean_wave_3_data()
Expand All @@ -16,7 +16,7 @@ def test_my_unique_movies():
assert INTRIGUE_2 in amandas_unique_movies
assert amandas_data == clean_wave_3_data()

@pytest.mark.skip()
# @pytest.mark.skip()
def test_my_not_unique_movies():
# Arrange
amandas_data = clean_wave_3_data()
Expand All @@ -28,7 +28,7 @@ def test_my_not_unique_movies():
# Assert
assert len(amandas_unique_movies) == 0

@pytest.mark.skip()
# @pytest.mark.skip()
def test_friends_unique_movies():
# Arrange
amandas_data = clean_wave_3_data()
Expand All @@ -43,7 +43,7 @@ def test_friends_unique_movies():
assert FANTASY_4 in friends_unique_movies
assert amandas_data == clean_wave_3_data()

@pytest.mark.skip()
# @pytest.mark.skip()
def test_friends_unique_movies_not_duplicated():
# Arrange
amandas_data = clean_wave_3_data()
Expand All @@ -55,12 +55,12 @@ def test_friends_unique_movies_not_duplicated():
# Assert
assert len(friends_unique_movies) == 3

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

@pytest.mark.skip()
assert friends_unique_movies[2] == INTRIGUE_3
# @pytest.mark.skip()
def test_friends_not_unique_movies():
# Arrange
amandas_data = {
Expand Down
6 changes: 3 additions & 3 deletions tests/test_wave_04.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from viewing_party.party import *
from tests.test_constants import *

@pytest.mark.skip()
# @pytest.mark.skip()
def test_get_available_friend_rec():
# Arrange
amandas_data = clean_wave_4_data()
Expand All @@ -16,7 +16,7 @@ def test_get_available_friend_rec():
assert FANTASY_4b in recommendations
assert amandas_data == clean_wave_4_data()

@pytest.mark.skip()
# @pytest.mark.skip()
def test_no_available_friend_recs():
# Arrange
amandas_data = {
Expand All @@ -38,7 +38,7 @@ def test_no_available_friend_recs():
# Assert
assert len(recommendations) == 0

@pytest.mark.skip()
# @pytest.mark.skip()
def test_no_available_friend_recs_watched_all():
# Arrange
amandas_data = {
Expand Down
Loading