Commit 6821f496 authored by Gianluca Marotta's avatar Gianluca Marotta
Browse files

CT-207 Integration tests for Off Command

parent 9f709bf5
Loading
Loading
Loading
Loading
Loading
+63 −8
Original line number Diff line number Diff line
@@ -176,7 +176,6 @@ class TestCspSubarray(TestBase):
            'dish': { 'receptorIDList': list(map(str, argin))}}
        return json.dumps(param)
    
    @pytest.mark.csp_k8s
    def test_AFTER_initialization(self):
        """
        Test for State after CSP startup.
@@ -190,7 +189,6 @@ class TestCspSubarray(TestBase):
        prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.EMPTY, f"CSP Subarray not EMPTY")
        Poller(4, 0.2).check(prober_subarray_obsstate)

    @pytest.mark.csp_k8s
    def test_subarray_state_AFTER_on_command_execution(self):

        """
@@ -206,7 +204,6 @@ class TestCspSubarray(TestBase):
        prober_subarray_state = Probe(self.midcsp_subarray01, "State", DevState.ON, f"CSP Subarray not OFF")
        Poller(4, 0.2).check(prober_subarray_state)

    @pytest.mark.csp_k8s
    def test_OffCommand_after_RESOURCING(self):
        self._setup_subarray
        json_config= self._build_resources([1,2])
@@ -216,8 +213,9 @@ class TestCspSubarray(TestBase):
        Poller(4, 0.2).check(prober_subarray_state)
        prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.EMPTY, f"CSP Subarray not EMPTY")
        Poller(4, 0.2).check(prober_subarray_obsstate)
        receptors = self.midcsp_subarray01.assignedReceptors
        assert not receptors.any(), f"CSP Subarray is not empty"

    @pytest.mark.csp_k8s
    def test_OffCommand_after_IDLE(self):
        self._setup_subarray()
        self._assign_receptors()
@@ -226,9 +224,10 @@ class TestCspSubarray(TestBase):
        Poller(4, 0.2).check(prober_subarray_state)
        prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.EMPTY, f"CSP Subarray not EMPTY")
        Poller(4, 0.2).check(prober_subarray_obsstate)
        receptors = self.midcsp_subarray01.assignedReceptors
        assert not receptors.any(), f"CSP Subarray is not empty"

    @pytest.mark.cps_k8s
    def test_OffCommand_after_CONFIGURE(self):
    def test_OffCommand_after_CONFIGURING(self):
        self._setup_subarray()
        self._configure_scan()
        self.midcsp_subarray01.Off()
@@ -236,8 +235,65 @@ class TestCspSubarray(TestBase):
        Poller(10, 0.2).check(prober_subarray_state)
        prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.EMPTY, f"CSP Subarray not EMPTY")
        Poller(10, 0.2).check(prober_subarray_obsstate)
        receptors = self.midcsp_subarray01.assignedReceptors
        assert not receptors.any(), f"CSP Subarray is not empty"

    def test_OffCommand_after_READY(self):
        self._setup_subarray()
        self._configure_scan()
        prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.READY, f'CSP Subarray not READY')
        Poller(10, 0.2).check(prober_subarray_obsstate)
        self.midcsp_subarray01.Off()
        prober_subarray_state = Probe(self.midcsp_subarray01, "State", DevState.OFF, f"CSP Subarray not OFF")
        Poller(10, 0.2).check(prober_subarray_state)
        prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.EMPTY, f"CSP Subarray not EMPTY")
        Poller(10, 0.2).check(prober_subarray_obsstate)
        receptors = self.midcsp_subarray01.assignedReceptors
        assert not receptors.any(), f"CSP Subarray is not empty"
    
    def test_OffCommand_after_SCAN(self):
        self._setup_subarray()
        self._configure_scan()
        prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.READY, f'CSP Subarray not READY')
        Poller(10, 0.2).check(prober_subarray_obsstate)
        self.midcsp_subarray01.Scan('2')
        prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.SCANNING, f'CSP Subarray not SCANNING')
        Poller(10, 0.2).check(prober_subarray_obsstate)
        self.midcsp_subarray01.Off()
        prober_subarray_state = Probe(self.midcsp_subarray01, "State", DevState.OFF, f"CSP Subarray not OFF")
        Poller(10, 0.2).check(prober_subarray_state)
        prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.EMPTY, f"CSP Subarray not EMPTY")
        Poller(10, 0.2).check(prober_subarray_obsstate)
        receptors = self.midcsp_subarray01.assignedReceptors
        assert not receptors.any(), f"CSP Subarray is not empty"
    def test_OffCommand_after_ABORTED(self):
        self._setup_subarray()
        self._assign_receptors()
        self.midcsp_subarray01.Abort()
        prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.ABORTED, f'CSP Subarray not ABORTED')
        Poller(10, 0.2).check(prober_subarray_obsstate)
        self.midcsp_subarray01.Off()
        prober_subarray_state = Probe(self.midcsp_subarray01, "State", DevState.OFF, f"CSP Subarray not OFF")
        Poller(4, 0.2).check(prober_subarray_state)
        prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.EMPTY, f"CSP Subarray not EMPTY")
        Poller(4, 0.2).check(prober_subarray_obsstate)
        receptors = self.midcsp_subarray01.assignedReceptors
        assert not receptors.any(), f"CSP Subarray is not empty"
    @pytest.mark.fault
    def test_OffCommand_after_FAULT(self):
        self._setup_subarray()
        self._assign_receptors()
        self.midcsp_subarray01.Configure('{"input":"failed"}')
        prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.FAULT, f'CSP Subarray not FAULT')
        Poller(10, 0.2).check(prober_subarray_obsstate)
        self.midcsp_subarray01.Off()
        prober_subarray_state = Probe(self.midcsp_subarray01, "State", DevState.OFF, f"CSP Subarray not OFF")
        Poller(4, 0.2).check(prober_subarray_state)
        prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.EMPTY, f"CSP Subarray not EMPTY")
        Poller(4, 0.2).check(prober_subarray_obsstate)
        receptors = self.midcsp_subarray01.assignedReceptors
        assert not receptors.any(), f"CSP Subarray is not empty"
        
    @pytest.mark.csp_k8s
    def test_add_receptors_WITH_invalid_id(self):
        """
        Test the assignment of a number of invalid receptor IDs to
@@ -256,7 +312,6 @@ class TestCspSubarray(TestBase):
                invalid_receptor_to_assign.append(id_num)
            if len(invalid_receptor_to_assign) > 3:
                break

        param = {
            'subarrayID': 1,
            'dish': { 'receptorIDList': list(map(str, invalid_receptor_to_assign))}}