Skip to content

Commit

Permalink
Update on function create_movie
Browse files Browse the repository at this point in the history
  • Loading branch information
momofAnAl committed Sep 23, 2024
1 parent 6eabeb8 commit 23a67e3
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 15 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Viewing Party

## Skills Assessed
# Hi Anh :) --> -->
### Hi Jenny. It's so great to work with you!

Solving problems with...

- Conditional logic
Expand Down
22 changes: 11 additions & 11 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()
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_non_empty_user_watched():
# Arrange
movie = {
Expand All @@ -99,7 +99,7 @@ def test_adds_movie_to_non_empty_user_watched():
assert movie in updated_data["watched"]
assert FANTASY_2 in updated_data["watched"]

@pytest.mark.skip()
#@pytest.mark.skip()
def test_adds_movie_to_user_watchlist():
# Arrange
movie = {
Expand All @@ -120,7 +120,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_adds_movie_to_non_empty_user_watchlist():
# Arrange
movie = {
Expand All @@ -140,7 +140,7 @@ def test_adds_movie_to_non_empty_user_watchlist():
assert movie in updated_data["watchlist"]
assert FANTASY_2 in updated_data["watchlist"]

@pytest.mark.skip()
#@pytest.mark.skip()
def test_moves_movie_from_watchlist_to_empty_watched():
# Arrange
janes_data = {
Expand All @@ -164,7 +164,7 @@ def test_moves_movie_from_watchlist_to_empty_watched():
# ****** Add assertions here to test that the correct movie was added to "watched" **********
# *******************************************************************************************

@pytest.mark.skip()
#@pytest.mark.skip()
def test_moves_movie_from_watchlist_to_watched():
# Arrange
movie_to_watch = HORROR_1
Expand All @@ -188,7 +188,7 @@ def test_moves_movie_from_watchlist_to_watched():
# ****** Add assertions here to test that the correct movie was added to "watched" **********
# *******************************************************************************************

@pytest.mark.skip()
#@pytest.mark.skip()
def test_does_nothing_if_movie_not_in_watchlist():
# Arrange
movie_to_watch = HORROR_1
Expand Down
35 changes: 33 additions & 2 deletions viewing_party/party.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,43 @@
# ------------- WAVE 1 --------------------

def create_movie(title, genre, rating):
pass
"""
Create a dictionary representing a movie
Parameters:
title(str): the title of movie
genre (str): the genre of movie
rating (float): the rating of movie
Returns:
dict: with keys "title", "genre", "rating" if all arguments are truthy
None: if any of arguments are falsy
"""

# Psuedocode:

try:
# Checking if user inputs on these parameters are all valid.
title = str(title)
genre = str(genre)
rating = float(rating)

# Need to check the type of tittle and genre are string and rating are int
if title and genre and rating:
return {"title": title, "genre": genre, "rating": rating}

except ValueError and TypeError as e:
print(e)
return None

print(create_movie(None, "Horror", 3.5))



# -----------------------------------------
# ------------- WAVE 2 --------------------
# -----------------------------------------


# -----------------------------------------
# ------------- WAVE 3 --------------------
Expand Down

0 comments on commit 23a67e3

Please sign in to comment.