From 3b1fcf0c55b0df0d254792cdd535e70f73b88413 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20J=C3=BCrges?= <jurges@astron.nl>
Date: Wed, 19 Sep 2018 14:58:14 +0000
Subject: [PATCH] Task SSB-42:  Added HDF5 tests

The tests are not working yet.
---
 .../test/t_holography_dataset_class.py        | 42 +++++++++++++++++--
 1 file changed, 38 insertions(+), 4 deletions(-)

diff --git a/CAL/CalibrationCommon/test/t_holography_dataset_class.py b/CAL/CalibrationCommon/test/t_holography_dataset_class.py
index 83e9b5899b3..c13d4f25e0b 100755
--- a/CAL/CalibrationCommon/test/t_holography_dataset_class.py
+++ b/CAL/CalibrationCommon/test/t_holography_dataset_class.py
@@ -1,24 +1,58 @@
 import logging
 import unittest
+import tempfile
+import os
 from lofar.calibration.common.datacontainers import HolographyDataset, HolographySpecification
 from lofar.calibration.common.datacontainers import HolographyObservation
 
+
 logger = logging.getLogger('t_holography_dataset_class')
 path_to_test_data = '/data/test/HolographyObservation'
+path_to_test_data = '/home/thomas/workspace.astron/data/holography'
 
 
 class TestHolographyDatasetClass(unittest.TestCase):
-    def test_one(self):
+    new_test_data_file = None
+
+    def tearDown(self):
+        if self.new_test_data_file is not None:
+            os.unlink(self.new_test_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)
+#         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)
+#         self.assertEqual(holography_dataset.source_name, '3C 147')
+
+    def test_two(self):
         holist = HolographyObservation.list_observations_in_path(path_to_test_data)
         hbsflist = HolographySpecification.list_bsf_files_in_path(path_to_test_data)
         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)
-        self.assertEqual(holography_dataset.source_name, '3C 147')
+
+        # Create an empty temporary data file
+        (fd, self.new_test_data_file) = tempfile.mkstemp()
+        print "**** %s " % (self.new_test_data_file)
+        os.close(fd)
+        # Now store the MS data in an HDF5 file.
+        holography_dataset.store_to_file(self.new_test_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
+
 
 if __name__ == '__main__':
     logging.basicConfig(format='%(name)s : %(message)s')
-- 
GitLab