Example #1
0
def test_add_colleague(actor):
    result = actor.add_actor_colleague("")
    assert result == -1
    assert actor.actor_colleague_list == []
    actor1 = Actor("Joe Jonas")
    result = actor.add_actor_colleague(actor1)
    assert result == 1
    assert actor.actor_colleague_list == [actor1]
    actor2 = 'Henry Bagel'
    result = actor.add_actor_colleague(actor2)
    assert result == -1
    assert actor.actor_colleague_list == [actor1]
    actor3 = Actor("Jane Doe")
    result = actor.add_actor_colleague(actor3)
    assert result == 1
    assert actor.actor_colleague_list == [actor1, actor3]
    result = actor.add_actor_colleague(actor1)
    list1 = [actor1]
    assert result == 0
    assert actor.actor_colleague_list == [actor1, actor3]
    actor4 = Actor("")
    actor5 = Actor(45)
    result = actor.add_actor_colleague(actor4)
    assert result == 0
    result = actor.add_actor_colleague(actor5)
    assert result == 0
    assert len(actor.actor_colleague_list) == 2
    assert actor.actor_colleague_list == [actor1, actor3]
Example #2
0
def test_compare():
    actor1 = Actor("Brad Pitt")
    actor2 = Actor("Brad Pitt")
    assert actor1 == actor2
    actor2 = 4
    assert actor1 != actor2
    actor1 = Actor("")
    actor2 = Actor(45)
    assert actor1 == actor2
Example #3
0
def test_init(actor):
    assert actor.actor_full_name == 'Brad Pitt'
    actor1 = Actor("Brad Pitt")
    assert repr(actor1) == "<Actor Brad Pitt>"
    actor2 = Actor("")
    assert actor2.actor_full_name is None
    actor3 = Actor(42)
    assert actor3.actor_full_name is None
    assert repr(actor2) == "<Actor None>"
    assert repr(actor3) == "<Actor None>"
Example #4
0
def test_hash():
    actor1 = Actor("Brad Pitt")
    actor2 = Actor("Brad Pitt")
    assert hash(actor1) == hash(actor2)
    actor2 = Actor("Taika Waititj")
    assert hash(actor1) != hash(actor2)
    dict1 = dict()
    dict1[actor1] = actor2
    assert dict1[actor1] == actor2
    assert repr(dict1[actor1]) == "<Actor Taika Waititj>"
    actor1 = Actor("")
    actor2 = Actor(9)
    dict1[actor1] = actor2
    assert dict1[actor1] == actor2
    assert repr(dict1[actor1]) == "<Actor None>"
Example #5
0
 def get_movies_for_actor(self, actor_name: str):
     list_of_movies = []
     for movie in self.__dataset_of_movies:
         if not len(movie.actors) == 0:
             if Actor(actor_name) in movie.actors:
                 list_of_movies.append(movie)
     return list_of_movies
Example #6
0
def user():
    movie = Movie('Up', 2009)
    movie.add_actor(Actor("Will Smith"))
    movie.add_actor(Actor("Daniel Radcliff"))
    movie.add_genre(Genre("Comedy"))
    movie.add_genre(Genre("Drama"))
    director = Director("Peter Jackson")
    movie.director = director

    movie1 = Movie('Down', 2013)
    movie1.add_actor(Actor("Tom Cruise"))
    movie1.add_actor(Actor("Selena Gomez"))
    movie1.add_genre(Genre("Comedy"))
    movie1.add_genre(Genre("Romance"))
    director = Director("Peter Jackson")
    movie1.director = director

    movie2 = Movie('Boom', 1999)
    movie2.add_actor(Actor("Will Smith"))
    movie2.add_actor(Actor("Tom Cruise"))
    movie2.add_genre(Genre("Comedy"))
    movie2.add_genre(Genre("Action"))
    director = Director("Taika Waititi")
    movie2.director = director

    user = User("aram", "one1")
    user.watch_movie(movie)
    user.watch_movie(movie1)
    user.watch_movie(movie2)
    return user
Example #7
0
def test_check_colleague(actor):
    assert not actor.check_if_this_actor_worked_with(actor)
    actor1 = 'Henry Bagel'
    actor2 = Actor('Joe Jonas')
    actor3 = Actor('Amy Harris')
    actor4 = Actor("")
    actor5 = Actor(56)
    result = actor.add_actor_colleague(actor1)
    assert result == -1
    result = actor.add_actor_colleague(actor2)
    assert result == 1
    result = actor.add_actor_colleague(actor3)
    assert result == 1
    result = actor.add_actor_colleague(actor4)
    assert result == 0
    result = actor.add_actor_colleague(actor5)
    assert result == 0
    assert not actor.check_if_this_actor_worked_with(actor1)
    assert actor.check_if_this_actor_worked_with(actor2)
    assert actor.check_if_this_actor_worked_with(actor3)
    assert not actor.check_if_this_actor_worked_with(actor4)
    assert not actor.check_if_this_actor_worked_with(actor5)
Example #8
0
def test_init(stats):
    assert stats.user == User("aram", "one1", [], [], None, 0)
    assert stats.watched_movies == [
        Movie("Up", 2009),
        Movie("Down", 2013),
        Movie("Boom", 1999)
    ]
    assert stats.watched_actors == {
        Actor("Will Smith"): 2,
        Actor("Daniel Radcliff"): 1,
        Actor("Selena Gomez"): 1,
        Actor("Tom Cruise"): 2
    }
    assert stats.watched_directors == {
        Director("Peter Jackson"): 2,
        Director("Taika Waititi"): 1
    }
    assert stats.watched_genres == {
        Genre("Comedy"): 3,
        Genre("Romance"): 1,
        Genre("Drama"): 1,
        Genre("Action"): 1
    }
Example #9
0
def test_top_actors(stats):
    movie2 = Movie('Brin', 2002)
    movie2.add_actor(Actor("Tom Cruise"))
    stats.user.watch_movie(movie2)
    stats.update_watched_lists()
    assert stats.top_actors(2) == [Actor("Tom Cruise"), Actor("Will Smith")]
    assert stats.top_actors(6) == []
    assert stats.top_actors(-1) == [
        Actor("Tom Cruise"),
        Actor("Will Smith"),
        Actor("Selena Gomez"),
        Actor("Daniel Radcliff")
    ]
Example #10
0
def load_movies(data_path: str, repo: MemoryRepository, data_file):
    print("DATA: ", data_file)
    for row in read_csv_file(os.path.join(data_path, data_file)):
        try:
            movie = Movie(row['Title'], int(row['Year']))
        except ValueError:
            print("Invalid release year")
        else:
            director = Director(row['Director'].strip())
            actors = row['Actors'].split(",")
            genres = row['Genre'].split(",")
            movie.director = director
            repo.add_director(director)
            movie.description = row['Description'].strip()
            for actor_name in actors:
                actor_name = actor_name.strip()
                actor = Actor(actor_name)
                if actor in repo.get_actors():
                    i = repo.get_actors().index(actor)
                    actor = repo.get_actors()[i]
                else:
                    repo.add_actor(actor)
                for actor1_name in actors:
                    actor1_name = actor1_name.strip()
                    if not actor.check_if_this_actor_worked_with(
                            Actor(actor1_name)) and (actor_name !=
                                                     actor1_name):
                        actor.add_actor_colleague(Actor(actor1_name))
                movie.add_actor(actor)
            for genre_name in genres:
                genre = Genre(genre_name.strip())
                movie.add_genre(genre)
                if genre not in repo.get_genres():
                    repo.add_genre(genre)
            try:
                movie.runtime_minutes = int(row['Runtime (Minutes)'])
            except ValueError:
                movie.runtime_minutes = None
            try:
                movie.votes = int(row['Votes'])
            except ValueError:
                movie.votes = None
            try:
                movie.rating = float(row['Rating'])
            except ValueError:
                movie.rating = None
            if movie not in repo.get_movies():
                movie.image = get_image(movie)
                if movie.image == "":
                    movie.image = "../static/none.jpg"
                repo.add_movie(movie)
Example #11
0
def test_update(stats):
    movie2 = Movie('Brain', 2002)
    movie2.add_actor(Actor("Julia Roberts"))
    movie2.add_actor(Actor("Tom Cruise"))
    movie2.add_genre(Genre("Sci-Fi"))
    movie2.add_genre(Genre("Action"))
    director = Director("Christopher Nolan")
    movie2.director = director

    stats.user.watch_movie(movie2)
    stats.update_watched_lists()

    assert stats.user == User("aram", "one1", [], [], 0)
    assert stats.watched_movies == [
        Movie("Up", 2009),
        Movie("Down", 2013),
        Movie("Boom", 1999),
        Movie("Brain", 2002)
    ]
    assert stats.watched_actors == {
        Actor("Will Smith"): 2,
        Actor("Daniel Radcliff"): 1,
        Actor("Selena Gomez"): 1,
        Actor("Tom Cruise"): 3,
        Actor("Julia Roberts"): 1
    }
    assert stats.watched_directors == {
        Director("Peter Jackson"): 2,
        Director("Taika Waititi"): 1,
        Director("Christopher Nolan"): 1
    }
    assert stats.watched_genres == {
        Genre("Comedy"): 3,
        Genre("Romance"): 1,
        Genre("Drama"): 1,
        Genre("Action"): 2,
        Genre("Sci-Fi"): 1
    }
Example #12
0
def test_add_remove_actor(movie):
    movie.add_actor(Actor("Will Smith"))
    movie.add_actor(Actor(""))
    movie.add_actor(Actor(3))
    movie.add_actor(4)
    movie.add_actor(Actor("Daniel Radcliff"))
    assert movie.actors == [Actor("Will Smith"), Actor("Daniel Radcliff")]
    movie.remove_actor(Actor("Daniel Radcliff"))
    assert movie.actors == [Actor("Will Smith")]
    movie.remove_actor(Actor("Daniel Radcliff"))
    assert movie.actors == [Actor("Will Smith")]
    movie.remove_actor(Actor("Will Smith"))
    movie.remove_actor(4)
    movie.remove_actor(Actor(""))
    assert movie.actors == []
    movie.remove_actor(Actor("Will Smith"))
    assert movie.actors == []
Example #13
0
def actor():
    return Actor('Brad Pitt')
Example #14
0
def test_lt():
    actor1 = Actor("Brad Pitt")
    actor2 = Actor("brad Pitt")
    assert actor1 < actor2
Example #15
0
def test_get_next_colleague():
    actor2 = Actor('Joe Jonas')
    actor3 = Actor('Amy Harris')
Example #16
0
def test_set_colleagues():
    actor2 = Actor('Joe Jonas')
    actor3 = Actor('Amy Harris')
Example #17
0
def test_add_actor(in_memory_repo):
    assert Actor("Katy Perry") not in in_memory_repo.get_actors()
    in_memory_repo.add_actor(Actor("Katy Perry"))
    assert Actor("Katy Perry") in in_memory_repo.get_actors()