Ejemplo n.º 1
0
    def test_search_results(self, execute_task):
        task = execute_task('test_search_result')
        entry = task.entries[0]
        print entry['trakt_series_name'].lower()
        assert entry['trakt_series_name'].lower() == 'Shameless'.lower(
        ), 'lookup failed'
        with Session() as session:
            assert task.entries[1]['trakt_series_name'].lower(
            ) == 'Shameless'.lower(), 'second lookup failed'

            assert len(session.query(TraktShowSearchResult).all()
                       ) == 1, 'should have added 1 show to search result'

            assert len(session.query(TraktShow).all()
                       ) == 1, 'should only have added one show to show table'
            assert session.query(TraktShow).first().title == 'Shameless', 'should have added Shameless and' \
                                                                          'not Shameless (2011)'
            # change the search query
            session.query(TraktShowSearchResult).update(
                {'search': "Shameless.S01E03.HDTV-FlexGet"})
            session.commit()

            lookupargs = {'title': "Shameless.S01E03.HDTV-FlexGet"}
            series = ApiTrakt.lookup_series(**lookupargs)

            assert series.tvdb_id == entry[
                'tvdb_id'], 'tvdb id should be the same as the first entry'
            assert series.id == entry[
                'trakt_show_id'], 'trakt id should be the same as the first entry'
            assert series.title.lower() == entry['trakt_series_name'].lower(
            ), 'series name should match first entry'
Ejemplo n.º 2
0
    def get(self, session=None):
        args = lookup_parser.parse_args()
        try:
            result = at.lookup_series(session=session, **args)
        except LookupError as e:
            return {'status': 'error',
                    'message': e.args[0]
                    }, 404

        return jsonify(result.to_dict())
Ejemplo n.º 3
0
    def get(self, session=None):
        args = lookup_parser.parse_args()
        try:
            result = at.lookup_series(session=session, **args)
        except LookupError as e:
            return {'status': 'error',
                    'message': e.args[0]
                    }, 404

        return jsonify(result.to_dict())
Ejemplo n.º 4
0
 def get(self, session=None):
     args = lookup_parser.parse_args()
     include_actors = args.pop('include_actors')
     try:
         series = at.lookup_series(session=session, **args)
     except LookupError as e:
         return {'status': 'error',
                 'message': e.args[0]
                 }, 404
     result = series.to_dict()
     if include_actors:
         result["actors"] = list_actors(series.actors),
     return jsonify(result)
Ejemplo n.º 5
0
 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:
         series = at.lookup_series(session=session, **kwargs)
     except LookupError as e:
         return {'status': 'error',
                 'message': e.args[0]
                 }, 404
     result = series.to_dict()
     if include_actors:
         result["actors"] = list_actors(series.actors),
     if include_translations:
         result["translations"] = get_translations(series.translate)
     return jsonify(result)
Ejemplo n.º 6
0
    def test_search_results(self, execute_task):
        task = execute_task('test_search_result')
        entry = task.entries[0]
        print(entry['trakt_series_name'].lower())
        assert entry['trakt_series_name'].lower() == 'Shameless'.lower(), 'lookup failed'
        with Session() as session:
            assert task.entries[1]['trakt_series_name'].lower() == 'Shameless'.lower(), 'second lookup failed'

            assert len(session.query(TraktShowSearchResult).all()) == 1, 'should have added 1 show to search result'

            assert len(session.query(TraktShow).all()) == 1, 'should only have added one show to show table'
            assert session.query(TraktShow).first().title == 'Shameless', 'should have added Shameless and' \
                                                                          'not Shameless (2011)'
            # change the search query
            session.query(TraktShowSearchResult).update({'search': "Shameless.S01E03.HDTV-FlexGet"})
            session.commit()

            lookupargs = {'title': "Shameless.S01E03.HDTV-FlexGet"}
            series = ApiTrakt.lookup_series(**lookupargs)

            assert series.tvdb_id == entry['tvdb_id'], 'tvdb id should be the same as the first entry'
            assert series.id == entry['trakt_id'], 'trakt id should be the same as the first entry'
            assert series.title.lower() == entry['trakt_series_name'].lower(), 'series name should match first entry'