Commit 6d4ff904 authored by Elisabetta Giani's avatar Elisabetta Giani
Browse files

CT-69: Removed the fspMembership forwarded attribute from code and from database configuration

file.
Added tests for Scan command.
parent 912bc3ff
Loading
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -239,10 +239,10 @@ class MidCspMasterBase(CspMaster):
        label="reportFSPAdminMode",
        forwarded=True
    )
    fspMembership = attribute(name="fspMembership",
        label="fspMembership",
        forwarded=True
    )
    #fspMembership = attribute(name="fspMembership",
    #    label="fspMembership",
    #    forwarded=True
    #)
    vccMembership = attribute(name="vccMembership",
        label="vccMembership",
        forwarded=True
+0 −5
Original line number Diff line number Diff line
@@ -81,11 +81,6 @@
                                    "1"
                                ]
                            }, 
                            "fspMembership": {
                                "__root_att": [
                                    "mid_csp_cbf/sub_elt/master/reportFSPSubarrayMembership"
                                ]
                            }, 
                            "healthState": {
                                "abs_change": [
                                    "-1", 
+3 −2
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ sys.path.insert(0, os.path.abspath(path))
#Local imports
from ska.base.control_model  import ObsState

LOGGER = logging.getLogger(__name__)
# Device test case
@pytest.mark.usefixtures("midcsp_master", "midcsp_subarray01", "midcsp_subarray02", "cbf_subarray01")

@@ -368,6 +369,6 @@ class TestCspSubarray(object):
        assert ((obs_state2 == 2) and (obs_state1 == 2))
        time.sleep(1)
        assert not midcsp_subarray01.timeoutExpiredFlag 
        midcsp_subarray01.GotToIdle()
        midcsp_subarray02.GotToIdle()
        midcsp_subarray01.GoToIdle()
        midcsp_subarray02.GoToIdle()
        time.sleep(3)
+100 −1
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ def prepare_configuration_string(filename="test_ConfigureScan_ADR4.json"):
    """Create the config string for CSP-CBF"""
    try:
        file_to_load = file_path + '/' + filename
        LOGGER.info(f"Reading configuration from {filefile_to_load}")
        LOGGER.info(f"Reading configuration from {file_to_load}")
        json_file = open(file_to_load)
        configuration_string = json_file.read().replace("\n", "")
        return configuration_string
@@ -85,6 +85,14 @@ class TestCspSubarrayConfiguration(TestBase):
        state = self.midcsp_subarray01.State()
        assert state == DevState.ON

    def _set_cspsubarray_to_idle_state(self):
        LOGGER.info("Set the CSP Subarray to IDLE")
        obs_state = self.midcsp_subarray01.obsState
        if obs_state == ObsState.READY:
            self.midcsp_subarray01.GoToIdle()
            prober_obs_state = Probe(self.midcsp_subarray01, 'obsState', ObsState.IDLE, f"CSP Subarray not IDLE")
            Poller(7, 0.2).check(prober_obs_state)

    def _reset_subarray_to_disable_state(self):
        try:
            state = self.midcsp_subarray01.State()
@@ -92,6 +100,7 @@ class TestCspSubarrayConfiguration(TestBase):
            if state == DevState.DISABLE:
                return
            if state == DevState.ON:
                self._set_cspsubarray_to_idle_state()
                LOGGER.debug("Remove all receptors")
                self.midcsp_subarray01.RemoveAllReceptors()
                # wait for the transition of the CSP sub-array to OFF
@@ -228,3 +237,93 @@ class TestCspSubarrayConfiguration(TestBase):
        Poller(7, 0.2).check(prober_subarray_flag)
        # failure_flag = self.midcsp_subarray01.failureRaisedFlag
        # assert failure_flag

    def test_cspsubarray_scan_WITH_invalid_string_id(self):
        """
        CSP Subarray receives the Scan command with an invalid 
        scanId number
        """
        # setup the test: Subarray DISABLE-IDLE
        self._setup_csp_subarray()
        configuration_string = prepare_configuration_string()
        LOGGER.info(f"Configuring CSP subarray01")
        self.midcsp_subarray01.Configure(configuration_string)
        prober_obs_state = Probe(self.midcsp_subarray01, 'obsState', ObsState.READY, f"CSP Subarray not configured")
        Poller(7, 0.2).check(prober_obs_state)
        LOGGER.info(f"Issue the Scan command sending the string \"abcd\" as input")
        # exercise the device
        with pytest.raises(tango.DevFailed) as df:
            self.midcsp_subarray01.Scan("abcd")
        if df:
            err_msg = str(df.value.args[0].desc)
            LOGGER.error(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.READY

    def test_cspsubarray_scan_WITH_no_argument(self):
        """
        CSP Subarray receives the Scan command with an invalid 
        scanId number
        """
        # setup the test: Subarray DISABLE-IDLE
        self._setup_csp_subarray()
        configuration_string = prepare_configuration_string()
        LOGGER.info(f"Configuring CSP subarray01")
        self.midcsp_subarray01.Configure(configuration_string)
        prober_obs_state = Probe(self.midcsp_subarray01, 'obsState', ObsState.READY, f"CSP Subarray not configured")
        Poller(7, 0.2).check(prober_obs_state)
        LOGGER.info(f"Issue the Scan command sending the string \"abcd\" as input")
        # exercise the device
        with pytest.raises(tango.DevFailed) as df:
            self.midcsp_subarray01.Scan()
        if df:
            err_msg = str(df.value.args[0].desc)
            LOGGER.error(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.READY

    def test_cspsubarray_scan_WITH_int_argument(self):
        """
        CSP Subarray receives the Scan command with an invalid 
        scanId number
        """
        # setup the test: Subarray DISABLE-IDLE
        self._setup_csp_subarray()
        configuration_string = prepare_configuration_string()
        LOGGER.info(f"Configuring CSP subarray01")
        self.midcsp_subarray01.Configure(configuration_string)
        prober_obs_state = Probe(self.midcsp_subarray01, 'obsState', ObsState.READY, f"CSP Subarray not configured")
        Poller(7, 0.2).check(prober_obs_state)
        LOGGER.info(f"Issue the Scan command sending an int as input")
        # exercise the device
        with pytest.raises(tango.DevFailed) as df:
            self.midcsp_subarray01.Scan(1)
        if df:
            err_msg = str(df.value.args[0].desc)
            LOGGER.error(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.READY

    def test_cspsubarray_scan_WITH_valid_scan_id(self):
        """
        CSP Subarray receives the Scan command with an invalid 
        scanId number
        """
        # setup the test: Subarray DISABLE-IDLE
        self._setup_csp_subarray()
        configuration_string = prepare_configuration_string()
        LOGGER.info(f"Configuring CSP subarray01")
        self.midcsp_subarray01.Configure(configuration_string)
        prober_obs_state = Probe(self.midcsp_subarray01, 'obsState', ObsState.READY, f"CSP Subarray not configured")
        Poller(7, 0.2).check(prober_obs_state)
        LOGGER.info(f"Issue the Scan command with a sequence")
        # exercise the device
        self.midcsp_subarray01.Scan("1")
        prober_obs_state = Probe(self.midcsp_subarray01, 'obsState', ObsState.SCANNING, f"CSP Subarray not configured")
        Poller(7, 0.2).check(prober_obs_state)
        self.midcsp_subarray01.EnScan()
        prober_obs_state = Probe(self.midcsp_subarray01, 'obsState', ObsState.READY, f"CSP Subarray not configured")
        Poller(7, 0.2).check(prober_obs_state)