bec_lib.tests.utils.ClientMock#

class ClientMock(*args, forced=False, **kwargs)[source]#

Bases: BECClient

Initialize the BECClient

Parameters:
  • config (ServiceConfig, optional) – The configuration for the client. Defaults to None.

  • connector_cls (ConnectorBase, optional) – The connector class to use. Defaults to None.

  • wait_for_server (bool, optional) – Whether to wait for the server to be available before starting. Defaults to False.

  • forced (bool, optional) – Whether to force the initialization of a new client. Defaults to False.

Methods

alarms

get the next alarm with at least the specified severity

clear_all_alarms

remove all alarms from stack

delete_global_var

Delete a global variable from Redis

forget_all_user_scripts

unload / remove loaded user scripts from builtins.

forget_user_script

unload / remove a user scripts.

get_global_var

Get a global variable from Redis

global_vars

Get all available global variables

list_user_scripts

display all currently loaded user functions

load_all_user_scripts

Load all scripts from the scripts directory.

load_high_level_interface

Load a high level interface module.

load_user_script

load a user script file and import all its definitions

set_global_var

Set a global variable through Redis

show_all_alarms

print all unhandled alarms

show_all_commands

shutdown

shutdown the client and all its components

start

start the client

wait_for_service

Attributes

active_account

get the currently active target (e)account

pre_scan_macros

currently stored pre-scan macros

service_status

get the status of active services

started

status

get the current BECService status

username

get the current username

property active_account: str#

get the currently active target (e)account

alarms(severity=Alarms.WARNING)#

get the next alarm with at least the specified severity

clear_all_alarms()#

remove all alarms from stack

delete_global_var(name: str) None#

Delete a global variable from Redis

Parameters:

name (str) – Name of the variable

forget_all_user_scripts() None#

unload / remove loaded user scripts from builtins. Files will remain untouched.

Runs a callback of type EventType.NAMESPACE_UPDATE to inform clients about removing objects from the namesapce.

forget_user_script(name: str) None#

unload / remove a user scripts. The file will remain on disk.

get_global_var(name: str) Any#

Get a global variable from Redis

Parameters:

name (str) – Name of the variable

Returns:

Value of the variable

Return type:

Any

global_vars() str#

Get all available global variables

list_user_scripts()#

display all currently loaded user functions

load_all_user_scripts() None#

Load all scripts from the scripts directory.

Runs a callback of type EventType.NAMESPACE_UPDATE to inform clients about added objects in the namesapce.

load_high_level_interface(module_name: str) None#

Load a high level interface module. Runs a callback of type EventType.NAMESPACE_UPDATE to inform clients about added objects in the namesapce.

Parameters:

module_name (str) – The name of the module to load

load_user_script(file: str) None#

load a user script file and import all its definitions

Parameters:

file (str) – Full path to the script file.

property pre_scan_macros#

currently stored pre-scan macros

property service_status#

get the status of active services

set_global_var(name: str, val: Any) None#

Set a global variable through Redis

Parameters:
  • name (str) – Name of the variable

  • val (Any) – Value of the variable

show_all_alarms(severity=Alarms.WARNING)#

print all unhandled alarms

shutdown()#

shutdown the client and all its components

start()#

start the client

property status: BECStatus#

get the current BECService status

property username: str#

get the current username