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()
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()
def test_check_pv(): try: check.pv(config) except: pass time.sleep(1) assert res.is_text_in_file(logfile, 'PV ID32ds:Energy.VAL has value out of range. The value is 4.0 but should be greater_than 10.0') assert res.is_text_in_file(logfile, 'PV S:SRcurrentAI has value out of range. The value is 4.0 but should be greater_than 50.0') clean()
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()
def test_qualitychecks_report_for_file(): config = init('ab') data_path = os.path.join(os.getcwd(),"test/data1") new_data1 = os.path.join(data_path,"test_data1.h5") new_data2 = os.path.join(data_path,"test_data2.h5") 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') bad_indexes_type = bad_indexes[data_type] bad_data1 = bad_indexes_type[new_data1] bad_data2 = bad_indexes_type[new_data2] assert 0 in bad_data1 assert 0 in bad_data2 assert 1 in bad_data1 assert 1 in bad_data2 #assert 3 in bad_data1 #assert 3 in bad_data2 assert 4 in bad_data1 assert 4 in bad_data2 assert not res.is_text_in_file(logfile, 'no file extension specified. Monitoring for all files') clean(new_data1, new_data2)
def test_check_accumulator(): try: check.accumulator(config, "something", "data_white", 1, True) except: pass time.sleep(1) assert res.is_text_in_file(logfile, 'parameter error: directory something does not exist') clean()
def test_bad_file(): data_file = "data/test_datax.h5" # the file.verify will exit with -1 try: data.verify(config_test, 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()
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_bad_directory(): config = init('ac') directory = "bad_dir" # the file.verify will exit with -1 try: monitor.verify(config, directory, 1) except: pass time.sleep(1) assert res.is_text_in_file(logfile, 'parameter error: directory bad_dir does not exist') clean()
def test_bad_directory(): config = init('be') directory = "bad_dir" # the file.verify will exit with -1 try: acc.verify(config, directory, data_type, 1) except: pass time.sleep(1) assert res.is_text_in_file(logfile, 'parameter error: directory bad_dir does not exist') clean()
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
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()
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()
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()
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()
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()
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()
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_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()
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()
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()
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()
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()
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()
def test_qualitychecks_one_report(): config = init('bc') data_path = os.path.join(os.getcwd(),"test/data1") new_data1 = os.path.join(data_path,"test_data3.h5") new_data2 = os.path.join(data_path,"test_data4.h5") 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, False) bad_data = bad_indexes[data_type] assert 0 in bad_data assert 4 in bad_data assert 5 in bad_data assert 9 in bad_data assert not res.is_text_in_file(logfile, 'no file extension specified. Monitoring for all files') clean(new_data1, new_data2)
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()
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()
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()