Commit f79fe52f authored by Elisabetta Giani's avatar Elisabetta Giani
Browse files

CT-69: Added messages on failure.

parent 4b7c8af6
Loading
Loading
Loading
Loading
Loading
+21 −10
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import unittest
# Local imports
from ska.base.control_model import ObsState
from utils import Poller, Probe
from assertpy import assert_that

LOGGER = logging.getLogger(__name__)

@@ -75,6 +76,11 @@ class TestCspSubarrayConfiguration(TestBase):
        # 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)
        state = self.midcsp_subarray01.State()
        assert state == DevState.ON

    def _reset_subarray_to_disable_state(self):
        try:
@@ -138,11 +144,11 @@ class TestCspSubarrayConfiguration(TestBase):
        LOGGER.info("Send configuration command")
        self.midcsp_subarray01.Configure(configuration_string)
        prober_subarray_obstate = Probe(self.midcsp_subarray01, 'obsState', ObsState.READY,
                                        f"Wrong CSP Subarray obsState")
                                        f"Wrong CSP Subarray obsState {self.midcsp_subarray01.obsState}")
        Poller(5, 0.2).check(prober_subarray_obstate)
        # check
        obs_state = self.midcsp_subarray01.obsState
        assert obs_state == ObsState.READY
        #obs_state = self.midcsp_subarray01.obsState
        #assert obs_state == ObsState.READY,f"Wrong CSP Subarray obsState {obs_state}"
        stored_json = self.midcsp_subarray01.validScanConfiguration
        assert stored_json == configuration_string

@@ -155,16 +161,20 @@ class TestCspSubarrayConfiguration(TestBase):
        # Set the CSP Subarray to ON-IDLE state
        self._setup_csp_subarray()
        configuration_string = prepare_configuration_string("test_ConfigureScan_without_configID.json")
        #configuration_string = prepare_configuration_string("test_ConfigureScan_ADR4.json")

        # exercise the device
        with pytest.raises(tango.DevFailed):
        with pytest.raises(tango.DevFailed) as tango_err:
            self.midcsp_subarray01.Configure(configuration_string)
        if tango_err:
            err_msg = str(tango_err.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}")
        # check
        obs_state = self.midcsp_subarray01.obsState
        #assert obs_state == ObsState.IDLE, f"CSP Subarray obsState has wrong value ({obs_state})"
        assert_that(obs_state).described_by("AAA").is_equal_to(ObsState.IDLE)
        assert_that(obs_state).described_as("CSP Subarray obsState has wrong value ({obs_state}").is_equal_to(ObsState.IDLE)

            self._reset_subarray_to_disable_state()
    def test_configure_cspsubarray_WHEN_in_wrong_state(self):
        """
        Set the CSP Subarray in a wrong state and issue the
@@ -179,17 +189,18 @@ def test_configure_cspsubarray_WHEN_in_wrong_state(self):
        # exercise the device
        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 with error: {err_msg}")
            LOGGER.info(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
        end_state = self.midcsp_subarray01.State()
        assert obs_state == ObsState.IDLE, f"Current ObsState should be IDLE"
        assert end_state == init_state, f"Current State should be the initial one"
        assert_that(obs_state).described_by("Current ObsState should be IDLE").is_not_equal_to(ObsState.IDLE)
        #assert_that(obs_state).described_by("Current ObsState should be IDLE").is_not_equal_to(ObsState.IDLE)

    def test_configure_cbf_WITH_invalid_json(self):
        """
@@ -205,6 +216,6 @@ def test_configure_cspsubarray_WHEN_in_wrong_state(self):
        # check
        # Subarray final ObsState IDLE
        prober_subarray_flag = Probe(self.midcsp_subarray01, 'failureRaisedFlag', True, f"Failure flag is false")
        Poller(5, 0.2).check(prober_subarray_flag)
        Poller(7, 0.2).check(prober_subarray_flag)
        # failure_flag = self.midcsp_subarray01.failureRaisedFlag
        # assert failure_flag