diff --git a/tangostationcontrol/tangostationcontrol/integration_test/default/statistics/test_writer_sst.py b/tangostationcontrol/tangostationcontrol/integration_test/default/statistics/test_writer_sst.py index d8932263df5079790e14cdd988f73c3224e8c53a..2d98e2fce13730e2e02ea49316c29fe2dd693b1f 100644 --- a/tangostationcontrol/tangostationcontrol/integration_test/default/statistics/test_writer_sst.py +++ b/tangostationcontrol/tangostationcontrol/integration_test/default/statistics/test_writer_sst.py @@ -46,6 +46,45 @@ class TestStatisticsWriterSST(BaseIntegrationTestCase): self.assertIsNotNone(self.recv_proxy.RCU_Band_Select_R) self.assertIsNotNone(self.recv_proxy.RCU_DTH_on_R) + def test_header_info(self): + """ Test whether the header info are inserted and collected in the proper way""" + with TemporaryDirectory() as tmpdir: + new_sys_argv = [ + sys.argv[0], + "--mode", "SST", + "--no-tango", + "--file", join( + dirname(dirname(dirname(dirname(__file__)))), + "test/statistics", "SDP_SST_statistics_packets.bin" + ), + "--output_dir", tmpdir + ] + + with mock.patch.object(entry.sys, 'argv', new_sys_argv): + with self.assertRaises(SystemExit): + entry.main() + + # check if file was written + self.assertTrue(isfile(f"{tmpdir}/SST_2021-09-20-12-17-40.h5")) + + # test statistics reader + new_sys_argv = [ + sys.argv[0], + "--files", f"{tmpdir}/SST_2021-09-20-12-17-40.h5", + "--start_time", "2021-09-20#07:40:08.937+00:00", + "--end_time", "2021-10-04#07:50:08.937+00:00" + ] + with mock.patch.object(reader.sys, 'argv', new_sys_argv): + stat_parser = reader.setup_stat_parser() + SSTstatistics = stat_parser.list_statistics() + self.assertIsNotNone(SSTstatistics) + stat = stat_parser.get_statistic( + '2021-09-20T12:17:40.000+00:00' + ) + self.assertIsNotNone(stat) + self.assertEqual("0.1", stat.station_version_id) + self.assertEqual("0.1", stat.writer_version_id) + def test_insert_tango_SST_statistics(self): self.assertEqual(DevState.ON, self.recv_proxy.state()) collector = StationSSTCollector(device=self.recv_proxy)