def test_ge():
    config = init('af')
    data_path = os.path.join(os.getcwd(), "test/data1")
    data_file = os.path.join(os.getcwd(), "test/data/test_data.ge4")
    new_data = os.path.join(data_path, "test_data.ge4")

    find = 'HDF'
    replace = 'GE'
    mod.replace_text_in_file(config, find, replace)
    mod.delete_line_in_file(config, 'extensions')
    mod.add_line_to_file(config, "'extensions' = .ge, .ge4, .ge3")

    if not os.path.exists(data_path):
        os.makedirs(data_path)
    p = Process(target=copy_file, args=(
        data_file,
        new_data,
    ))
    p.start()

    bad_indexes_file = monitor.verify(config, data_path, 1)
    bad_indexes = bad_indexes_file[new_data]
    bad_data = bad_indexes['data']
    assert 1 in bad_data
    assert 2 in bad_data
    assert 3 in bad_data
    assert 4 in bad_data
    clean()
def test_ge_corrupted_file():
    config = init('ag')
    data_path = os.path.join(os.getcwd(),"test/data1")
    data_file = os.path.join(os.getcwd(),"test/data/test_data.h5")
    new_data = os.path.join(data_path,"test_data.ge4")

    find = 'HDF'
    replace = 'GE'
    mod.replace_text_in_file(config, find, replace)
    mod.delete_line_in_file(config, 'extensions')
    mod.add_line_to_file(config, "'extensions' = .ge, .ge4, .ge3")


    if not os.path.exists(data_path):
        os.makedirs(data_path)
    p = Process(target=copy_file, args=(data_file, new_data,))

    data_file = os.path.join(os.getcwd(),"test/data/test_data.ge4")
    new_data = os.path.join(data_path,"test_data1.ge4")
    p1 = Process(target=copy_file, args=(data_file, new_data,))
    p.start()
    p1.start()

    bad_indexes_file = monitor.verify(config, data_path, 1)
    bad_indexes = bad_indexes_file[new_data]
    bad_data = bad_indexes['data']
    assert 1 in bad_data
    assert 2 in bad_data
    assert 3 in bad_data
    assert 4 in bad_data
    clean()
Beispiel #3
0
def test_tags_missing_tags():
    config, tags = init('f')
    find = 'hdf_structure'
    replace = 'hdf_tags'
    mod.replace_text_in_file(config, find, replace)
    hdf.verify(config, data_file)
    time.sleep(1)
    assert res.is_text_in_file(logfile, '/exchange/missing')
    assert res.is_text_in_file(logfile, '/exchange/missing1')
    clean()
Beispiel #4
0
def test_tags_missing_tags():
    config, tags = init('f')
    find = 'hdf_structure'
    replace = 'hdf_tags'
    mod.replace_text_in_file(config, find, replace)
    hdf.verify(config, data_file)
    time.sleep(1)
    assert res.is_text_in_file(logfile, '/exchange/missing')
    assert res.is_text_in_file(logfile, '/exchange/missing1')
    clean()
Beispiel #5
0
def test_tags_no_missing_tags():
    config, tags = init('g')
    find = 'hdf_structure'
    replace = 'hdf_tags'
    mod.replace_text_in_file(config, find, replace)
    match = 'missing'
    mod.delete_line_in_file(tags, match)
    time.sleep(1)
    assert (hdf.verify(config, data_file))
    assert res.is_text_in_file(logfile, 'All required tags exist')
    clean()
Beispiel #6
0
def test_tags_no_missing_tags():
    config, tags = init('g')
    find = 'hdf_structure'
    replace = 'hdf_tags'
    mod.replace_text_in_file(config, find, replace)
    match = 'missing'
    mod.delete_line_in_file(tags, match)
    time.sleep(1)
    assert (hdf.verify(config, data_file))
    assert res.is_text_in_file(logfile, 'All required tags exist')
    clean()
def test_no_limit():
    config = init('ae')
    find = 'limits.json'
    replace = 'limitsx.json'
    mod.replace_text_in_file(config, find, replace)
    # the file.verify will exit with -1
    try:
        monitor.verify(config, None, 1)
    except:
        pass
    time.sleep(1)
    assert res.is_text_in_file(logfile, 'configuration error: file test/schemas/limitsx.json does not exist')
    clean()
Beispiel #8
0
def init(id):
    config = 'test/conf' + id + '.ini'
    config = os.path.join(os.getcwd(), config)
    shutil.copyfile(config_test, config)
    find = 'tags'
    replace = 'tags' + id
    mod.replace_text_in_file(config, find, replace)
    if not os.path.isdir(schemas):
        shutil.copytree(schemas_test, schemas)
    tags = 'test/schemas/tags' + id + '.json'
    tags = os.path.join(os.getcwd(), tags)
    shutil.copyfile(tags_test, tags)
    return config, tags
Beispiel #9
0
def test_conf_error_no_limits():
    config = init('bf')
    find = 'limits'
    replace = 'limitsx'
    mod.replace_text_in_file(config, find, replace)
    # the file.verify will exit with -1
    try:
        acc.verify(config, None, data_type, 1)
    except:
        pass
    time.sleep(1)
    assert res.is_text_in_file(logfile, 'configuration error: limits is not configured')
    clean()
Beispiel #10
0
def test_ge():
    config = init('d')
    find = 'HDF'
    replace = 'GE'
    mod.replace_text_in_file(config, find, replace)
    data_file = os.path.join(os.getcwd(),"test/data/test_data.ge4")
    bad_indexes = data.verify(config, data_file)
    bad_data = bad_indexes['data']
    assert 1 in bad_data
    assert 2 in bad_data
    assert 3 in bad_data
    assert 4 in bad_data
    clean()
Beispiel #11
0
def test_bad_type():
    config, tags = init('d')
    find = 'hdf_structure'
    replace = 'hdf_structurex'
    mod.replace_text_in_file(config, find, replace)
    # the file.verify will exit with -1
    try:
        hdf.verify(config, None)
    except:
        pass
    time.sleep(1)
    assert res.is_text_in_file(logfile, 'configured verification type hdf_structurex is not supported')
    clean()
Beispiel #12
0
def test_conf_error_no_type():
    config, tags = init('c')
    find = 'verification_type'
    replace = 'verification_typex'
    mod.replace_text_in_file(config, find, replace)
    # the file.verify will exit with -1
    try:
        hdf.verify(config, None)
    except:
        pass
    time.sleep(1)
    assert res.is_text_in_file(logfile, 'config error: verification type not configured')
    clean()
Beispiel #13
0
def test_no_schema():
    config, tags = init('b')
    find = 'tags'
    replace = 'tagsx'
    mod.replace_text_in_file(config, find, replace)
    # the file.verify will exit with -1
    try:
        hdf.verify(config, None)
    except:
        pass
    time.sleep(1)
    assert res.is_text_in_file(logfile, 'configuration error: file test/schemas/tagsxb.json does not exist')
    clean()
Beispiel #14
0
def test_conf_error_no_schema():
    config, tags = init('a')
    find = 'schema'
    replace = 'schemax'
    mod.replace_text_in_file(config, find, replace)
    # the file.verify will exit with -1
    try:
        hdf.verify(config, None)
    except:
        pass
    time.sleep(1)
    assert res.is_text_in_file(logfile, 'configuration error: schema is not configured')
    clean()
Beispiel #15
0
def init(id):
    config = 'test/conf' + id + '.ini'
    config =  os.path.join(os.getcwd(),config)
    shutil.copyfile(config_test, config)
    find = 'tags'
    replace = 'tags'+ id
    mod.replace_text_in_file(config, find, replace)
    if not os.path.isdir(schemas):
        shutil.copytree(schemas_test, schemas)
    tags = 'test/schemas/tags' + id + '.json'
    tags = os.path.join(os.getcwd(), tags)
    shutil.copyfile(tags_test, tags)
    return config, tags
def test_conf_error_no_limits():
    config = init('ad')
    find = 'limits'
    replace = 'limitsx'
    mod.replace_text_in_file(config, find, replace)
    # the file.verify will exit with -1
    try:
        monitor.verify(config, None, 1)
    except:
        pass
    time.sleep(1)
    assert res.is_text_in_file(logfile, 'configuration error: limits is not configured')
    clean()
Beispiel #17
0
def test_no_limit():
    config = init('bg')
    find = 'limits.json'
    replace = 'limitsx.json'
    mod.replace_text_in_file(config, find, replace)
    # the file.verify will exit with -1
    try:
        acc.verify(config, None, data_type, 1, True)
    except:
        pass
    time.sleep(1)
    assert res.is_text_in_file(logfile, 'configuration error: file test/schemas/limitsx.json does not exist')
    clean()
Beispiel #18
0
def test_conf_error_no_type():
    config, tags = init('c')
    find = 'verification_type'
    replace = 'verification_typex'
    mod.replace_text_in_file(config, find, replace)
    # the file.verify will exit with -1
    try:
        hdf.verify(config, None)
    except:
        pass
    time.sleep(1)
    assert res.is_text_in_file(
        logfile, 'config error: verification type not configured')
    clean()
Beispiel #19
0
def test_conf_error_no_schema():
    config, tags = init('a')
    find = 'schema'
    replace = 'schemax'
    mod.replace_text_in_file(config, find, replace)
    # the file.verify will exit with -1
    try:
        hdf.verify(config, None)
    except:
        pass
    time.sleep(1)
    assert res.is_text_in_file(
        logfile, 'configuration error: schema is not configured')
    clean()
Beispiel #20
0
def test_no_schema():
    config, tags = init('b')
    find = 'tags'
    replace = 'tagsx'
    mod.replace_text_in_file(config, find, replace)
    # the file.verify will exit with -1
    try:
        hdf.verify(config, None)
    except:
        pass
    time.sleep(1)
    assert res.is_text_in_file(
        logfile,
        'configuration error: file test/schemas/tagsxb.json does not exist')
    clean()
Beispiel #21
0
def test_bad_type():
    config, tags = init('d')
    find = 'hdf_structure'
    replace = 'hdf_structurex'
    mod.replace_text_in_file(config, find, replace)
    # the file.verify will exit with -1
    try:
        hdf.verify(config, None)
    except:
        pass
    time.sleep(1)
    assert res.is_text_in_file(
        logfile,
        'configured verification type hdf_structurex is not supported')
    clean()
def test_no_extentions_interrupt():
    config = init('bb')
    data_path = os.path.join(os.getcwd(),"test/data1")
    new_data = os.path.join(data_path,"INTERRUPT")

    find = 'extensions'
    replace = 'extensionsx'
    mod.replace_text_in_file(config, find, replace)

    if not os.path.exists(data_path):
        os.makedirs(data_path)
    p = Process(target=copy_file, args=(interrupt_file, new_data,))
    p.start()

    bad_indexes = monitor.verify(config, data_path, 2)
    assert len(bad_indexes) is 0
    assert res.is_text_in_file(logfile, 'no file extension specified. Monitoring for all files')
    clean()
Beispiel #23
0
def test_no_extentions_interrupt():
    config = init('bd')
    data_path = os.path.join(os.getcwd(),"test/data1")
    new_data1 = os.path.join(data_path,"INTERRUPT")
    new_data2 = os.path.join(data_path,"INTERRUPT.h5")

    find = 'extensions'
    replace = 'extensionsx'
    mod.replace_text_in_file(config, find, replace)

    if not os.path.exists(data_path):
        os.makedirs(data_path)
    p = Process(target=copy_file, args=(data_file, new_data1, new_data2))
    p.start()

    bad_indexes = acc.verify(config, data_path, data_type, 2, True)
    assert len(bad_indexes) is 0
    assert res.is_text_in_file(logfile, 'no file extension specified. Monitoring for all files')
    clean()
Beispiel #24
0
def test_ge_corrupted_file():
    config = init('ef')
    data_path = os.path.join(os.getcwd(),"test/data1")
    new_data = os.path.join(data_path,"test_data.ge4")

    find = 'HDF'
    replace = 'GE'
    mod.replace_text_in_file(config, find, replace)
    mod.delete_line_in_file(config, 'extensions')
    mod.add_line_to_file(config, "'extensions' = .ge, .ge4, .ge3")


    if not os.path.exists(data_path):
        os.makedirs(data_path)
    p = Process(target=copy_file, args=(data_file, new_data,))
    p.start()

    bad_indexes_file = monitor.verify(config, data_path, 1)
    bad_indexes = bad_indexes_file[new_data]
    assert bad_indexes is None
    assert res.is_text_in_file(logfile, 'GE image size unexpected:')
    clean()
Beispiel #25
0
def test_ge_corrupted_file():
    config = init('gg')
    data_path = os.path.join(os.getcwd(), "test/data1")
    new_data = os.path.join(data_path, "test_data.ge4")

    find = 'HDF'
    replace = 'GE'
    mod.replace_text_in_file(config, find, replace)
    mod.delete_line_in_file(config, 'extensions')
    mod.add_line_to_file(config, "'extensions' = .ge, .ge4, .ge3")

    if not os.path.exists(data_path):
        os.makedirs(data_path)
    p = Process(target=copy_file, args=(
        data_file,
        new_data,
    ))
    p.start()

    bad_indexes_file = monitor.verify(config, data_path, 1)
    bad_indexes = bad_indexes_file[new_data]
    assert bad_indexes is None
    assert res.is_text_in_file(logfile, 'GE image size unexpected:')
    clean()