Ejemplo n.º 1
0
def test_video(settings, tmpdir):
    settings['destination'] = str(tmpdir)
    m = Video('example video.ogv', 'video', settings)
    file_path = join('video', 'example video.webm')
    assert str(m) == file_path
    assert m.dst_path == join(settings['destination'], file_path)

    os.makedirs(join(settings['destination'], 'video', 'thumbnails'))
    assert m.thumbnail == join('thumbnails', 'example%20video.tn.jpg')
    assert os.path.isfile(m.thumb_path)
Ejemplo n.º 2
0
def test_video(settings, tmpdir):
    settings['destination'] = str(tmpdir)
    m = Video('stallman software-freedom-day-low.ogv', 'video', settings)
    file_path = join('video', 'stallman software-freedom-day-low.webm')
    assert str(m) == file_path
    assert m.dst_path == join(settings['destination'], file_path)

    os.makedirs(join(settings['destination'], 'video', 'thumbnails'))
    assert m.thumbnail == join('thumbnails',
                               'stallman software-freedom-day-low.tn.jpg')
    assert os.path.isfile(m.thumb_path)
Ejemplo n.º 3
0
def test_media_orig(settings):
    settings['keep_orig'] = False
    m = Media('11.jpg', 'dir1/test1', settings)
    assert m.big is None

    settings['keep_orig'] = True
    m = Image('11.jpg', 'dir1/test1', settings)
    assert m.big == 'original/11.jpg'

    m = Video('file.ogv', 'video', settings)
    assert m.filename == 'file.webm'
    assert m.big == 'original/file.ogv'
Ejemplo n.º 4
0
def test_metadata(tmpdir):
    base, ext = os.path.splitext(TEST_VIDEO)

    settings = create_settings(
        video_format='ogv',
        use_orig=True,
        orig_link=True,
        source=os.path.join(SRCDIR, 'video'),
        destination=str(tmpdir),
    )
    video = Video(TEST_VIDEO, '.', settings)
    assert video.meta == {'date': ['2020-01-01T09:00:00']}
    assert video.date == datetime(2020, 1, 1, 9, 0)
Ejemplo n.º 5
0
def test_media_orig(settings, tmpdir):
    settings['keep_orig'] = False
    m = Media('11.jpg', 'dir1/test1', settings)
    assert m.big is None

    settings['keep_orig'] = True
    settings['destination'] = str(tmpdir)

    m = Image('11.jpg', 'dir1/test1', settings)
    assert m.big == 'original/11.jpg'

    m = Video('stallman software-freedom-day-low.ogv', 'video', settings)
    assert m.filename == 'stallman software-freedom-day-low.webm'
    assert m.big == 'original/stallman software-freedom-day-low.ogv'
    assert os.path.isfile(join(settings['destination'], m.path, m.big))
Ejemplo n.º 6
0
def test_process_video(tmpdir):
    base, ext = os.path.splitext(TEST_VIDEO)

    settings = create_settings(video_format='ogv',
                               use_orig=True,
                               orig_link=True,
                               source=os.path.join(SRCDIR, 'video'),
                               destination=str(tmpdir))
    video = Video(TEST_VIDEO, '.', settings)
    process_video(video)
    dstfile = str(tmpdir.join(base + '.ogv'))
    assert os.path.realpath(dstfile) == SRCFILE

    settings = create_settings(video_format='mjpg')
    assert process_video(video) == Status.FAILURE

    settings = create_settings(thumb_video_delay=-1)
    assert process_video(video) == Status.FAILURE
Ejemplo n.º 7
0
def test_media_orig(settings, tmpdir):
    settings['keep_orig'] = False
    m = Media('11.jpg', 'dir1/test1', settings)
    assert m.big is None

    settings['keep_orig'] = True
    settings['destination'] = str(tmpdir)

    m = Image('11.jpg', 'dir1/test1', settings)
    assert m.big == 'original/11.jpg'

    m = Video('example video.ogv', 'video', settings)
    assert m.filename == 'example video.webm'
    assert m.big_url == 'original/example%20video.ogv'
    assert os.path.isfile(join(settings['destination'], m.path, m.big))

    settings['use_orig'] = True

    m = Image('21.jpg', 'dir1/test2', settings)
    assert m.big == '21.jpg'