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
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
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
27 changes: 15 additions & 12 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()

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()

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()

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()

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

@pytest.mark.skip()
def test_adds_movie_to_user_watched():
# Arrange
movie = {
Expand All @@ -79,7 +78,6 @@ 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()
def test_adds_movie_to_user_watchlist():
# Arrange
movie = {
Expand All @@ -100,7 +98,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()

def test_moves_movie_from_watchlist_to_empty_watched():
# Arrange
janes_data = {
Expand All @@ -119,12 +117,13 @@ 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.")
assert updated_data["watched"][0]["title"] == MOVIE_TITLE_1
# *******************************************************************************************
# ****** Add assertions here to test that the correct movie was added to "watched" **********
# *******************************************************************************************

@pytest.mark.skip()

def test_moves_movie_from_watchlist_to_watched():
# Arrange
movie_to_watch = HORROR_1
Expand All @@ -142,13 +141,17 @@ def test_moves_movie_from_watchlist_to_watched():
# Assert
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.")
assert updated_data["watched"][1] == movie_to_watch
assert updated_data["watchlist"][0] != movie_to_watch
# *******************************************************************************************
# ****** Add assertions here to test that the correct movie was added to "watched" **********
# *******************************************************************************************




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

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

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

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

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

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

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

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

@pytest.mark.skip()
def test_friends_unique_movies_not_duplicated():
# Arrange
amandas_data = clean_wave_3_data()
Expand All @@ -55,12 +51,13 @@ 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.")
assert HORROR_1 in friends_unique_movies
assert INTRIGUE_3 in friends_unique_movies
# *************************************************************************************************
# ****** Add assertions here to test that the correct movies are in friends_unique_movies **********
# **************************************************************************************************

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

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

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

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

@pytest.mark.skip()
def test_new_genre_rec():
# Arrange
sonyas_data = clean_wave_5_data()
Expand All @@ -17,7 +16,6 @@ def test_new_genre_rec():
assert FANTASY_4b in recommendations
assert sonyas_data == clean_wave_5_data()

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

@pytest.mark.skip()
def test_new_genre_rec_from_empty_friends():
# Arrange
sonyas_data = {
Expand All @@ -53,12 +50,16 @@ def test_new_genre_rec_from_empty_friends():
]
}

raise Exception("Test needs to be completed.")
# raise Exception("Test needs to be completed.")
# Act
recommendations = get_new_rec_by_genre(sonyas_data)
# Assert
assert len(recommendations) == 0

# *********************************************************************
# ****** Complete the Act and Assert Portions of theis tests **********
# *********************************************************************

@pytest.mark.skip()
def test_unique_rec_from_favorites():
# Arrange
sonyas_data = clean_wave_5_data()
Expand All @@ -72,7 +73,6 @@ def test_unique_rec_from_favorites():
assert INTRIGUE_2b in recommendations
assert sonyas_data == clean_wave_5_data()

@pytest.mark.skip()
def test_unique_from_empty_favorites():
# Arrange
sonyas_data = {
Expand All @@ -94,7 +94,6 @@ def test_unique_from_empty_favorites():
# Assert
assert len(recommendations) == 0

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