コード例 #1
0
def test_obsreset_command(mock_lower_devices_proxy, subarray_state_model,
                          mock_tango_server_helper):
    tango_server_obj = mock_tango_server_helper
    device_data = DeviceData.get_instance()
    obsreset_cmd = ObsReset(device_data, subarray_state_model)
    assert obsreset_cmd.do() == (ResultCode.STARTED,
                                 const.STR_OBSRESET_SUCCESS)
コード例 #2
0
def test_configure_command_subarray_with_invalid_configure_input(
        subarray_state_model, mock_lower_devices_proxy):
    device_proxy, tango_client = mock_lower_devices_proxy
    device_data = DeviceData.get_instance()
    configure_cmd = Configure(device_data, subarray_state_model)
    subarray_state_model._straight_to_state(DevState.ON, None, ObsState.IDLE)
    with pytest.raises(tango.DevFailed) as df:
        configure_cmd.do(invalid_conf_input)
    assert const.ERR_INVALID_JSON in str(df.value)
コード例 #3
0
def test_start_scan_should_command_subarray_to_start_scan_when_it_is_ready(
        mock_lower_devices_proxy, mock_tango_server_helper):
    device_proxy, tango_client = mock_lower_devices_proxy
    tango_server_obj = mock_tango_server_helper
    device_data = DeviceData.get_instance()
    scan_cmd = Scan(device_data, subarray_state_model)
    assert scan_cmd.do(scan_input_str) == (
        ResultCode.STARTED,
        "Scan command is executed successfully.",
    )
コード例 #4
0
def test_obsreset_raise_devfailed(mock_lower_devices_proxy,
                                  subarray_state_model,
                                  mock_tango_server_helper):
    device_proxy, tango_client = mock_lower_devices_proxy
    tango_server_obj = mock_tango_server_helper
    device_data = DeviceData.get_instance()
    tango_client.deviceproxy.command_inout.side_effect = raise_devfailed_exception
    obsreset_cmd = ObsReset(device_data, subarray_state_model)
    with pytest.raises(tango.DevFailed) as df:
        obsreset_cmd.do()
    assert "This is error message for devfailed" in str(df.value)
コード例 #5
0
def test_configure_command(subarray_state_model, mock_lower_devices_proxy,
                           mock_tango_server_helper):
    device_proxy, tango_client = mock_lower_devices_proxy
    device_data = DeviceData.get_instance()
    tango_server_obj = mock_tango_server_helper
    configure_cmd = Configure(device_data, subarray_state_model)
    subarray_state_model._straight_to_state(DevState.ON, None, ObsState.IDLE)
    assert configure_cmd.do(configure_str) == (
        ResultCode.STARTED,
        "Configure command invoked",
    )
コード例 #6
0
def test_end_should_raise_devfailed_exception_when_mccs_subarray_throws_devfailed_exception(
        mock_lower_devices_proxy, subarray_state_model,
        mock_tango_server_helper):
    device_proxy, tango_client = mock_lower_devices_proxy
    tango_server_obj = mock_tango_server_helper
    device_data = DeviceData.get_instance()
    tango_client.deviceproxy.command_inout.side_effect = raise_devfailed_exception
    end_cmd = End(device_data, subarray_state_model)
    with pytest.raises(tango.DevFailed) as df:
        end_cmd.do()
    assert "This is error message for devfailed" in str(df.value)
コード例 #7
0
def test_subarray_health_state_changes_as_per_mccs_subarray_ln_healthstate(
        mock_tango_server_helper, mock_tango_client, health_state):
    tango_server_obj = mock_tango_server_helper
    device_data = DeviceData.get_instance()

    mccs_subarray1_ln_fqdn = "ska_low/tm_leaf_node/mccs_subarray01"
    dut_properties = {
        "MccsSubarrayLNFQDN": mccs_subarray1_ln_fqdn,
    }
    device_data = DeviceData.get_instance()
    with mock.patch.object(TangoClient,
                           "_get_deviceproxy",
                           return_value=Mock()) as mock_obj:
        with mock.patch.object(TangoClient,
                               "subscribe_attribute",
                               side_effect=dummy_subscriber):
            with fake_tango_system(
                    SubarrayNode,
                    initial_dut_properties=dut_properties) as tango_context:
                tango_context.device.On()
    assert device_data._subarray_health_state == health_state
コード例 #8
0
def test_end_should_command_subarray_to_end_when_it_is_ready(
        mock_lower_devices_proxy, subarray_state_model,
        mock_tango_server_helper):
    device_proxy, tango_client = mock_lower_devices_proxy
    tango_server_obj = mock_tango_server_helper
    device_proxy.On()
    device_data = DeviceData.get_instance()
    end_cmd = End(device_data, subarray_state_model)
    subarray_state_model._straight_to_state(DevState.ON, None, ObsState.READY)
    assert end_cmd.do() == (
        ResultCode.OK,
        "End command invoked successfully on MCCS Subarray Leaf Node.",
    )
コード例 #9
0
def test_release_all_resources_should_release_resources_when_obstate_idle(
        mock_lower_devices_proxy, subarray_state_model,
        mock_tango_server_helper):
    device_proxy, tango_client = mock_lower_devices_proxy
    tango_server_obj = mock_tango_server_helper
    device_proxy.On()
    device_proxy.AssignResources(assign_input_str)
    device_data = DeviceData.get_instance()
    release_resources_cmd = ReleaseAllResources(device_data,
                                                subarray_state_model)
    assert release_resources_cmd.do() == (
        ResultCode.STARTED,
        "RELEASEALLRESOURCES command invoked successfully.",
    )
コード例 #10
0
def test_end_scan_should_command_subarray_to_end_scan_when_it_is_scanning(
        mock_lower_devices_proxy, subarray_state_model,
        mock_tango_server_helper):
    device_proxy, tango_client = mock_lower_devices_proxy
    tango_server_obj = mock_tango_server_helper
    device_data = DeviceData.get_instance()
    end_scan_cmd = EndScan(device_data, subarray_state_model)
    subarray_state_model._straight_to_state(DevState.ON, None,
                                            ObsState.SCANNING)
    device_data.scan_timer_handler.start_scan_timer(10)
    assert end_scan_cmd.do() == (
        ResultCode.OK,
        "EndScan command is executed successfully.",
    )
コード例 #11
0
def test_subarray_assigned_resources_attr_callback_with_error_event(
        mock_lower_devices_proxy, mock_tango_server_helper):
    device_proxy, tango_client = mock_lower_devices_proxy
    tango_server_obj = mock_tango_server_helper
    device_data = DeviceData.get_instance()
    with mock.patch.object(TangoClient,
                           "_get_deviceproxy",
                           return_value=Mock()) as mock_obj:
        with mock.patch.object(
                TangoClient,
                "subscribe_attribute",
                side_effect=create_dummy_event_assign_resource_attr_with_error,
        ):
            device_proxy.On()
            device_proxy.AssignResources(assign_input_str)
    assert const.ERR_SUBSR_MCCSSA_ASSIGNED_RES_ATTR in device_proxy.activityMessage
コード例 #12
0
def test_subarray_assigned_resources_attr_changes_as_per_mccs_subarray_ln_assigned_resources_attr(
        mock_lower_devices_proxy, mock_tango_server_helper):
    device_proxy, tango_client = mock_lower_devices_proxy
    tango_server_obj = mock_tango_server_helper
    device_data = DeviceData.get_instance()
    with mock.patch.object(TangoClient,
                           "_get_deviceproxy",
                           return_value=Mock()) as mock_obj:
        with mock.patch.object(TangoClient,
                               "subscribe_attribute",
                               side_effect=dummy_subscriber_mccs):
            device_proxy.On()
            device_proxy.AssignResources(assign_input_str)
    test1 = {
        "interface":
        "https://schema.skatelescope.org/ska-low-mccs-assignedresources/1.0",
        "subarray_beam_ids": [1],
        "station_ids": [[1, 2]],
        "channel_blocks": [3]
    }
    result = json.dumps(test1)
    assert device_data.assignd_resources_by_mccs == result
コード例 #13
0
def device_data():
    yield DeviceData()