Ejemplo n.º 1
0
 def test_check_if_this_actor_worked_with(self):
     actor1 = Actor("Angelina Jolie")
     actor2 = Actor("Brad Pitt")
     actor3 = Actor("Not an Actor")
     actor1.add_actor_colleague(actor2)
     assert actor1.check_if_this_actor_worked_with(actor2) == True
     assert actor2.check_if_this_actor_worked_with(actor1) == True
     assert actor1.check_if_this_actor_worked_with(actor3) == False
Ejemplo n.º 2
0
 def test_init(self):
     actor1 = Actor("Angelina Jolie")
     assert repr(actor1) == "<Actor Angelina Jolie>"
     actor2 = Actor("Brad Pitt")
     assert (actor1 == actor2) == False
     assert (actor1 < actor2) == True
     assert hash(actor2) == hash("Brad Pitt")
     actor1.add_actor_colleague(actor2)
     assert actor1.check_if_this_actor_worked_with(actor2) == True
Ejemplo n.º 3
0
def test_init():
    actor1 = Actor("Angelina Jolie")
    assert repr(actor1) == "<Actor Angelina Jolie>"
    actor2 = Actor("Cameron Diaz")
    assert repr(actor2) == "<Actor Cameron Diaz>"
    actor3 = Actor(42)
    assert actor3.actor_name is None
    actor1.add_actor_colleague(actor2)
    result = actor1.check_if_this_actor_worked_with(actor2)
    assert result is True
Ejemplo n.º 4
0
def test_actor():
    actor1 = Actor("Angelina Jolie")
    assert repr(actor1) == "<Actor Angelina Jolie>"
    actor2 = Actor("")
    assert actor2.actor_full_name is None
    actor3 = Actor(42)
    assert actor3.actor_full_name is None
    actor4 = Actor("Brad Pitt")
    assert actor1 < actor4
    actor1.add_actor_colleague(actor4)
    assert actor1.check_if_this_actor_worked_with(actor4)
Ejemplo n.º 5
0
 def read_csv_file(self):
     with open(self.__file_name, mode='r', encoding='utf-8-sig') as csvfile:
         movie_file_reader = csv.DictReader(csvfile)
         index = 0
         for row in movie_file_reader:
             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
                 if director not in self.__dataset_of_directors:
                     self.__dataset_of_directors.append(director)
                 movie.description = row['Description'].strip()
                 for actor_name in actors:
                     actor_name = actor_name.strip()
                     actor = Actor(actor_name.strip())
                     if actor in self.dataset_of_actors:
                         i = self.dataset_of_actors.index(actor)
                         actor = self.dataset_of_actors[i]
                     else:
                         self.__dataset_of_actors.append(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 self.__dataset_of_genres:
                         self.__dataset_of_genres.append(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 self.__dataset_of_movies: # Check if this takes into account the same movie but different objects
                     self.__dataset_of_movies.append(movie)
             index += 1
Ejemplo n.º 6
0
    def test_add_actor_colleague(self):
        actor1 = Actor("Tom Cruise")
        colleague1 = Actor("Dwayne Johnson")

        actor1.add_actor_colleague(colleague1)
        assert actor1.check_if_this_actor_worked_with(colleague1) == True
Ejemplo n.º 7
0
 def test_actor_add_and_check_colleague(self):
     actor1 = Actor("Angelina Jolie")
     actor2 = Actor("Jack Black")
     actor1.add_actor_colleague(actor2)
     assert actor1.check_if_this_actor_worked_with(actor2) is True