コード例 #1
0
def test_config_from_argv_filename_replace(optargs, expected):
    "The filename replacement mapping can be changed."
    for opt in ("-r", "--filename-replace"):
        argv = ["test"]
        for optarg in optargs:
            argv.extend([opt, optarg])
        config = Config.from_argv(argv)
        assert config.filename_replace == expected
コード例 #2
0
def test_config_from_argv_defaults(prefs, expected):
    "A default config is returned when no command-line arguments are given."
    config = Config.from_argv([], prefs=prefs)
    assert config.job_path == expected.job_path
    assert config.filename_replace == expected.filename_replace
    assert config.output_dir == expected.output_dir
    assert config.subcommand == Subcommand.HELP
    assert config.video_dir == expected.video_dir
    assert config.video_ext == expected.video_ext
    assert config.video_filename_format == expected.video_filename_format
コード例 #3
0
    "Deserializing an invalid clip dict results in an error."
    with pytest.raises(Error):
        Clip.from_dict(data)


# pylint: disable=too-many-arguments
@pytest.mark.parametrize(
    "clip,config,date,epoch,title,expected",
    [
        # Clip start time is relative to video time with epoch 0
        (
            Clip.from_dict({
                "time": "1-2",
                "title": "title"
            }),
            Config.default(),
            datetime.datetime(1970, 1, 1),
            datetime.timedelta(),
            "test",
            "1970-01-01 00-00-00 - t+0h00m01s - test - title.mkv",
        ),
        # Clip start time and video time are adjusted with positive epoch
        (
            Clip.from_dict({
                "time": "1-2",
                "title": "title"
            }),
            Config.default(),
            datetime.datetime(1970, 1, 1),
            datetime.timedelta(seconds=1),
            "test",
コード例 #4
0
def test_config_from_argv_output_dir_invalid(path):
    "Invalid paths are rejected."
    with pytest.raises(Error):
        Config.from_argv(["", "--output-dir", path])
コード例 #5
0
def test_config_from_argv_output_dir(opt):
    "The default path to the output clips directory can be changed."
    path = Path("/dev/null")
    config = Config.from_argv(["", opt, str(path)])
    assert config.output_dir == path
コード例 #6
0
def test_config_from_argv_job_path_invalid(path):
    "Invalid paths are rejected."
    with pytest.raises(Error):
        Config.from_argv(["", "--job-path", path])
コード例 #7
0
def test_config_from_argv_job_path(opt):
    "The default path to the job file can be changed."
    path = Path("/dev/null")
    config = Config.from_argv(["", opt, str(path)])
    assert config.job_path == path
コード例 #8
0
def test_config_from_argv_filename_replace_invalid(optarg):
    "Invalid filename replacement arguments are rejected."
    for opt in ("-r", "--filename-replace"):
        with pytest.raises(Error):
            Config.from_argv(["", opt, optarg])
コード例 #9
0
def test_config_from_argv_video_filename_format_invalid(fmt):
    "Invalid filename formats are rejected."
    with pytest.raises(Error):
        Config.from_argv(["", "--video-filename-format", fmt])
コード例 #10
0
def test_config_from_argv_video_filename_format(opt):
    "The default input video filename format can be changed."
    fmt = "%s"
    config = Config.from_argv(["", opt, fmt])
    assert config.video_filename_format == fmt
コード例 #11
0
def test_config_from_argv_video_ext_invalid(ext):
    "Invalid file extensions are rejected."
    with pytest.raises(Error):
        Config.from_argv(["", "--video-ext", ext])
コード例 #12
0
def test_config_from_argv_video_ext(opt):
    "The default input video file extension can be changed."
    ext = "rm"
    config = Config.from_argv(["", opt, ext])
    assert config.video_ext == ext
コード例 #13
0
def test_config_from_argv_video_dir(opt):
    "The default path to the input video directory can be changed."
    path = Path("/dev/null")
    config = Config.from_argv(["", opt, str(path)])
    assert config.video_dir == path
コード例 #14
0
def test_config_from_argv_subcommand_invalid(subcommand_str):
    "Invalid subcommands are rejected."
    with pytest.raises(Error):
        Config.from_argv(["", subcommand_str])
コード例 #15
0
def test_config_from_argv_subcommand(subcommand_str, expected):
    "The subcommand is set from the first non-option argument."
    config = Config.from_argv(["", subcommand_str])
    assert config.subcommand == expected
コード例 #16
0
def test_job_from_dict(data, expected):
    "Jobs are deserialized from dicts correctly."
    job = Job.from_dict(Config.default(), data)
    assert job == expected
コード例 #17
0
def test_job_from_dict_invalid(data):
    "Deserializing an invalid job dict results in an error."
    with pytest.raises(Error):
        Job.from_dict(Config.default(), data)
コード例 #18
0
def test_config_from_argv_output_ext(opt):
    "The default output clip file extension can be changed."
    ext = "rm"
    config = Config.from_argv(["", opt, ext])
    assert config.output_ext == ext