def test_delete_unwanted_subtitles__keep_only_wanted_disabled(monkeypatch, tmpdir): # Given monkeypatch.setattr(app, 'SUBTITLES_MULTI', True) monkeypatch.setattr(app, 'SUBTITLES_KEEP_ONLY_WANTED', False) monkeypatch.setattr(app, 'SUBTITLES_LANGUAGES', ['pob', 'eng']) subtitle_pob = text_type(tmpdir.ensure('video.pt-BR.srt')) subtitle_fre = text_type(tmpdir.ensure('video.fr.srt')) # When sut.delete_unwanted_subtitles(tmpdir, subtitle_pob) sut.delete_unwanted_subtitles(tmpdir, subtitle_fre) # Then assert os.path.exists(subtitle_pob) assert os.path.exists(subtitle_fre)
def test_delete_unwanted_subtitles__keep_only_wanted_disabled(monkeypatch, tmpdir): # Given monkeypatch.setattr(app, 'SUBTITLES_MULTI', True) monkeypatch.setattr(app, 'SUBTITLES_KEEP_ONLY_WANTED', False) monkeypatch.setattr(app, 'SUBTITLES_LANGUAGES', ['pob', 'eng']) subtitle_pob = text_type(tmpdir.ensure('video.pt-BR.srt')) subtitle_fre = text_type(tmpdir.ensure('video.fr.srt')) # When sut.delete_unwanted_subtitles(tmpdir, subtitle_pob) sut.delete_unwanted_subtitles(tmpdir, subtitle_fre) # Then assert os.path.exists(subtitle_pob) assert os.path.exists(subtitle_fre)
def test_delete_unwanted_subtitles__existing_subtitles_in_unwanted_languages(monkeypatch, tmpdir): # Given monkeypatch.setattr(app, 'SUBTITLES_MULTI', True) monkeypatch.setattr(app, 'SUBTITLES_KEEP_ONLY_WANTED', True) monkeypatch.setattr(app, 'SUBTITLES_LANGUAGES', ['pob', 'eng']) subtitle_pob = text_type(tmpdir.ensure('video.pt-BR.srt')) subtitle_eng = text_type(tmpdir.ensure('video.en.srt')) subtitle_fre = text_type(tmpdir.ensure('video.fr.srt')) some_file = text_type(tmpdir.ensure('video.fr.nfo')) # When sut.delete_unwanted_subtitles(text_type(tmpdir), subtitle_pob) sut.delete_unwanted_subtitles(text_type(tmpdir), subtitle_eng) sut.delete_unwanted_subtitles(text_type(tmpdir), subtitle_fre) # Then assert os.path.exists(subtitle_pob) assert os.path.exists(subtitle_eng) assert not os.path.exists(subtitle_fre) assert os.path.exists(some_file)
def test_delete_unwanted_subtitles__existing_subtitles_in_unwanted_languages(monkeypatch, tmpdir): # Given monkeypatch.setattr(app, 'SUBTITLES_MULTI', True) monkeypatch.setattr(app, 'SUBTITLES_KEEP_ONLY_WANTED', True) monkeypatch.setattr(app, 'SUBTITLES_LANGUAGES', ['pob', 'eng']) subtitle_pob = text_type(tmpdir.ensure('video.pt-BR.srt')) subtitle_eng = text_type(tmpdir.ensure('video.en.srt')) subtitle_fre = text_type(tmpdir.ensure('video.fr.srt')) some_file = text_type(tmpdir.ensure('video.fr.nfo')) # When sut.delete_unwanted_subtitles(text_type(tmpdir), subtitle_pob) sut.delete_unwanted_subtitles(text_type(tmpdir), subtitle_eng) sut.delete_unwanted_subtitles(text_type(tmpdir), subtitle_fre) # Then assert os.path.exists(subtitle_pob) assert os.path.exists(subtitle_eng) assert not os.path.exists(subtitle_fre) assert os.path.exists(some_file)