Commit 161d1841 authored by Elisabetta Giani's avatar Elisabetta Giani
Browse files

CT-69: Check isCmdInProgrss attribute value to assert AddReceptors command end.

Moved some logging messages from info to debug.
parent 9b7a930b
Loading
Loading
Loading
Loading
Loading
+18 −21
Original line number Diff line number Diff line
@@ -63,45 +63,38 @@ class TestCspSubarrayConfiguration(TestBase):
        # and the receptorMembership attribute reporting
        # dish affiliation to subarrays
        unassigned_receptors = self.midcsp_master.unassignedReceptorIDs
        receptor_membership_expected = self.midcsp_master.receptorMembership
        # assign the first one to the CSP subarray to force 
        # the transition to ON
        LOGGER.info("Add receptors to CSP Subarray")
        LOGGER.debug("Add receptors to CSP Subarray")
        self.midcsp_subarray01.AddReceptors([unassigned_receptors[0], ])
        receptor_membership_expected[unassigned_receptors[0] - 1] = 1
        # wait for the expected value of the CSP Master receptorMembership attribute
        prober_receptor_membership = Probe(self.midcsp_master, 'receptorMembership', receptor_membership_expected,
                                           f"Wrong value for receptor membership attribute")
        Poller(10, 0.2).check(prober_receptor_membership)
        # wait for the transition of the CSP subarray to ON
        prober_subarray_state = Probe(self.midcsp_subarray01, 'state', DevState.ON, f"Wrong CSP Subarray state")
        Poller(10, 0.2).check(prober_subarray_state)
        prober_progress_counter = Probe(self.midcsp_subarray01, 'addReceptorsCmdProgress', 100,
                                           f"Wrong value for receptor membership attribute")
        Poller(10, 0.2).check(prober_progress_counter)
        prober_cmd_in_progress = Probe(self.midcsp_subarray01, 'isCmdInProgress', False,
                                           f"Wrong value for command in progress")
        Poller(10, 0.2).check(prober_cmd_in_progress)
        state = self.midcsp_subarray01.State()
        assert state == DevState.ON

    def _reset_subarray_to_disable_state(self):
        try:
            state = self.midcsp_subarray01.State()
            LOGGER.info("CSP Subarray init State:{}".format(state))
            LOGGER.debug("CSP Subarray init State:{}".format(state))
            if state == DevState.DISABLE:
                return
            if state == DevState.ON:
                LOGGER.info("Remove all receptors")
                LOGGER.debug("Remove all receptors")
                self.midcsp_subarray01.RemoveAllReceptors()
                # wait for the transition of the CSP sub-array to OFF
                prober_subarray_state = Probe(self.midcsp_subarray01, 'state', DevState.OFF,
                                              f"Wrong CSP Subarray state")
                Poller(7, 0.2).check(prober_subarray_state)
                prober_master_state = Probe(self.midcsp_master, 'state', DevState.ON, f"Wrong CSP Master state")
                Poller(7, 0.2).check(prober_master_state)

            # Set the CSP subarray to OFF issuing the Standby command
            # on CSP Master
            state = self.midcsp_subarray01.State()
            if state == DevState.OFF:
                LOGGER.info("CSP Subarray State is OFF...going to execute Standby")
                LOGGER.debug("CSP Subarray State is OFF...going to execute Standby")
                # wait until Master is ON
                prober_master_state = Probe(self.midcsp_master, 'state', DevState.ON, f"Wrong CSP Master state")
                Poller(7, 0.2).check(prober_master_state)
                self.midcsp_master.Standby("")
                prober_subarray_state = Probe(self.midcsp_subarray01, 'state', DevState.DISABLE,
                                              f"Wrong CSP Subarray state")
@@ -121,7 +114,7 @@ class TestCspSubarrayConfiguration(TestBase):
        self._reset_subarray_to_disable_state()
        # switch-on the CspMaster to force CSP Subarray
        # transition to OFF
        LOGGER.info("Switch on Master")
        LOGGER.debug("Set CSP Subarray to OFF")
        self.midcsp_master.On("")
        # wait for the transition of the CSP subarray to OFF
        prober_subarray_state = Probe(self.midcsp_subarray01, 'state', DevState.OFF, f"Wrong CSP Subarray state")
@@ -141,7 +134,7 @@ class TestCspSubarrayConfiguration(TestBase):
        assert state == DevState.ON, "assume the CSP subarray State is ON"
        # exercise the device
        LOGGER.debug(f"sending configure:{configuration_string}")
        LOGGER.info("Send configuration command")
        LOGGER.info(f"Configuring CSP subarray01")
        self.midcsp_subarray01.Configure(configuration_string)
        prober_subarray_obstate = Probe(self.midcsp_subarray01, 'obsState', ObsState.READY,
                                        f"Wrong CSP Subarray obsState {self.midcsp_subarray01.obsState}")
@@ -164,6 +157,7 @@ class TestCspSubarrayConfiguration(TestBase):
        #configuration_string = prepare_configuration_string("test_ConfigureScan_ADR4.json")

        # exercise the device
        LOGGER.info(f"Configuring CSP subarray01")
        with pytest.raises(tango.DevFailed) as tango_err:
            self.midcsp_subarray01.Configure(configuration_string)
        if tango_err:
@@ -181,19 +175,22 @@ class TestCspSubarrayConfiguration(TestBase):
        Configure command on it.
        """
        # setup the test: Subarray DISABLE-IDLE

        self._setup_csp_subarray()
        LOGGER.info("Force CSP Subarray to an invalid state to accept Configure")
        self._reset_subarray_to_disable_state()
        configuration_string = prepare_configuration_string()
        init_state = self.midcsp_subarray01.State()

        # exercise the device
        LOGGER.info(f"Configuring CSP subarray01")
        with pytest.raises(tango.DevFailed) as df:
            self.midcsp_subarray01.Configure(configuration_string)
        #assert_that(self.midcsp_subarray01.Configure).raises(tango.DevFailed).when_called_with(configuration_string)
        if df:
            err_msg = str(df.value.args[0].desc)
            # TODO: aggiungere quale device fallisce
            LOGGER.info(f"Command configure failed on {self.midcsp_subarray01.dev_name()} with error: {err_msg}")
            LOGGER.error(f"Command configure failed on {self.midcsp_subarray01.dev_name()} with error: {err_msg}")
        # check
        # Subarray final ObsState=IDLE
        obs_state = self.midcsp_subarray01.obsState