BaseCscTestCase

class lsst.ts.salobj.BaseCscTestCase

Bases: object

Base class for CSC tests.

Subclasses must:

  • Inherit both from this and asynctest.TestCase.
  • Override basic_make_csc to return a CSC.

Also we suggest:

Methods Summary

assert_next_sample(topic[, flush, timeout]) Wait for the next data sample for the specified topic, check specified fields for equality, and return the data.
assert_next_summary_state(state[, flush, …]) Wait for and check the next summaryState event.
basic_make_csc(initial_state, config_dir, …) Make and return a CSC.
check_bad_commands([bad_commands, good_commands]) Check that bad commands fail.
check_bin_script(name, index, exe_name[, …]) Test running the CSC command line script.
check_standard_state_transitions(…[, …]) Test standard CSC state transitions.
make_csc([initial_state, config_dir, …]) Create a CSC and remote and wait for them to start.
next_index()

Methods Documentation

assert_next_sample(topic, flush=False, timeout=60, **kwargs)

Wait for the next data sample for the specified topic, check specified fields for equality, and return the data.

Parameters:
topic : topics.ReadTopic

Topic to read, e.g. remote.evt_logMessage.

flush : bool, optional

Flush the read queue before waiting?

timeout : double, optional

Time limit for getting the data sample (sec).

kwargs : dict

Dict of field_name: expected_value The specified fields will be checked for equality.

Returns:
data : topic data type

The data read.

assert_next_summary_state(state, flush=False, timeout=60, remote=None)

Wait for and check the next summaryState event.

Parameters:
state : lsst.ts.salobj.State or int

Desired summary state.

flush : bool, optional

Flush the read queue before waiting?

timeout : float, optional

Time limit for getting the data sample (sec).

remote : Remote, optional

Remote to use; self.remote if None.

basic_make_csc(initial_state, config_dir, simulation_mode, **kwargs)

Make and return a CSC.

Parameters:
initial_state : lsst.ts.salobj.State or int

The initial state of the CSC.

config_dir : str

Directory of configuration files, or None for the standard configuration directory (obtained from ConfigureCsc._get_default_config_dir).

simulation_mode : int

Simulation mode.

kwargs : dict

Extra keyword arguments, if needed.

check_bad_commands(bad_commands=None, good_commands=None)

Check that bad commands fail.

Parameters:
bad_commands : List`[`str] or None, optional

Names of bad commands to try, or None for all commands.

good_commands : List`[`str] or None, optional

Names of good commands to skip, or None to skip none.

Notes

If a command appears in both lists, it is considered a good command, so it is skipped.

check_bin_script(name, index, exe_name, default_initial_state=<State.STANDBY: 5>, initial_state=None, settings_to_apply=None, cmdline_args=())

Test running the CSC command line script.

Parameters:
name : str

Name of SAL component, e.g. “Rotator”

index : int or None

SAL index of component.

exe_name : str

Name of executable, e.g. “run_rotator.py”

default_initial_state : lsst.ts.salobj.State, optional

The default initial state of the CSC. Ignored unless initial_state is None.

initial_state : lsst.ts.salobj.State or int or None, optional

The desired initial state of the CSC; used to specify the --state command-argument.

settings_to_apply : str or None, optional

Value for the --settings command-line argument. Only relevant if initial_state is one of salobj.State.DISABLED or salobj.State.ENABLED.

cmdline_args : List [str]

Additional command-line arguments, such as “–simulate”.

check_standard_state_transitions(enabled_commands, skip_commands=None, settingsToApply='', timeout=60)

Test standard CSC state transitions.

Parameters:
enabled_commands : List [str]

List of CSC-specific commands that are valid in the enabled state. Need not include the standard commands, which are “disable” and “setLogLevel” (which is valid in any state).

skip_commands : List [str] or None, optional

List of commands to skip.

settingsToApply : str, optional

Value for the settingsToApply argument for the start command.

timeout : float, optional

Time limit for state transition commands (seconds).

Notes

timeout is only used for state transition commands that are expected to succceed. STD_TIMEOUT is used for things that should happen quickly:

  • Commands that should fail, due to the CSC being in the wrong state.
  • The summaryState event after each state transition:
make_csc(initial_state=<State.STANDBY: 5>, config_dir=None, simulation_mode=0, log_level=None, timeout=60, **kwargs)

Create a CSC and remote and wait for them to start.

The csc is accessed as self.csc and the remote as self.remote.

Reads and checks all but the last summaryState event during startup.

Parameters:
name : str

Name of SAL component.

initial_state : lsst.ts.salobj.State or int, optional

The initial state of the CSC. Defaults to STANDBY.

config_dir : str, optional

Directory of configuration files, or None (the default) for the standard configuration directory (obtained from ConfigureCsc._get_default_config_dir).

simulation_mode : int, optional

Simulation mode. Defaults to 0 because not all CSCs support simulation. However, tests of CSCs that support simulation will almost certainly want to set this nonzero.

log_level : int or None, optional

Logging level, such as logging.INFO. If None then do not set the log level, leaving the default behavior of SalInfo: increase the log level to INFO.

timeout : float

Time limit for the CSC to start (seconds).

**kwargs : dict

Extra keyword arguments for basic_make_csc. For a configurable CSC this may include settings_to_apply, especially if initial_state is DISABLED or ENABLED.

Notes

Adds a logging.StreamHandler if one is not already present.

next_index()