예제 #1
0
def test_equality():
    instance = Video("foo.mkv", "/not-a-real-path/bar")
    duplicate = Video("foo.mkv", "/not-a-real-path/bar")
    different_video = Video("bar.mkv", "/not-a-real-path/bar")
    different_path = Video("foo.mkv", "/not-a-real-path/baz")
    not_a_video = "I'm not a video!"

    assert instance == duplicate
    assert instance != different_video
    assert instance != different_path
    with pytest.raises(AssertionError):
        assert instance == not_a_video
예제 #2
0
def test_quality_setter_happy_path():
    v = Video("foo.mkv", "./foo")
    v.quality = "1080p"
    assert v.quality == "1080p"
    v.quality = "720p"
    assert v.quality == "720p"
    v.quality = "SD"
    assert v.quality == "SD"
예제 #3
0
def test_refresh(mock_needs_refresh, mock_get_size, mock_validator, mock_media_info):
    expected_codec = Codec("HEVC")
    mock_media_info.parse.return_value = metadata_return()
    mock_validator().quality_similar_to.return_value = "1080p"

    v = Video("foo.mkv", "/not-a-real-path/bar")
    v.refresh()

    assert v.codec == expected_codec
    assert v.quality == "1080p"
    assert v.size == 12345
예제 #4
0
def test_refresh_failure(mock_validator, mock_stat, mock_media_info):
    mock_stat.return_value = stat_return()
    metadata = metadata_return()
    for track in metadata.tracks:
        track.track_type = "not-video"
    mock_media_info.parse.return_value = metadata
    mock_validator().quality_similar_to.return_value = "1080p"

    v = Video("foo.mkv", "/not-a-real-path/bar")
    with pytest.raises(RuntimeError):
        v.refresh()
def target():
    audio_settings = AudioSettings(codec=Codec("AAC"), channels=2, bitrate=120)

    video_settings = VideoSettings(codec=Codec("HEVC"),
                                   quality=25,
                                   preset="slow",
                                   encoder="software")

    return VideoProcessor(
        video=Video("bar.mkv", "/asdf/foo"),
        video_settings=video_settings,
        audio_settings=audio_settings,
        container="asdf",
        in_place=False,
        dry_run=False,
    )
예제 #6
0
def test_minimal():
    v = Video("foo.mkv", "/not-a-real-path/bar")
    assert v.name == "foo.mkv"
    assert v.dir_path == "/not-a-real-path/bar"
예제 #7
0
def test_codec_setter():
    v = Video("foo.mkv", "./foo")
    codec = Codec("foo", "bar", "baz")
    v.codec = codec
    assert v.codec == codec
예제 #8
0
def test_codec_setter_invalid_type():
    v = Video("foo.mkv", "./foo")
    with pytest.raises(TypeError):
        v.codec = "not-a-codec"
예제 #9
0
def test_quality_setter_failure():
    v = Video("foo.mkv", "./foo")
    with pytest.raises(AttributeError):
        v.quality = "not-a-real-quality"
예제 #10
0
def test_refresh_not_required(mock_needs_refresh, mock_validator, mock_parse):
    v = Video("foo.mkv", "/not-a-real-path/bar")
    v.refresh()
    assert mock_parse.called is False
예제 #11
0
def test_quality_setter_default():
    v = Video("foo.mkv", "./foo")
    v.quality = None
    assert v.quality == "Unknown"
예제 #12
0
def test_dir_path_setter():
    v = Video("foo.mkv", "./foo")
    assert v.dir_path == f"{os.getcwd()}/foo"
예제 #13
0
def test_get_video_processor(mock_video_processor, target):
    result = target._get_video_processor(Video("bar.mkv", "/tmp/foo"))
    mock_video_processor.assert_called()
    assert isinstance(result, NonCallableMagicMock)
예제 #14
0
def test_full_path():
    v = Video("foo.mkv", "/not-a-real-path/bar")
    assert v.full_path == "/not-a-real-path/bar/foo.mkv"
예제 #15
0
def test_get_size(mock_stat):
    mock_stat.return_value = stat_return()
    v = Video("foo.mkv", "/not-a-real-path/bar", size=555)
    assert v._get_size() == 12345
예제 #16
0
def test_needs_refresh_false(mock_stat):
    mock_stat.return_value = 12345
    v = Video("foo.mkv", "/not-a-real-path/bar", size=12345)
    assert v._needs_refresh() is False
예제 #17
0
def test_needs_refresh_size_different(mock_stat):
    mock_stat.return_value = stat_return()
    v = Video("foo.mkv", "/not-a-real-path/bar", size=1)
    assert v._needs_refresh() is True