def test_legal(self):
     with h5py.File(data_utils.std_beps_path, mode='r') as h5_f:
         h5_main = h5_f['/Raw_Measurement/source_main']
         expected_groups = [
             h5_f['/Raw_Measurement/source_main-Fitter_000'],
             h5_f['/Raw_Measurement/source_main-Fitter_001']
         ]
         ret_val = prov_utils.find_results_groups(h5_main, 'Fitter')
         self.assertEqual(set(ret_val), set(expected_groups))
    def test_results_in_diff_file_invalid_type(self):
        file_path = 'test.h5'
        data_utils.delete_existing_file(file_path)
        with h5py.File(file_path, mode='w') as h5_f:
            h5_main = h5_f.create_dataset('Main', data=[1, 2, 3])
            with self.assertRaises(TypeError):
                _ = prov_utils.find_results_groups(h5_main,
                                                   'Tool',
                                                   h5_parent_group=h5_main)

        os.remove(file_path)
    def test_results_in_diff_file(self):
        file_path = 'test.h5'
        data_utils.delete_existing_file(file_path)

        new_path = 'new.h5'
        data_utils.delete_existing_file(new_path)

        with h5py.File(file_path, mode='w') as h5_f:
            h5_main = h5_f.create_dataset('Main', data=[1, 2, 3])
            with h5py.File(new_path, mode='w') as h5_f_2:
                grp_1 = h5_f_2.create_group('Main-Tool_000')
                grp_2 = h5_f_2.create_group('Main-Tool_001')
                grps = prov_utils.find_results_groups(h5_main,
                                                      'Tool',
                                                      h5_parent_group=h5_f_2)
                self.assertEqual(set([grp_1, grp_2]), set(grps))

        os.remove(file_path)
        os.remove(new_path)
 def test_no_such_tool(self):
     with h5py.File(data_utils.std_beps_path, mode='r') as h5_f:
         h5_main = h5_f['/Raw_Measurement/source_main']
         ret_val = prov_utils.find_results_groups(h5_main, 'Blah')
         self.assertEqual(len(ret_val), 0)
 def test_not_string(self):
     with h5py.File(data_utils.std_beps_path, mode='r') as h5_f:
         h5_main = h5_f['/Raw_Measurement/source_main']
         with self.assertRaises(TypeError):
             _ = prov_utils.find_results_groups(h5_main, np.arange(5))
 def test_no_dset(self):
     with h5py.File(data_utils.std_beps_path, mode='r') as h5_f:
         with self.assertRaises(TypeError):
             _ = prov_utils.find_results_groups(h5_f, 'Fitter')