Пример #1
0
def test_provider_pool_list_subtitles(episodes, mock_providers):
    pool = ProviderPool()
    subtitles = pool.list_subtitles(episodes['bbt_s07e05'], {Language('eng')})
    assert sorted(subtitles) == ['addic7ed', 'legendastv', 'opensubtitles', 'podnapisi', 'shooter', 'thesubdb',
                                 'tvsubtitles']
    for provider in subtitles:
        assert provider_manager[provider].plugin.initialize.called
        assert provider_manager[provider].plugin.list_subtitles.called
Пример #2
0
def test_provider_pool_list_subtitles(episodes, mock_providers):
    pool = ProviderPool()
    subtitles = pool.list_subtitles(episodes['bbt_s07e05'], {Language('eng')})
    assert sorted(subtitles) == ['addic7ed', 'legendastv', 'opensubtitles', 'podnapisi', 'shooter', 'thesubdb',
                                 'tvsubtitles']
    for provider in subtitles:
        assert provider_manager[provider].plugin.initialize.called
        assert provider_manager[provider].plugin.list_subtitles.called
Пример #3
0
def test_provider_pool_list_subtitles_provider(episodes, mock_providers):
    pool = ProviderPool()
    subtitles = pool.list_subtitles_provider('tvsubtitles',
                                             episodes['bbt_s07e05'],
                                             {Language('eng')})
    assert subtitles == ['tvsubtitles']
    assert provider_manager['tvsubtitles'].plugin.initialize.called
    assert provider_manager['tvsubtitles'].plugin.list_subtitles.called
Пример #4
0
def test_download_bad_subtitle(movies):
    pool = ProviderPool(provider_configs={
        'legendastv': {
            'username': '******',
            'password': '******'
        }
    })
    subtitles = pool.list_subtitles_provider('legendastv',
                                             movies['man_of_steel'],
                                             {Language('eng')})
    subtitle = subtitles[0]
    subtitle.archive.content._rarfile.truncate(200)

    pool.download_subtitle(subtitle)

    assert subtitle.content is None
    assert subtitle.is_valid() is False
Пример #5
0
def _get_provider_pool():
    # Create a new provider pool with our settings
    # If we don't have any providers configured, don't create the pool
    if autosubliminal.SUBLIMINALPROVIDERS:
        # Load the Addic7ed provider cache (if needed) with our Addic7ed show name mappings
        if 'addic7ed' in ','.join(autosubliminal.SUBLIMINALPROVIDERS):
            provider_cache.fill_addic7ed_show_id_cache()
        # Create the pool
        return ProviderPool(providers=autosubliminal.SUBLIMINALPROVIDERS,
                            provider_configs=autosubliminal.SUBLIMINALPROVIDERCONFIGS)
    else:
        return None
Пример #6
0
def test_provider_pool_list_subtitles_provider(episodes, mock_providers):
    pool = ProviderPool()
    subtitles = pool.list_subtitles_provider('tvsubtitles', episodes['bbt_s07e05'], {Language('eng')})
    assert subtitles == ['tvsubtitles']
    assert provider_manager['tvsubtitles'].plugin.initialize.called
    assert provider_manager['tvsubtitles'].plugin.list_subtitles.called
Пример #7
0
def test_provider_pool_iter(mock_providers):
    pool = ProviderPool()
    assert len(list(pool)) == 0
    pool['tvsubtitles']
    assert len(list(pool)) == 1
Пример #8
0
def test_provider_pool_del_keyerror():
    pool = ProviderPool()
    with pytest.raises(KeyError):
        del pool['addic7ed']
Пример #9
0
def test_provider_pool_get_keyerror():
    pool = ProviderPool()
    with pytest.raises(KeyError):
        pool['de7cidda']
Пример #10
0
def test_download_bad_subtitle(movies):
    pool = ProviderPool()
    subtitles = pool.list_subtitles_provider('legendastv', movies['man_of_steel'], {Language('eng')})
    pool.download_subtitle(subtitles[0])
    assert subtitles[0].content is None
    assert subtitles[0].is_valid() is False