示例#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(session=session, **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'
示例#2
0
    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()