Esempio n. 1
0
def test_get_show(mocker):
    mocker.patch.object(ShowDetailsDb, 'get_show', return_value=show_details_1)
    mocker.patch('os.path.exists', return_value=True)
    mocker.patch.object(ShowEpisodeDetailsDb,
                        'get_show_episodes',
                        return_value=[show_episode_details_1_1])
    mocker.patch.object(ShowSettingsDb,
                        'get_show_settings',
                        return_value=show_settings_1)
    mocker.patch(
        'autosubliminal.server.api.shows.ShowsApi._get_show_episode_files',
        return_value=[{
            'season_name':
            'Season 01',
            'season_path':
            '/path/to/show1',
            'season_files': [{
                'filename': 's01e01.mkv',
                'type': 'video',
                'embedded_languages': [],
                'hardcoded_languages': [],
                'tvdb_id': 11
            }, {
                'filename': 's01e01.srt',
                'type': 'subtitle',
                'language': 'nl'
            }]
        }])
    assert show_1_json == pickle_api_result(ShowsApi().get('1'))
def test_get_movies_overview(mocker):
    mocker.patch.object(FailedMoviesDb, 'get_failed_movies', return_value=['/path/to/failed/movie'])
    mocker.patch.object(MovieDetailsDb, 'get_all_movies', return_value=[movie_details_1])
    mocker.patch.object(MovieSettingsDb, 'get_movie_settings', side_effect=[movie_settings_1, movie_settings_2])
    overview_json = '{"failed_movies": ["/path/to/failed/movie"], "total_movies": 1, "total_subtitles_available": 1, ' \
                    '"total_subtitles_missing": 1, "total_subtitles_wanted": 2}'
    assert overview_json == pickle_api_result(MoviesApi().overview.get())
Esempio n. 3
0
def test_get_movies(mocker):
    mocker.patch.object(MovieDetailsDb,
                        'get_all_movies',
                        return_value=[movie_details_1, movie_details_2])
    mocker.patch.object(MovieSettingsDb,
                        'get_movie_settings',
                        side_effect=[movie_settings_1, movie_settings_2])
    assert movies_json == pickle_api_result(MoviesApi().get())
def test_get_movie(mocker):
    mocker.patch.object(MovieDetailsDb, 'get_movie', return_value=movie_details_1)
    mocker.patch('os.path.exists', return_value=True)
    mocker.patch('autosubliminal.server.api.movies.MoviesApi._get_movie_files',
                 return_value=[
                     {'filename': 'movie1.mkv', 'type': 'video', 'embedded_languages': [], 'hardcoded_languages': []},
                     {'filename': 'subtitle1.srt', 'type': 'subtitle', 'language': 'nl'}])
    mocker.patch.object(MovieSettingsDb, 'get_movie_settings', return_value=movie_settings_1)
    assert movie_1_json == pickle_api_result(MoviesApi().get('tt1'))
def test_get_shows_overview(mocker):
    mocker.patch.object(FailedShowsDb, 'get_failed_shows', return_value=['/path/to/failed/show'])
    mocker.patch.object(ShowDetailsDb, 'get_all_shows', return_value=[show_details_1, show_details_2])
    mocker.patch.object(ShowSettingsDb, 'get_show_settings', side_effect=[show_settings_1, show_settings_2])
    mocker.patch.object(ShowEpisodeDetailsDb, 'get_show_episodes',
                        side_effect=[[show_episode_details_1_1], [show_episode_details_2_1, show_episode_details_2_2]])
    overview_json = '{"failed_shows": ["/path/to/failed/show"], "total_episodes": 3, "total_shows": 2, ' \
                    '"total_subtitles_available": 2, "total_subtitles_missing": 4, "total_subtitles_wanted": 6}'
    assert overview_json == pickle_api_result(ShowsApi().overview.get())
def test_get_show(mocker):
    mocker.patch.object(ShowDetailsDb, 'get_show', return_value=show_details_1)
    mocker.patch('os.path.exists', return_value=True)
    mocker.patch.object(ShowEpisodeDetailsDb, 'get_show_episodes', return_value=[show_episode_details_1_1])
    mocker.patch.object(ShowSettingsDb, 'get_show_settings', return_value=show_settings_1)
    mocker.patch('autosubliminal.server.api.shows.ShowsApi._get_show_episode_files',
                 return_value=[{'season_name': 'Season 01', 'season_path': '/path/to/show1', 'season_files': [
                     {'filename': 's01e01.mkv', 'type': 'video', 'embedded_languages': [], 'hardcoded_languages': [],
                      'tvdb_id': 11},
                     {'filename': 's01e01.srt', 'type': 'subtitle', 'language': 'nl'}
                 ]}])
    assert show_1_json == pickle_api_result(ShowsApi().get('1'))
Esempio n. 7
0
def test_get_movies_overview(mocker):
    mocker.patch.object(FailedMoviesDb,
                        'get_failed_movies',
                        return_value=['/path/to/failed/movie'])
    mocker.patch.object(MovieDetailsDb,
                        'get_all_movies',
                        return_value=[movie_details_1])
    mocker.patch.object(MovieSettingsDb,
                        'get_movie_settings',
                        side_effect=[movie_settings_1, movie_settings_2])
    overview_json = '{"failed_movies": ["/path/to/failed/movie"], "total_movies": 1, "total_subtitles_available": 1, ' \
                    '"total_subtitles_missing": 1, "total_subtitles_wanted": 2}'
    assert overview_json == pickle_api_result(MoviesApi().overview.get())
Esempio n. 8
0
def test_get_shows(mocker):
    mocker.patch.object(ShowDetailsDb,
                        'get_all_shows',
                        return_value=[show_details_1, show_details_2])
    mocker.patch.object(
        ShowEpisodeDetailsDb,
        'get_show_episodes',
        side_effect=[[show_episode_details_1_1],
                     [show_episode_details_2_1, show_episode_details_2_2]])
    mocker.patch.object(ShowSettingsDb,
                        'get_show_settings',
                        side_effect=[show_settings_1, show_settings_2])
    assert shows_json == pickle_api_result(ShowsApi().get())
def test_get_settings(monkeypatch, mocker):
    monkeypatch.setattr('autosubliminal.DEVELOPER', True)
    monkeypatch.setattr('autosubliminal.WEBROOT', 'mywebroot')
    monkeypatch.setattr('autosubliminal.SCANDISK', MyScheduler('DiskScanner'))
    monkeypatch.setattr('autosubliminal.SCANLIBRARY', MyScheduler('LibraryScanner'))
    monkeypatch.setattr('autosubliminal.CHECKSUB', MyScheduler('SubChecker'))
    monkeypatch.setattr('autosubliminal.CHECKVERSION', MyScheduler('VersionChecker'))
    monkeypatch.setattr('autosubliminal.DEREFERURL', 'http://www.dereferer.org/?')
    monkeypatch.setattr('autosubliminal.TVDBURL', 'http://thetvdb.com/?tab=series&id=')
    monkeypatch.setattr('autosubliminal.IMDBURL', 'http://www.imdb.com/title/')
    monkeypatch.setattr('autosubliminal.TIMESTAMPFORMAT', '%d-%m-%Y %H:%M:%S')
    monkeypatch.setattr('autosubliminal.server.api.settings.os.path.sep', '/')
    mocker.patch('autosubliminal.server.api.settings.get_subtitle_languages',
                 return_value=[{'code': 'nl', 'name': 'Dutch'}])
    assert settings_json == pickle_api_result(SettingsApi().get())
Esempio n. 10
0
def test_get_shows_overview(mocker):
    mocker.patch.object(FailedShowsDb,
                        'get_failed_shows',
                        return_value=['/path/to/failed/show'])
    mocker.patch.object(ShowDetailsDb,
                        'get_all_shows',
                        return_value=[show_details_1, show_details_2])
    mocker.patch.object(ShowSettingsDb,
                        'get_show_settings',
                        side_effect=[show_settings_1, show_settings_2])
    mocker.patch.object(
        ShowEpisodeDetailsDb,
        'get_show_episodes',
        side_effect=[[show_episode_details_1_1],
                     [show_episode_details_2_1, show_episode_details_2_2]])
    overview_json = '{"failed_shows": ["/path/to/failed/show"], "total_episodes": 3, "total_shows": 2, ' \
                    '"total_subtitles_available": 2, "total_subtitles_missing": 4, "total_subtitles_wanted": 6}'
    assert overview_json == pickle_api_result(ShowsApi().overview.get())
Esempio n. 11
0
def test_get_movie(mocker):
    mocker.patch.object(MovieDetailsDb,
                        'get_movie',
                        return_value=movie_details_1)
    mocker.patch('os.path.exists', return_value=True)
    mocker.patch('autosubliminal.server.api.movies.MoviesApi._get_movie_files',
                 return_value=[{
                     'filename': 'movie1.mkv',
                     'type': 'video',
                     'embedded_languages': [],
                     'hardcoded_languages': []
                 }, {
                     'filename': 'subtitle1.srt',
                     'type': 'subtitle',
                     'language': 'nl'
                 }])
    mocker.patch.object(MovieSettingsDb,
                        'get_movie_settings',
                        return_value=movie_settings_1)
    assert movie_1_json == pickle_api_result(MoviesApi().get('tt1'))
Esempio n. 12
0
def test_get_settings(monkeypatch, mocker):
    monkeypatch.setattr('autosubliminal.DEVELOPER', True)
    monkeypatch.setattr('autosubliminal.WEBROOT', 'mywebroot')
    monkeypatch.setattr('autosubliminal.SCANDISK', MyScheduler('DiskScanner'))
    monkeypatch.setattr('autosubliminal.SCANLIBRARY',
                        MyScheduler('LibraryScanner'))
    monkeypatch.setattr('autosubliminal.CHECKSUB', MyScheduler('SubChecker'))
    monkeypatch.setattr('autosubliminal.CHECKVERSION',
                        MyScheduler('VersionChecker'))
    monkeypatch.setattr('autosubliminal.DEREFERURL',
                        'http://www.dereferer.org/?')
    monkeypatch.setattr('autosubliminal.TVDBURL',
                        'http://thetvdb.com/?tab=series&id=')
    monkeypatch.setattr('autosubliminal.IMDBURL', 'http://www.imdb.com/title/')
    monkeypatch.setattr('autosubliminal.TIMESTAMPFORMAT', '%d-%m-%Y %H:%M:%S')
    monkeypatch.setattr('autosubliminal.server.api.settings.os.path.sep', '/')
    mocker.patch('autosubliminal.server.api.settings.get_subtitle_languages',
                 return_value=[{
                     'code': 'nl',
                     'name': 'Dutch'
                 }])
    assert settings_json == pickle_api_result(SettingsApi().get())
Esempio n. 13
0
def test_get_movie_settings(mocker):
    mocker.patch.object(MovieSettingsDb,
                        'get_movie_settings',
                        return_value=movie_settings_1)
    assert movie_settings_1_json == pickle_api_result(
        MoviesApi().settings.get('tt1'))
Esempio n. 14
0
def test_get_downloaded_number_of_items(mocker):
    mocker.patch.object(LastDownloadsDb, 'get_last_downloads', return_value=[downloaded_item])
    assert downloaded_item_list_json == pickle_api_result(ItemsApi().downloaded.get(1))
Esempio n. 15
0
def test_delete_wanted_item():
    autosubliminal.WANTEDQUEUE = []
    autosubliminal.WANTEDQUEUE.append(wanted_item)
    # Check conversion to json (need to pickle ourselves because we don't use cherrypy.tools here)
    assert wanted_item_json == pickle_api_result(ItemsApi().wanted.delete(0))
    assert '[]' == pickle_api_result(ItemsApi().wanted.get())
Esempio n. 16
0
def test_get_wanted_single_item():
    autosubliminal.WANTEDQUEUE = []
    autosubliminal.WANTEDQUEUE.append(wanted_item)
    assert wanted_item_json == pickle_api_result(ItemsApi().wanted.get(0))
Esempio n. 17
0
def test_get_downloaded_zero_items(mocker):
    mocker.patch.object(LastDownloadsDb, 'get_last_downloads', return_value=[downloaded_item])
    assert '[]' == pickle_api_result(ItemsApi().downloaded.get(0))
def test_get_scheduler():
    autosubliminal.SCHEDULERS = {'MyScheduler1': MyScheduler('MyScheduler1')}
    assert scheduler_json == pickle_api_result(SchedulersApi().get('MyScheduler1'))
def test_get_movie_settings(mocker):
    mocker.patch.object(MovieSettingsDb, 'get_movie_settings', return_value=movie_settings_1)
    assert movie_settings_1_json == pickle_api_result(MoviesApi().settings.get('tt1'))
Esempio n. 20
0
def test_get_scheduler():
    autosubliminal.SCHEDULERS = {'MyScheduler1': MyScheduler('MyScheduler1')}
    assert scheduler_json == pickle_api_result(
        SchedulersApi().get('MyScheduler1'))
def test_get_movies(mocker):
    mocker.patch.object(MovieDetailsDb, 'get_all_movies', return_value=[movie_details_1, movie_details_2])
    mocker.patch.object(MovieSettingsDb, 'get_movie_settings', side_effect=[movie_settings_1, movie_settings_2])
    assert movies_json == pickle_api_result(MoviesApi().get())
Esempio n. 22
0
def test_get_shows(mocker):
    mocker.patch.object(ShowDetailsDb, 'get_all_shows', return_value=[show_details_1, show_details_2])
    mocker.patch.object(ShowEpisodeDetailsDb, 'get_show_episodes',
                        side_effect=[[show_episode_details_1_1], [show_episode_details_2_1, show_episode_details_2_2]])
    mocker.patch.object(ShowSettingsDb, 'get_show_settings', side_effect=[show_settings_1, show_settings_2])
    assert shows_json == pickle_api_result(ShowsApi().get())
Esempio n. 23
0
def test_get_show_settings(mocker):
    mocker.patch.object(ShowSettingsDb,
                        'get_show_settings',
                        return_value=show_settings_1)
    assert show_settings_1_json == pickle_api_result(
        ShowsApi().settings.get('1'))
Esempio n. 24
0
def test_get_show_settings(mocker):
    mocker.patch.object(ShowSettingsDb, 'get_show_settings', return_value=show_settings_1)
    assert show_settings_1_json == pickle_api_result(ShowsApi().settings.get('1'))