def test_scan_videos(movies, tmpdir, monkeypatch): man_of_steel = tmpdir.ensure('movies', movies['man_of_steel'].name) tmpdir.ensure('movies', '.private', 'sextape.mkv') tmpdir.ensure('movies', '.hidden_video.mkv') tmpdir.ensure('movies', movies['enders_game'].name) tmpdir.ensure('movies', os.path.splitext(movies['enders_game'].name)[0] + '.nfo') tmpdir.ensure('movies', 'watched', dir=True) tmpdir.join('movies', 'watched', os.path.split(movies['man_of_steel'].name)[1]).mksymlinkto(man_of_steel) mock_scan_video = Mock() monkeypatch.setattr('subliminal.video.scan_video', mock_scan_video) monkeypatch.chdir(str(tmpdir)) videos = scan_videos('movies') kwargs = dict(subtitles=True, embedded_subtitles=True) calls = [((os.path.join('movies', movies['man_of_steel'].name),), kwargs), ((os.path.join('movies', movies['enders_game'].name),), kwargs)] assert len(videos) == len(calls) assert mock_scan_video.call_count == len(calls) mock_scan_video.assert_has_calls(calls, any_order=True)
def test_scan_videos_path_is_not_a_directory(movies, tmpdir, monkeypatch): monkeypatch.chdir(str(tmpdir)) tmpdir.ensure(movies['man_of_steel'].name) with pytest.raises(ValueError) as excinfo: scan_videos(movies['man_of_steel'].name) assert str(excinfo.value) == 'Path is not a directory'
def test_scan_videos_path_does_not_exist(movies): with pytest.raises(ValueError) as excinfo: scan_videos(movies['man_of_steel'].name) assert str(excinfo.value) == 'Path does not exist'