Exemplo n.º 1
0
def test_write_chapters_to_file(intro_file, tmpdir, monkeypatch, mock):
    def check_chapter(cmd):
        text = subprocess.check_output(cmd)
        chapter_info = json.loads(text)
        if chapter_info.get('chapters'):
            return True
        return False

    if os.name == 'nt':
        fn = '"%s"' % str(intro_file)
    else:
        fn = str(intro_file)
    # Confirm that no chapters exists in that file.
    cmd = ['ffprobe', '-i', fn, '-print_format', 'json', '-show_chapters', '-loglevel', 'error']
    assert check_chapter(cmd) is False

    f = tmpdir.join('hello.mkv')
    shutil.copyfile(intro_file, f)
    root = str(tmpdir)
    mock.patch('edl.os.path.isfile', lambda k: True)
    monkeypatch.setattr(edl, 'create_edl_path', lambda k: os.path.join(root, 'hello.edl'))

    edl_file = edl.write_edl('hello.mkv', [[1, 2, 3]])
    modified_file = edl.write_chapters_to_file(str(f), input_edl=edl_file)

    new_cmd = list(cmd)

    if os.name == 'nt':
        fn_mod = '"%s"' % str(modified_file)
    else:
        fn_mod = str(modified_file)

    new_cmd[2] = fn_mod

    assert check_chapter(new_cmd)
Exemplo n.º 2
0
def test_write_edl(tmpdir, monkeypatch, mock):
    root = str(tmpdir)
    mock.patch('edl.os.path.isfile', lambda k: True)
    monkeypatch.setattr(edl, 'create_edl_path', lambda k: os.path.join(root, 'hello.edl'))

    edl_file = edl.write_edl('hello.mkv', [[1,2,3]])

    with open(edl_file, 'r') as f:
        result = f.read()
        assert result == '1    2    3\n'