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:
- Add a method
test_standard_state_transitions
which callscheck_standard_state_transitions
. - Add a method
test_bin_script
which callscheck_bin_script
, assuming you have a binary script to run your CSC.
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=5, **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.
- topic :
-
assert_next_summary_state
(state, flush=False, timeout=5, remote=None)¶ Wait for and check the next
summaryState
event.Parameters: - state :
lsst.ts.salobj.State
orint
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.
- state :
-
basic_make_csc
(initial_state, config_dir, simulation_mode, **kwargs)¶ Make and return a CSC.
- initial_state :
lsst.ts.salobj.State
orint
(optional) - The initial state of the CSC. Ignored except in simulation mode because in normal operation the initial state is the current state of the controller.
- config_dir :
str
- Directory of configuration files, or None for the standard
configuration directory (obtained from
get_default_config_dir
). - simulation_mode :
int
- Simulation mode.
- kwargs :
dict
- Extra keyword arguments, if needed.
- initial_state :
-
check_bad_commands
(bad_commands=None, good_commands=None)¶ Check that bad commands fail.
Parameters: 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, initial_state=<State.STANDBY: 5>, cmdline_args=())¶ Test running the CSC command line script.
Parameters: - name :
str
Name of SAL component, e.g. “Rotator”
- index :
int
orNone
SAL index of component.
- exe_name :
str
Name of executable, e.g. “run_rotator.py”
- initial_state :
lsst.ts.salobj.State
orint
(optional) The expected initial state of the CSC.
- cmdline_args :
List
[str
] Additional command-line arguments, such as “–simulate”.
- name :
-
check_standard_state_transitions
(enabled_commands, skip_commands=None)¶ Test standard CSC state transitions.
Parameters:
-
make_csc
(initial_state, config_dir=None, simulation_mode=0, log_level=20, **kwargs)¶ Create a CSC and remote and wait for them to start.
The csc is accessed as
self.csc
and the remote asself.remote
.If your CSC is indexed, we suggest you use a different index for each call, e.g. by using
index_generator
.Parameters: - name :
str
Name of SAL component.
- index :
int
orNone
(optional) SAL component index, or 0 or None if the component is not indexed. A value is required if the component is indexed.
- initial_state :
lsst.ts.salobj.State
orint
(optional) The initial state of the CSC.
- config_dir :
str
(optional) Directory of configuration files, or None for the standard configuration directory (obtained from
get_default_config_dir
).- simulation_mode :
int
(optional) Simulation mode.
- log_level :
int
(optional) Logging level, such as
logging.INFO
.- **kwargs :
dict
Extra keyword arguments for
basic_make_csc
.
- name :
-
next_index
()¶
- Inherit both from this and