def test_search_results(self, execute_task): task = execute_task('test_search_results') entry = task.entries[0] assert entry['movie_name'].lower() == 'Harry Potter and The Philosopher\'s Stone'.lower(), 'lookup failed' with Session() as session: assert len(session.query(TraktMovieSearchResult).all()) == 1, 'should have added one movie to search result' # change the search query session.query(TraktMovieSearchResult).update({'search': "harry.potter.and.the.philosopher's"}) session.commit() lookupargs = {'title': "harry.potter.and.the.philosopher's"} movie = ApiTrakt.lookup_movie(**lookupargs) assert movie.imdb_id == entry['imdb_id'] assert movie.title.lower() == entry['movie_name'].lower()
def get(self, title, session=None): args = lookup_parser.parse_args() include_actors = args.pop('include_actors') include_translations = args.pop('include_translations') kwargs = args kwargs['title'] = title try: movie = at.lookup_movie(session=session, **kwargs) except LookupError as e: return {'status': 'error', 'message': e.args[0]}, 404 result = movie.to_dict() if include_actors: result["actors"] = list_actors(movie.actors) if include_translations: result["translations"] = get_translations(movie.translate) return jsonify(result)
def get(self, title, session=None): args = lookup_parser.parse_args() include_actors = args.pop('include_actors') include_translations = args.pop('include_translations') kwargs = args kwargs['title'] = title try: movie = at.lookup_movie(session=session, **kwargs) except LookupError as e: raise NotFoundError(e.args[0]) result = movie.to_dict() if include_actors: result['actors'] = list_actors(movie.actors) if include_translations: result['translations'] = get_translations_dict(movie.translations, 'movie') return jsonify(result)
def test_search_results(self, execute_task): task = execute_task('test_search_results') entry = task.entries[0] assert entry['movie_name'].lower() == 'Harry Potter and The Philosopher\'s Stone'.lower(), 'lookup failed' with Session() as session: assert len(session.query(TraktMovieSearchResult).all()) == 1, 'should have added one movie to search result' # change the search query session.query(TraktMovieSearchResult).update({'search': "harry.potter.and.the.philosopher's"}) session.commit() lookupargs = {'title': "harry.potter.and.the.philosopher's"} movie = ApiTrakt.lookup_movie(session=session, **lookupargs) assert movie.imdb_id == entry['imdb_id'] assert movie.title.lower() == entry['movie_name'].lower()
def get(self, title, session=None): """Trakt movie lookup""" args = lookup_parser.parse_args() include_actors = args.pop('include_actors') include_translations = args.pop('include_translations') kwargs = args kwargs['title'] = title try: movie = at.lookup_movie(session=session, **kwargs) except LookupError as e: raise NotFoundError(e.args[0]) result = movie.to_dict() if include_actors: result['actors'] = list_actors(movie.actors) if include_translations: result['translations'] = get_translations_dict(movie.translations, 'movie') return jsonify(result)
def get(self, title, session=None): args = lookup_parser.parse_args() include_actors = args.pop('include_actors') include_translations = args.pop('include_translations') kwargs = args kwargs['title'] = title try: movie = at.lookup_movie(session=session, **kwargs) except LookupError as e: return {'status': 'error', 'message': e.args[0] }, 404 result = movie.to_dict() if include_actors: result["actors"] = list_actors(movie.actors) if include_translations: result["translations"] = get_translations(movie.translate) return jsonify(result)