Skip to content
Snippets Groups Projects
Commit 896cba0d authored by Thomas Jürges's avatar Thomas Jürges
Browse files

Task SSB-42: Create the temp HDF5 file name before a test is run

parent 82c183e5
No related branches found
No related tags found
1 merge request!44Merge back holography to master
......@@ -12,12 +12,21 @@ path_to_test_data = '/home/thomas/workspace.astron/data/holography'
class TestHolographyDatasetClass(unittest.TestCase):
new_test_data_file = None
hdf5_data_file = None
holography_dataset_test_two = None
def tearDown(self):
if self.new_test_data_file is not None:
os.unlink(self.new_test_data_file)
@classmethod
def setUpClass(cls):
# Create an empty temporary data file
(fd, cls.hdf5_data_file) = tempfile.mkstemp(suffix = ".hdf5")
os.close(fd)
@classmethod
def tearDownClass(cls):
if cls.hdf5_data_file is not None:
print("**** %s " % (cls.hdf5_data_file))
# os.unlink(cls.hdf5_data_file)
# def test_one(self):
# holist = HolographyObservation.list_observations_in_path(path_to_test_data)
# hbsflist = HolographySpecification.list_bsf_files_in_path(path_to_test_data)
......@@ -36,22 +45,19 @@ class TestHolographyDatasetClass(unittest.TestCase):
for hbsf in hbsflist:
hbsf.read_file()
ho_per_ms = [(hbsf, ho) for hbsf, ho in zip(hbsflist, holist)]
holography_dataset = HolographyDataset()
holography_dataset.load_from_beam_specification_and_ms('CS013HBA0', ho_per_ms)
# Create an empty temporary data file
(fd, self.new_test_data_file) = tempfile.mkstemp(suffix = ".hdf5")
print "**** %s " % (self.new_test_data_file)
os.close(fd)
self.holography_dataset_test_two = HolographyDataset()
self.holography_dataset_test_two.load_from_beam_specification_and_ms(
'CS013HBA0', ho_per_ms)
# Now store the MS data in an HDF5 file.
holography_dataset.store_to_file(self.new_test_data_file)
self.holography_dataset_test_two.store_to_file(self.hdf5_data_file)
# def test_three(self):
# # Read the MS data from an HDF5 file.
# holography_dataset = HolographyDataset.load_from_file(self.new_test_data_file)
# print holography_dataset
def test_three(self):
# Read the MS data from an HDF5 file.
holography_dataset_test_three = HolographyDataset.load_from_file(self.hdf5_data_file)
print(holography_dataset_test_three)
self.assertEqual(holography_dataset_test_three, self.holography_dataset_test_two)
if __name__ == '__main__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment