Test API package
conftest module
Path: tests/
conftest module for Subarray Node.
- tests.conftest.aggregation_process_low()
Create aggregation process low object
- Yields
Aggregation process low object
- Return type
- tests.conftest.aggregation_process_mid()
Create aggregation process mid object
- Yields
Aggregation procees mid object
- Return type
- tests.conftest.change_event_callbacks()
Return a dictionary of Tango device change event callbacks with asynchrony support.
- Return type
MockTangoEventCallbackGroup
- Returns
a collections.defaultdict that returns change event callbacks by name.
- tests.conftest.cm_without_er_lp_low()
Fixture to create and yield a SubarrayNodeComponentManagerLow instance without event receiver or liveliness probe for testing purposes.
- Yields
SubarrayNodeComponentManagerLow – Configured component manager instance.
- Return type
- tests.conftest.component_manager_low()
Create a component manager instance for LOW.
- Yields
Instance of component manager low
- Return type
- tests.conftest.component_manager_mid()
Create a component manager instance for MID.
- Yields
Instance of component manager
- Return type
- tests.conftest.component_state_changed_callback(cm, state_change)
Handle change in this device’s state.
This is a callback hook, called whenever the state changes. It is responsible for updating the tango side of things i.e. making sure the attribute is up to date, and events are pushed.
- Parameters
cm – Component Manager
state_change – A dictionary containing the name of the state that changed and its new value.
- Return type
- tests.conftest.devices_to_load()
This method returns the devices whose context are required
- Return type
- Returns
Dictionary of dictionaries containing the class and devices
- tests.conftest.event_recorder()
Records events and allows assertions
- Yields
EventRecorder instance
- Return type
- tests.conftest.get_input_str(path)
Returns input json string
- tests.conftest.get_scan_input_str(scan_input_file='Scan_mid.json')
Returns the scan input json string
- Parameters
scan_input_file – name of the scan input file
- Returns
scan input json string
- Return type
- tests.conftest.health_state_aggregation_process_low()
Create aggregation process low object
- Yields
Healthstate aggregation process mid
- Return type
- tests.conftest.health_state_aggregation_process_mid()
Create aggregation process mid object
- Yields
Healthstate aggregation process mid
- Return type
- tests.conftest.json_factory()
Json factory for getting json files
- Returns
get json from files
- Return type
- tests.conftest.pytest_addoption(parser)
Pytest hook; implemented to add the –true-context option, used to indicate that a true Tango subsystem is available, so there is no need for a tango.test_context.MultiDeviceTestContext.
- Parameters
parser (
ArgumentParser
) – the command line options parser- Return type
- tests.conftest.pytest_sessionstart(session)
Pytest hook; prints info about tango version.
- Parameters
session (
Session
) – a pytest Session object- Return type
- tests.conftest.set_low_sdp_csp_leaf_node_availability_for_aggregation()
Setting low Csp subarray leaf node and Sdp subarray leaf node availabilty attribute isSubsystemAvailable as True for aggregation
- Return type
- tests.conftest.set_low_sdp_csp_mccs_admin_modes()
Setting low Csp subarray and Sdp subarray adminModes attribute as Online.
- tests.conftest.set_mid_sdp_csp_admin_modes()
Setting mid Csp subarray and Sdp subarray adminModes attribute as Online.
- tests.conftest.set_mid_sdp_csp_leaf_node_availability_for_aggregation()
Setting mid Csp subarray leaf node and Sdp subarray leaf node availabilty attribute isSubsystemAvailable as True for aggregation
- Return type
- tests.conftest.subarray_node(event_recorder, request)
Returns the instance of SubarrayNode class
- Parameters
event_recorder – Event recorder instance
request – pytest request object
- Yields
SubarrayNode instance
- Return type
- tests.conftest.tango_context(devices_to_load, request)
This Fixture provide the tango context fixture
- tests.conftest.task_callback()
Creates a mock callable for asynchronous testing
- Return type
MockCallable
- Returns
MockCallable
common_utils module
Path: tests/test_helpers/common_utils.py
Common utils class for a simple test harness.
- class tests.test_helpers.common_utils.SubarrayNode(deployment='MID')
Bases:
object
Class for Subarray Node device for test harness
- assert_command_completion(unique_id, event_recorder)
Checks if the command was completed successfully.
Raises AssertionError in case of failure.
- Parameters
unique_id (str) – Unique id of the command
event_recorder (
EventRecorder
) – Event Recorder
- Return type
- assert_command_completion_on_device(device_name, expected_state)
Check for device obsState to transition to the correct state.
- assert_command_failure(unique_id, exception_message, event_recorder, result_code=ska_tango_base.commands.ResultCode.FAILED)
Checks if the command pushed the correct error message event on its longRunningCommandResult attribute.
Raises AssertionError in case of failure.
- Parameters
unique_id (str) – Unique id of the command
exception_message (str) – Exception message in case of failure
event_recorder (
EventRecorder
) – Event Recorderresult_code (
ResultCode
) – ResultCode, default is ResultCode.FAILED
- Return type
- assert_health_state(healthState)
Asserts the SubarrayNode HealthState to be the HealthState specified.
Raises AssertionError in case of failure.
- Parameters
healthState (
HealthState
) – Health State- Return type
- assert_obs_state(obsstate)
Asserts the SubarrayNode ObsState to be the ObsState specified.
Raises AssertionError in case of failure.
- Parameters
obsstate (
ObsState
) – ObsState- Return type
- assert_obsstate_update(obs_state, event_recorder)
Checks if the command pushed the expected obsState event
Raises AssertionError in case of failure.
- Parameters
obs_state (ObsState) – ObsState to be expected
event_recorder (
EventRecorder
) – Event Recorder
- Return type
- get_device_obs_states()
Returns a dictionary with current device ObsStates
- Returns
Dictionary with device names as keys and their ObsStates
- Return type
- invoke_abort_command(event_recorder)
Invoke Abort command on Subarray Node
- Parameters
event_recorder (
EventRecorder
) – Event Recorder- Return type
- invoke_and_assert_command_rejected(command_name, exception_message, **kwargs)
Invokes the command on Subarray Node and asserts its rejection. Raises AssertionError in case of failure.
- invoke_command(command_name, input_str='')
Method to invoke given command on subarray node with given input json if any. Returns the unique id from command invocation.
- invoke_command_on_device(device_name, command, input_data=None)
Invokes the given command on the device with provided input.
- perform_action(device_names, actions)
Performs the said action on the given device
- reset_defects_for_devices(device_names)
Resets the defect parameters for given devices
- set_devices_availability(device_names, availability=True)
Set the device availability to the given value.
- set_devices_availablity(device_availability)
Sets the availability of devices with provided parameters.
- set_devices_defective(device_names, defective_params)
Sets the given devices defective with provided parameters.
- set_subarray_health_state_to_ok(event_recorder)
Set Subarray Health state to OK
- Parameters
event_recorder (
EventRecorder
) – Event Recorder- Return type
- updated_tear_down(event_recorder)
Teardown for integration and acceptance testing. Brings the subarray node back to EMPTY state.
Raises given exception if the flag is set True.
- Parameters
event_recorder (
EventRecorder
) – Event Recorder- Return type
- wait_for_attribute_to_change_to(device, attribute_name, attribute_value)
Wait for the attribute to change to given value.
- Parameters
- Raises
AssertionError – If the attribute value is not equal to the given value within the timeout period.
- Return type
- wait_for_leaf_node_obsstate(device_name, obsstate, timeout=100)
Wait for Device ObsState to be the given obsstate till timeout occurs.
Raises Exception in case of a timeout.
- wait_for_subarray_assign_resources(assign_resources_value, timeout=3)
Wait for assign resources value of Subarray
- wait_for_subarray_healthstate(healthstate, timeout=60)
Wait for Subarray Node healthState to be the given Healthstate till timeout occurs.
Raises Exception in case of a timeout.
- wait_for_subarray_obsstate(obsstate, timeout=100)
Wait for Subarray Node ObsState to be the given obsstate till timeout occurs.
Raises Exception in case of a timeout.
constants module
Path: tests/test_helpers/constants.py
Define all constants required for testing
event_recorder module
Path: tests/test_helpers/event_recorder.py
Implement Event checker class which can be used to validate events
- exception tests.test_helpers.event_recorder.AttributeNotSubscribed(message)
Bases:
Exception
Raise this exception when attribute is not subscribed
- class tests.test_helpers.event_recorder.EventRecorder
Bases:
object
Implement method required for validating events
- has_change_event_occurred(device, attribute_name, attribute_value, lookahead=9)
Validate Change Event occurred for provided attribute This method check attribute value changed within number of lookahead events
- Parameters
- Returns
Change Event occurred True or False.
- Return type
- Raises
AttributeNotSubscribed – If attribute is not subscribed.