Exemple #1
0
def get_movie_poster_url(movie: Movie):
    if movie.poster_url == '':
        response = tmdb.Search().movie(query=movie.title)
        if response['total_results'] > 0:
            poster_path = response['results'][0]['poster_path']
            if poster_path is not None:
                movie.poster_url = base_url + size + poster_path
                return movie.poster_url
            else:
                movie.poster_url = 'static/images/default.png'
                return movie.poster_url
    else:
        return movie.poster_url
 def test_movie_hash(self, movie_1, movie_2):
     assert hash(movie_1) != hash(movie_2)
     movie_3 = Movie(title='Mr. & Mrs. Smith',
                     year=2005,
                     desc='',
                     director=director,
                     mins=120)
     assert hash(movie_1) == hash(movie_3)
Exemple #3
0
def load_movies(path: str, repo: MemoryRepository):
    for row in read_datafile(os.path.join(path, 'movies.csv')):
        new_director = Director(row[4].strip())
        movie = Movie(title=row[1],
                      year=int(row[6]),
                      desc=row[3],
                      director=new_director,
                      mins=int(row[7]),
                      rank=int(row[0]))
        repo.add_movie(movie)
        repo.add_director(movie.director)
        for actor in row[5].split(','):
            new_actor = Actor(actor.strip())
            movie.add_actor(new_actor)
            repo.add_actor(new_actor)
        for genre in row[2].split(','):
            new_genre = Genre(genre.strip())
            movie.add_genre(new_genre)
            repo.add_genre(new_genre)
def test_add_movie_get_by_id(test_repo):
    movie = Movie(title='Made-Up Movie', year=1994)
    test_repo.add_movie(movie)
    assert test_repo.get_movie_by_id(movie.movie_id) is movie
def test_add_movie_get_by_title(test_repo):
    movie = Movie(title='Harry Potter and the Order of the Phoenix', year=2007)
    test_repo.add_movie(movie)
    assert test_repo.get_movie_by_title(
        'Harry Potter and the Order of the Phoenix').title == movie.title
def movie_2(director):
    return Movie(title='Mr. & Mrs. Smith',
                 year=2006,
                 desc='This is a description',
                 director=director,
                 mins=120)
 def test_movie_year(self, movie_1):
     movie_1.year = 1899
     assert movie_1.year == 2005
     movie_2 = Movie('Mr. & Mrs. Smith', 1899)
     assert movie_2.year is None