Exemplo n.º 1
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()
Exemplo n.º 2
0
def test_struct_missing_tags_attrib():
    config, tags = init('h')
    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')
    assert res.is_text_in_file(logfile, 'should be axes:theta_dark:y:x')
    assert res.is_text_in_file(logfile, 'should be axes:theta_white:y:x')
    assert res.is_text_in_file(logfile, 'attributes are missing in tag /exchange/theta')
    clean()
Exemplo n.º 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()
Exemplo n.º 4
0
def test_struct_missing_tags_attrib():
    config, tags = init('h')
    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')
    assert res.is_text_in_file(logfile, 'should be axes:theta_dark:y:x')
    assert res.is_text_in_file(logfile, 'should be axes:theta_white:y:x')
    assert res.is_text_in_file(
        logfile, 'attributes are missing in tag /exchange/theta')
    clean()
Exemplo n.º 5
0
def test_bad_file():
    config, tags = init('e')
    data_file = "data/test_datax.h5"
    # the file.verify will exit with -1
    try:
        hdf.verify(config, data_file)
    except:
        pass
    time.sleep(1)
    assert res.is_text_in_file(logfile, 'parameter error: file data/test_datax.h5 does not exist')
    clean()
Exemplo n.º 6
0
def test_bad_file():
    config, tags = init('e')
    data_file = "data/test_datax.h5"
    # the file.verify will exit with -1
    try:
        hdf.verify(config, data_file)
    except:
        pass
    time.sleep(1)
    assert res.is_text_in_file(
        logfile, 'parameter error: file data/test_datax.h5 does not exist')
    clean()
Exemplo n.º 7
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()
Exemplo n.º 8
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()
Exemplo n.º 9
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()
Exemplo n.º 10
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()
Exemplo n.º 11
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()
Exemplo n.º 12
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()
Exemplo n.º 13
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()
Exemplo n.º 14
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()
Exemplo n.º 15
0
def hdf(conf, fname):
    """
    HDF file structure verifier.

    Parameters
    ----------
    conf : str
        configuration file name, including path

    file : str
        File Name to verify including path

    Returns
    -------
    boolean


    """

    if dqhdf.verify(conf, fname):
        print('All tags exist and meet conditions')
    else:
        print(
            'Some of the tags do not exist or do not meet conditions, check log file'
        )
Exemplo n.º 16
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()
Exemplo n.º 17
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()
Exemplo n.º 18
0
def test_struct_no_missing():
    config, tags = init('i')
    match = 'missing'
    mod.delete_line_in_file(tags, match)
    match = 'axes'
    mod.delete_line_in_file(tags, match)
    match = 'degrees'
    mod.delete_line_in_file(tags, match)
    assert (hdf.verify(config, data_file))
    time.sleep(1)
    assert res.is_text_in_file(logfile, 'All required tags exist and meet conditions')
    clean
Exemplo n.º 19
0
def test_struct_no_missing():
    config, tags = init('i')
    match = 'missing'
    mod.delete_line_in_file(tags, match)
    match = 'axes'
    mod.delete_line_in_file(tags, match)
    match = 'degrees'
    mod.delete_line_in_file(tags, match)
    assert (hdf.verify(config, data_file))
    time.sleep(1)
    assert res.is_text_in_file(logfile,
                               'All required tags exist and meet conditions')
    clean
Exemplo n.º 20
0
def hdf(conf, fname):
    """
    HDF file structure verifier.

    Parameters
    ----------
    conf : str
        configuration file name, including path

    file : str
        File Name to verify including path

    Returns
    -------
    boolean


    """

    if dqhdf.verify(conf, fname):
        print("All tags exist and meet conditions")
    else:
        print("Some of the tags do not exist or do not meet conditions, check log file")