Ejemplo n.º 1
0
def test_video_exists_age(movies, tmpdir, monkeypatch):
    monkeypatch.chdir(str(tmpdir))
    video = movies['man_of_steel']
    tmpdir.ensure(video.name).setmtime(
        timestamp(datetime.utcnow() - timedelta(days=3)))
    assert video.exists
    assert timedelta(days=3) < video.age < timedelta(days=3, seconds=1)
Ejemplo n.º 2
0
def test_scan_videos_age(movies, tmpdir, monkeypatch):
    tmpdir.ensure('movies', movies['man_of_steel'].name)
    tmpdir.ensure('movies', movies['enders_game'].name).setmtime(
        timestamp(datetime.utcnow() - timedelta(days=10)))

    # mock scan_video and scan_archive with the correct types
    mock_video = Mock(subtitle_languages=set())
    mock_scan_video = Mock(return_value=mock_video)
    monkeypatch.setattr('subliminal.core.scan_video', mock_scan_video)
    mock_scan_archive = Mock(return_value=mock_video)
    monkeypatch.setattr('subliminal.core.scan_archive', mock_scan_archive)
    monkeypatch.chdir(str(tmpdir))
    videos = scan_videos('movies', age=timedelta(days=7))

    # general asserts
    assert len(videos) == 1
    assert mock_scan_video.call_count == 1
    assert mock_scan_archive.call_count == 0

    # scan_video calls
    kwargs = dict()
    scan_video_calls = [
        ((os.path.join('movies', movies['man_of_steel'].name), ), kwargs)
    ]
    mock_scan_video.assert_has_calls(scan_video_calls, any_order=True)
Ejemplo n.º 3
0
def test_scan_videos_age(movies, tmpdir, monkeypatch):
    tmpdir.ensure('movies', movies['man_of_steel'].name)
    tmpdir.ensure('movies', movies['enders_game'].name).setmtime(timestamp(datetime.utcnow() - timedelta(days=10)))

    # mock scan_video and scan_archive with the correct types
    mock_video = Mock(subtitle_languages=set())
    mock_scan_video = Mock(return_value=mock_video)
    monkeypatch.setattr('subliminal.core.scan_video', mock_scan_video)
    mock_scan_archive = Mock(return_value=mock_video)
    monkeypatch.setattr('subliminal.core.scan_archive', mock_scan_archive)
    monkeypatch.chdir(str(tmpdir))
    videos = scan_videos('movies', age=timedelta(days=7))

    # general asserts
    assert len(videos) == 1
    assert mock_scan_video.call_count == 1
    assert mock_scan_archive.call_count == 0

    # scan_video calls
    kwargs = dict()
    scan_video_calls = [((os.path.join('movies', movies['man_of_steel'].name),), kwargs)]
    mock_scan_video.assert_has_calls(scan_video_calls, any_order=True)
Ejemplo n.º 4
0
def test_video_exists_age(movies, tmpdir, monkeypatch):
    monkeypatch.chdir(str(tmpdir))
    video = movies["man_of_steel"]
    tmpdir.ensure(video.name).setmtime(timestamp(datetime.utcnow() - timedelta(days=3)))
    assert video.exists
    assert timedelta(days=3) < video.age < timedelta(days=3, seconds=1)