Esempio n. 1
0
def test_json_conversion(mock_writer, mock_convert):
    """
    TEST JSON
    """
    infolder, outfolder = str(INFILES_JSON), str(MAIN_PATH)
    informat = "srt"
    args = [
        "--i", infolder, "--f", informat, "--t", "textgrid", "--out", outfolder
    ]
    res = vars(arg_parser.parse_args(args))
    assert res["strict"] is True
    assert res["input_path"] == str(INFILES_JSON)
    assert str(res["output_path"]) == str(MAIN_PATH)
    with pytest.raises(ValueError):
        main(**res)
    informat = "rev"
    args = ["--i", infolder, "--f", informat, "--t", "textgrid"]
    res = vars(arg_parser.parse_args(args))
    main(**res)
    assert mock_writer.call_count == len(os.listdir(res["input_path"]))
    assert mock_convert.call_count == len(os.listdir(res["input_path"]))
Esempio n. 2
0
def test_srt_conversion(mock_writer, mock_convert):
    """
    TEST SRT
    """
    infolder, outfolder = str(INFILES_SRT), str(MAIN_PATH)
    informat = "srt"
    args = [
        "--i", infolder, "--f", informat, "--t", "textgrid", "--out", outfolder
    ]
    res = vars(arg_parser.parse_args(args))
    assert res["strict"] is True
    assert res["input_path"] == infolder
    assert str(res["output_path"]) == str(MAIN_PATH)
    main(**res)
    assert mock_writer.call_count == len(os.listdir(res["input_path"]))
    assert mock_convert.call_count == len(os.listdir(res["input_path"]))
Esempio n. 3
0
def test_darla_conversion(mock_writer, mock_convert):
    """
    """
    for ext, path in FORMAT_DICT.items():
        infolder, outfolder = str(path), str(MAIN_PATH)
        informat = ext
        args = [
            "--i", infolder, "--f", informat, "--t", "darla", "--out",
            outfolder
        ]
        res = vars(arg_parser.parse_args(args))
        assert res["strict"] is True
        assert res["input_path"] == str(path)
        assert str(res["output_path"]) == str(MAIN_PATH)
        main(**res)
        assert mock_writer.call_count == len(os.listdir(res["input_path"]))
        assert mock_convert.call_count == len(os.listdir(res["input_path"]))
        mock_writer.call_count = 0
        mock_convert.call_count = 0
Esempio n. 4
0
def test_file_output_single(mock_writer, mock_convert):
    """
    """
    for ext, path in FORMAT_DICT.items():
        infolder, outfile = str(path), str(MAIN_PATH / "test.txt")
        infile = os.listdir(infolder)[0]
        informat = ext
        args = [
            "--i", infile, "--f", informat, "--t", "darla", "--out", outfile
        ]
        res = vars(arg_parser.parse_args(args))
        assert res["strict"] is True
        assert res["input_path"] == str(infile)
        assert str(res["output_path"]) == str(outfile)
        assert str(res["output_path"]) == str(MAIN_PATH / "test.txt")
        main(**res)
        assert mock_writer.call_count == 1
        assert mock_convert.call_count == 1
        mock_writer.call_count = 0
        mock_convert.call_count = 0
Esempio n. 5
0
import logging
log = logging.getLogger(__name__)
log.addHandler(logging.StreamHandler())

from textgrid_convert.ttextgrid_convert import main
from textgrid_convert.ArgParser import  arg_parser

current_args = arg_parser.parse_args()
log.debug("Current args %s " %current_args)
main(**vars(current_args))