Loading csp-lmc-common/csp_lmc_common/CspSubarray.py +161 −304 File changed.Preview size limit exceeded, changes collapsed. Show changes csp-lmc-common/tests/unit/cspsubarray_unit_test.py +5 −64 Original line number Diff line number Diff line Loading @@ -56,68 +56,9 @@ def test_cspsubarray_state_and_obstate_value_after_initialization(): } # CASE A: CBF is OFF with fake_tango_system(device_under_test, initial_dut_properties=dut_properties, proxies_to_mock=proxies_to_mock) as tango_context: dummy_event = create_dummy_event(cbf_subarray_fqdn, DevState.OFF) event_subscription_map_cbf[state_attr](dummy_event) assert tango_context.device.State() == DevState.OFF assert tango_context.device.obsState == ObsState.EMPTY # CASE B: CBF is ON # # CASE 1.1 ObsState are EQUAL with fake_tango_system(device_under_test, initial_dut_properties=dut_properties, proxies_to_mock=proxies_to_mock) as tango_context: dummy_event_cbf = create_dummy_obs_event(cbf_subarray_fqdn, ObsState.READY) dummy_event_pss = create_dummy_obs_event(cbf_subarray_fqdn, ObsState.READY) dummy_event_pst = create_dummy_obs_event(cbf_subarray_fqdn, ObsState.READY) event_subscription_map_cbf[state_attr](dummy_event_cbf) event_subscription_map_pss[state_attr](dummy_event_pss) event_subscription_map_pst[state_attr](dummy_event_pst) assert tango_context.device.State() == DevState.ON assert tango_context.device.obsState == ObsState.READY # # CASE 1.2 ObsState are DIFFERENT with fake_tango_system(device_under_test, initial_dut_properties=dut_properties, proxies_to_mock=proxies_to_mock) as tango_context: dummy_event_cbf = create_dummy_obs_event(cbf_subarray_fqdn, ObsState.READY) dummy_event_pss = create_dummy_obs_event(cbf_subarray_fqdn, ObsState.FAULT) dummy_event_pst = create_dummy_obs_event(cbf_subarray_fqdn, ObsState.READY) event_subscription_map_cbf[state_attr](dummy_event_cbf) event_subscription_map_pss[state_attr](dummy_event_pss) event_subscription_map_pst[state_attr](dummy_event_pst) assert tango_context.device.State() == DevState.ON assert tango_context.device.obsState == ObsState.FAULT # # CASE 2.1 Transitional states ALLOWED with fake_tango_system(device_under_test, initial_dut_properties=dut_properties, proxies_to_mock=proxies_to_mock) as tango_context: dummy_event_cbf = create_dummy_obs_event(cbf_subarray_fqdn, ObsState.CONFIGURING) dummy_event_pss = create_dummy_obs_event(cbf_subarray_fqdn, ObsState.READY) dummy_event_pst = create_dummy_obs_event(cbf_subarray_fqdn, ObsState.READY) event_subscription_map_cbf[state_attr](dummy_event_cbf) event_subscription_map_pss[state_attr](dummy_event_pss) event_subscription_map_pst[state_attr](dummy_event_pst) assert tango_context.device.State() == DevState.ON assert tango_context.device.obsState == ObsState.CONFIGURING dummy_event_cbf = create_dummy_obs_event(cbf_subarray_fqdn, ObsState.READY) assert tango_context.device.obsState == ObsState.READY # # CASE 2.1 Transitional states NOT ALLOWED with fake_tango_system(device_under_test, initial_dut_properties=dut_properties, proxies_to_mock=proxies_to_mock) as tango_context: dummy_event_cbf = create_dummy_obs_event(cbf_subarray_fqdn, ObsState.CONFIGURING) dummy_event_pss = create_dummy_obs_event(cbf_subarray_fqdn, ObsState.READY) dummy_event_pst = create_dummy_obs_event(cbf_subarray_fqdn, ObsState.FAULT) event_subscription_map_cbf[state_attr](dummy_event_cbf) event_subscription_map_pss[state_attr](dummy_event_pss) event_subscription_map_pst[state_attr](dummy_event_pst) assert tango_context.device.State() == DevState.ON assert tango_context.device.obsState == ObsState.FAULT def test_cspsbarray_state_after_On_WITH_exception_raised_by_subelement_subarray(): """ Test the behavior of the CspSubarray when one of the sub-element subarray Loading Loading @@ -251,13 +192,13 @@ def test_cspsubarray_transaction_id_in_log(capsys): with fake_tango_system(device_under_test, initial_dut_properties=dut_properties, proxies_to_mock=proxies_to_mock) as tango_context: cbf_subarray_device_proxy_mock.On.side_effect = return_ok pss_subarray_device_proxy_mock.On.side_effect = return_ok prober_obs_state = Probe(tango_context.device, "State", DevState.OFF, f"State is not OFF") Poller(3, 0.1).check(prober_obs_state) tango_context.device.On() assert tango_context.device.State() == DevState.ON 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) prober_obs_state = Probe(tango_context.device, "obsState", ObsState.EMPTY, f"AssignResources command out of time") Poller(10, 0.1).check(prober_obs_state) #tango_context.device.AssignResources('{"subarrayID":1,"dish":{"receptorIDList":["0001","0002"]}}') tango_context.device.AssignResources('{"example": ["BAND1"]}') tango_context.device.obsState == ObsState.IDLE #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. Loading Loading
csp-lmc-common/csp_lmc_common/CspSubarray.py +161 −304 File changed.Preview size limit exceeded, changes collapsed. Show changes
csp-lmc-common/tests/unit/cspsubarray_unit_test.py +5 −64 Original line number Diff line number Diff line Loading @@ -56,68 +56,9 @@ def test_cspsubarray_state_and_obstate_value_after_initialization(): } # CASE A: CBF is OFF with fake_tango_system(device_under_test, initial_dut_properties=dut_properties, proxies_to_mock=proxies_to_mock) as tango_context: dummy_event = create_dummy_event(cbf_subarray_fqdn, DevState.OFF) event_subscription_map_cbf[state_attr](dummy_event) assert tango_context.device.State() == DevState.OFF assert tango_context.device.obsState == ObsState.EMPTY # CASE B: CBF is ON # # CASE 1.1 ObsState are EQUAL with fake_tango_system(device_under_test, initial_dut_properties=dut_properties, proxies_to_mock=proxies_to_mock) as tango_context: dummy_event_cbf = create_dummy_obs_event(cbf_subarray_fqdn, ObsState.READY) dummy_event_pss = create_dummy_obs_event(cbf_subarray_fqdn, ObsState.READY) dummy_event_pst = create_dummy_obs_event(cbf_subarray_fqdn, ObsState.READY) event_subscription_map_cbf[state_attr](dummy_event_cbf) event_subscription_map_pss[state_attr](dummy_event_pss) event_subscription_map_pst[state_attr](dummy_event_pst) assert tango_context.device.State() == DevState.ON assert tango_context.device.obsState == ObsState.READY # # CASE 1.2 ObsState are DIFFERENT with fake_tango_system(device_under_test, initial_dut_properties=dut_properties, proxies_to_mock=proxies_to_mock) as tango_context: dummy_event_cbf = create_dummy_obs_event(cbf_subarray_fqdn, ObsState.READY) dummy_event_pss = create_dummy_obs_event(cbf_subarray_fqdn, ObsState.FAULT) dummy_event_pst = create_dummy_obs_event(cbf_subarray_fqdn, ObsState.READY) event_subscription_map_cbf[state_attr](dummy_event_cbf) event_subscription_map_pss[state_attr](dummy_event_pss) event_subscription_map_pst[state_attr](dummy_event_pst) assert tango_context.device.State() == DevState.ON assert tango_context.device.obsState == ObsState.FAULT # # CASE 2.1 Transitional states ALLOWED with fake_tango_system(device_under_test, initial_dut_properties=dut_properties, proxies_to_mock=proxies_to_mock) as tango_context: dummy_event_cbf = create_dummy_obs_event(cbf_subarray_fqdn, ObsState.CONFIGURING) dummy_event_pss = create_dummy_obs_event(cbf_subarray_fqdn, ObsState.READY) dummy_event_pst = create_dummy_obs_event(cbf_subarray_fqdn, ObsState.READY) event_subscription_map_cbf[state_attr](dummy_event_cbf) event_subscription_map_pss[state_attr](dummy_event_pss) event_subscription_map_pst[state_attr](dummy_event_pst) assert tango_context.device.State() == DevState.ON assert tango_context.device.obsState == ObsState.CONFIGURING dummy_event_cbf = create_dummy_obs_event(cbf_subarray_fqdn, ObsState.READY) assert tango_context.device.obsState == ObsState.READY # # CASE 2.1 Transitional states NOT ALLOWED with fake_tango_system(device_under_test, initial_dut_properties=dut_properties, proxies_to_mock=proxies_to_mock) as tango_context: dummy_event_cbf = create_dummy_obs_event(cbf_subarray_fqdn, ObsState.CONFIGURING) dummy_event_pss = create_dummy_obs_event(cbf_subarray_fqdn, ObsState.READY) dummy_event_pst = create_dummy_obs_event(cbf_subarray_fqdn, ObsState.FAULT) event_subscription_map_cbf[state_attr](dummy_event_cbf) event_subscription_map_pss[state_attr](dummy_event_pss) event_subscription_map_pst[state_attr](dummy_event_pst) assert tango_context.device.State() == DevState.ON assert tango_context.device.obsState == ObsState.FAULT def test_cspsbarray_state_after_On_WITH_exception_raised_by_subelement_subarray(): """ Test the behavior of the CspSubarray when one of the sub-element subarray Loading Loading @@ -251,13 +192,13 @@ def test_cspsubarray_transaction_id_in_log(capsys): with fake_tango_system(device_under_test, initial_dut_properties=dut_properties, proxies_to_mock=proxies_to_mock) as tango_context: cbf_subarray_device_proxy_mock.On.side_effect = return_ok pss_subarray_device_proxy_mock.On.side_effect = return_ok prober_obs_state = Probe(tango_context.device, "State", DevState.OFF, f"State is not OFF") Poller(3, 0.1).check(prober_obs_state) tango_context.device.On() assert tango_context.device.State() == DevState.ON 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) prober_obs_state = Probe(tango_context.device, "obsState", ObsState.EMPTY, f"AssignResources command out of time") Poller(10, 0.1).check(prober_obs_state) #tango_context.device.AssignResources('{"subarrayID":1,"dish":{"receptorIDList":["0001","0002"]}}') tango_context.device.AssignResources('{"example": ["BAND1"]}') tango_context.device.obsState == ObsState.IDLE #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. Loading