Exemplo n.º 1
0
def test_preprocess_file_options(metplus_config, filename, data_type,
                                 allow_dir, expected):
    config = metplus_config()
    if filename == 'dir':
        filename = config.getdir('METPLUS_BASE')
        expected = filename
    result = util.preprocess_file(filename, data_type, config, allow_dir)
    assert (result == expected)
Exemplo n.º 2
0
def test_preprocess_file_unzipped():
    conf = metplus_config()
    stage_dir = conf.getdir('STAGING_DIR',
                            os.path.join(conf.getdir('OUTPUT_BASE'), "stage"))
    filepath = conf.getdir(
        'METPLUS_BASE') + "/internal_tests/data/zip/testfile4.txt"
    outpath = util.preprocess_file(filepath, None, conf)
    assert (filepath == outpath and os.path.exists(outpath))
Exemplo n.º 3
0
def test_preprocess_file_stage(metplus_config, filename, ext):
    conf = metplus_config()
    metplus_base = conf.getdir('METPLUS_BASE')
    stage_dir = conf.getdir('STAGING_DIR',
                            os.path.join(conf.getdir('OUTPUT_BASE'), 'stage'))
    filepath = os.path.join(metplus_base, filename + ext)
    if ext:
        stagepath = stage_dir + os.path.join(metplus_base, filename)
        if os.path.exists(stagepath):
            os.remove(stagepath)
    else:
        stagepath = filepath

    outpath = util.preprocess_file(filepath, None, conf)
    assert (stagepath == outpath and os.path.exists(outpath))
Exemplo n.º 4
0
def test_preprocess_file_none():
    conf = metplus_config()
    outpath = util.preprocess_file(None, None, conf)
    assert (outpath is None)