diff --git a/MAC/TBB/lib/tbb_freeze.py b/MAC/TBB/lib/tbb_freeze.py index f7aa35a9a9b6d1d8c87b28a3d0c39b59edc6d514..815426bac1c2391fb7937176631f11dd8fa2722a 100755 --- a/MAC/TBB/lib/tbb_freeze.py +++ b/MAC/TBB/lib/tbb_freeze.py @@ -62,7 +62,7 @@ def freeze_tbb(stations, dm, timesec, timensec): # lcuhead to the stations and chain it into the command, so that we are not delayed by lcurun/ssh. # wait for timestamp, then stop all boards on all stations. - timestamp = float("%s.%09d" % (timesec, timensec)) + timestamp = float("%d.%09d" % (timesec, timensec)) if dm is not None: timestamp += 0.32 * dm diff --git a/SAS/TriggerServices/test/t_trigger_service.py b/SAS/TriggerServices/test/t_trigger_service.py index 0d1ab999488d0a97310f15aaf49a3a86666c93ea..20e035870bade2d1340e3df6e65fd332b32af97c 100644 --- a/SAS/TriggerServices/test/t_trigger_service.py +++ b/SAS/TriggerServices/test/t_trigger_service.py @@ -24,7 +24,7 @@ import unittest import os import logging -from lofar.triggerservices.trigger_service import TriggerHandler, ALERTHandler +from lofar.triggerservices.trigger_service import TriggerHandler, ALERTHandler, DEFAULT_TBB_PROJECT import lofar.triggerservices.trigger_service as serv from lofar.specificationservices.translation_service import SpecificationTranslationHandler from lxml import etree @@ -124,12 +124,22 @@ class TestALERTHandler(unittest.TestCase): logging.info('Setup test %s' % self._testMethodName) def test_valid_voevent_should_invoke_tbb_dump(self): - with mock.patch('lofar.triggerservices.trigger_service.momqueryrpc') as momrpc, \ - mock.patch('lofar.mac.tbbservice.client.tbbservice_rpc.TBBRPC.do_tbb_subband_dump') as dump, \ - mock.patch('lofar.triggerservices.voevent_decider.ALERTDecider') as sciencecheck: - momrpc.allows_triggers.return_value = {'allows': True} - momrpc.get_trigger_quota.return_value = {'used_triggers': 4, 'allocated_triggers': 5} + with mock.patch('lofar.mac.tbbservice.client.tbbservice_rpc.TBBRPC.do_tbb_subband_dump') as dump, \ + mock.patch('lofar.triggerservices.voevent_decider.ALERTDecider') as sciencecheck: + + self.handler._cache.get_project_info = mock.MagicMock() + self.handler._cache.get_project_info.return_value = {'allow_triggers':True, + 'num_used_triggers': 4, + 'num_allowed_triggers': 5} + self.handler._cache.get_active_tasks = mock.MagicMock() + self.handler._cache.get_stations = mock.MagicMock() + self.handler._cache.get_stations.return_value = ['CS004C'] + + test_task = mock.MagicMock() + test_task.radb_task = dict(otdb_id=123456) + self.handler._cache.get_active_tasks.return_value = [test_task] sciencecheck.is_acceptable.return_value = True + self.handler.handle_event(self.voevent_xml, self.voevent_etree) dump.assert_called_once() @@ -140,7 +150,7 @@ class TestALERTHandler(unittest.TestCase): with self.assertRaises(Exception) as err: self.handler.handle_event(self.voevent_xml, self.voevent_etree) - self.assertTrue('exceeded' in str(err.exception)) + self.assertTrue('pre-flight checks!' in str(err.exception)) def test_voevent_not_authorized_should_raise_exception(self): with mock.patch('lofar.triggerservices.trigger_service.momqueryrpc') as momrpc: @@ -149,7 +159,7 @@ class TestALERTHandler(unittest.TestCase): with self.assertRaises(Exception) as err: self.handler.handle_event(self.voevent_xml, self.voevent_etree) - self.assertTrue('not allowed' in str(err.exception)) + self.assertTrue('pre-flight checks!' in str(err.exception)) if __name__ == '__main__':