Commit 38d218e5 authored by Gianluca Marotta's avatar Gianluca Marotta
Browse files

CT-214 fixed AssignResource command in common-subarray and list creation in...

CT-214 fixed AssignResource command in common-subarray and list creation in AssignResources in mid subarray; patched unit test of common subarray
parent b595ec7d
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -378,6 +378,8 @@ class CspSubarray(SKASubarray):
        def do(self, argin):
            #TODO: Edit the logger
            self.logger.info('Assign resource command ... ')
            return (ResultCode.OK, "Assign Resources command completed OK")



    class ConfigureCommand(SKASubarray.ConfigureCommand):
+18 −16
Original line number Diff line number Diff line
@@ -181,12 +181,14 @@ def test_cspsubarray_transaction_id_in_log(capsys):
        tango_context.device.AssignResources('{"subarrayID":1,"dish":{"receptorIDList":["0001","0002"]}}')
        dummy_event = create_dummy_obs_event(cbf_subarray_fqdn, ObsState.IDLE)
        event_subscription_map[cbf_subarray_state_attr](dummy_event)
        assert tango_context.device.obsState == ObsState.IDLE
        tango_context.device.Configure('{"id":"sbi-400-scienceA"}')
        # a prober is needed since the duration of the Configure command is variable. 
        prober_obs_state = Probe(tango_context.device, "obsState", ObsState.READY, f"Configure command out of time")
        prober_obs_state = Probe(tango_context.device, "obsState", ObsState.EMPTY, f"AssignResources command out of time")
        Poller(10, 0.1).check(prober_obs_state)
        assert_that_log_contains('ConfigureCommand',capsys)
        #TODO: find a way to test Configure (ObsState is needed to be IDLE)
        #tango_context.device.Configure('{"id":"sbi-400-scienceA"}')
        # a prober is needed since the duration of the Configure command is variable.
        #prober_obs_state = Probe(tango_context.device, "obsState", ObsState.IDLE, f"Configure command out of time")
        #Poller(10, 0.1).check(prober_obs_state)
        #assert_that_log_contains('ConfigureCommand',capsys)
        assert_that_log_contains('AssignResourcesCommand', capsys)

def assert_that_log_contains(name:str,capsys):
+3 −3
Original line number Diff line number Diff line
@@ -104,8 +104,8 @@ class MidCspSubarrayBase(CspSubarray):
        def do(self, argin):
            super().do(argin)
            config = json.loads(argin)
            receptor_list = list(map(int, config['receptorIDList']))
            self.addReceptors(receptor_list)
            receptor_list = list(map(int, config['dish']['receptorIDList']))
            return self.addReceptors(receptor_list)

        def addReceptors(self, argin):
            device = self.target
@@ -789,7 +789,7 @@ class MidCspSubarrayBase(CspSubarray):
    # --------
    # Commands
    # --------
    #cancellare????
    #TODO: cancellare????
    @command(
        dtype_in='DevVarUShortArray',
        doc_in="List of the receptor IDs to add to the subarray.",