MockWriteTopic#

class lsst.ts.salobj.topics.MockWriteTopic(*, salinfo, attr_name, min_seq_num=1, max_seq_num=2147483647, initial_seq_num=None)#

Bases: WriteTopic

A version of WriteTopic that records every message written instead of actually writing it.

It is easiest to construct these by calling make_mock_write_topics. MockWriteTopic is only intended for unit tests and related short-term use; it saves every message, so long term use will leak memory.

Parameters:
  • salinfo (SalInfo) – SAL component information

  • attr_name (str) – Topic name with attribute prefix. The prefix must be one of: cmd_, evt_, tel_, or (only for the ackcmd topic) ack_.

  • min_seq_num (int or None, optional) – Minimum value for the private_seqNum field. The default is 1. If None then private_seqNum is not set; this is needed for the ackcmd writer, which sets the field itself.

  • max_seq_num (int, optional) – Maximum value for private_seqNum, inclusive. The default is the maximum allowed positive value (private_seqNum is a 4-byte signed int). Ignored if min_seq_num is None.

  • initial_seq_num (int, optional) – Initial sequence number; if None use min_seq_num.

data_list#

List of data written, with newer data at the end.

Type:

list [type_hints.BaseMsgType]

Plus the attributes of

WriteTopic

Methods Summary

write()

Write the current data and return a copy of the data written.

Methods Documentation

async write()#

Write the current data and return a copy of the data written.

Returns:

data – The data that was written. This can be useful to avoid race conditions (as found in RemoteCommand).

Return type:

type_hints.BaseMsgType

Raises:

RuntimeError – If not running.