Ejemplo n.º 1
0
def test_save_image_should_work_with_rtmpdump_temp_file_param(tmpdir):
    url = LIVE_RTMP_URL
    output_file_path = str(tmpdir.join('out.jpg'))
    temp_file_path = str(tmpdir.join('temp.flv'))

    shooter = Shooter(**test_shooter_args)
    shooter.save_image(url, output_file_path, temp_file_path)

    assert os.stat(output_file_path).st_size > 0, "output JPG is broken"
Ejemplo n.º 2
0
def test_save_image_should_only_save_jpg(tmpdir):
    url = LIVE_RTMP_URL
    output_file_path = str(tmpdir.join('out.jpg'))

    shooter = Shooter(**test_shooter_args)
    shooter.save_image(url, output_file_path)

    assert tmpdir.listdir() == [output_file_path]
    assert os.stat(output_file_path).st_size > 0, "output JPG is broken"
Ejemplo n.º 3
0
def test_save_image_should_discard_rtmpdump_temp_file(monkeypatch, tmpdir):
    url = LIVE_RTMP_URL
    output_file_path = str(tmpdir.join('out.jpg'))

    def mktemp_mock():
        return str(tmpdir.join('out.flv'))
   
    monkeypatch.setattr(tempfile, 'mktemp', mktemp_mock)
   
    shooter = Shooter(**test_shooter_args)
    shooter.save_image(url, output_file_path)

    assert tmpdir.listdir() == [output_file_path]
Ejemplo n.º 4
0
def test_save_image_should_not_create_rtmpdump_temp_file_if_rtmpdump_fail(monkeypatch, tmpdir):
    url = LIVE_RTMP_URL + '-NOTFOUND'
    output_file_path = str(tmpdir.join('out.jpg'))

    def mktemp_mock():
        return str(tmpdir.join('out.flv'))

    monkeypatch.setattr(tempfile, 'mktemp', mktemp_mock)

    shooter = Shooter(**test_shooter_args)
    try:
        shooter.save_image(url, output_file_path)
        assert False, "ffmpeg should raise an exception because FLV is broken"
    except:
        pass

    assert tmpdir.listdir() == []