Robot Framework Integrated Development Environment (RIDE)
robotide.lib.robot.utils.connectioncache.ConnectionCache Class Reference

Cache for test libs to use with concurrent connections, processes, etc. More...

Public Member Functions

def __init__ (self, no_current_msg='No open connection.')
 
def __iter__ (self)
 
def __len__ (self)
 
def __nonzero__ (self)
 
def close_all (self, closer_method='close')
 Closes connections using given closer method and empties cache. More...
 
def empty_cache (self)
 Empties the connection cache. More...
 
def get_connection (self, alias_or_index=None)
 Get the connection specified by the given alias or index. More...
 
def register (self, connection, alias=None)
 Registers given connection with optional alias and returns its index. More...
 
def resolve_alias_or_index (self, alias_or_index)
 
def switch (self, alias_or_index)
 Switches to the connection specified by the given alias or index. More...
 

Public Attributes

 current
 

Properties

 current_index = property
 

Private Member Functions

def _resolve_alias (self, alias)
 
def _resolve_alias_or_index (self, alias_or_index)
 
def _resolve_index (self, index)
 
def current_index (self)
 
def current_index (self, index)
 

Private Attributes

 _aliases
 
 _connections
 
 _no_current
 

Static Private Attributes

def __getitem__ = get_connection
 

Detailed Description

Cache for test libs to use with concurrent connections, processes, etc.

The cache stores the registered connections (or other objects) and allows
switching between them using generated indices or user given aliases.
This is useful with any test library where there's need for multiple
concurrent connections, processes, etc.

This class can, and is, used also outside the core framework by SSHLibrary,
Selenium(2)Library, etc. Backwards compatibility is thus important when
doing changes.

Definition at line 35 of file connectioncache.py.

Constructor & Destructor Documentation

◆ __init__()

def robotide.lib.robot.utils.connectioncache.ConnectionCache.__init__ (   self,
  no_current_msg = 'No open connection.' 
)

Definition at line 37 of file connectioncache.py.

Member Function Documentation

◆ __iter__()

def robotide.lib.robot.utils.connectioncache.ConnectionCache.__iter__ (   self)

Definition at line 134 of file connectioncache.py.

◆ __len__()

def robotide.lib.robot.utils.connectioncache.ConnectionCache.__len__ (   self)

Definition at line 137 of file connectioncache.py.

◆ __nonzero__()

def robotide.lib.robot.utils.connectioncache.ConnectionCache.__nonzero__ (   self)

Definition at line 140 of file connectioncache.py.

◆ _resolve_alias()

def robotide.lib.robot.utils.connectioncache.ConnectionCache._resolve_alias (   self,
  alias 
)
private

Definition at line 159 of file connectioncache.py.

◆ _resolve_alias_or_index()

def robotide.lib.robot.utils.connectioncache.ConnectionCache._resolve_alias_or_index (   self,
  alias_or_index 
)
private

Definition at line 151 of file connectioncache.py.

◆ _resolve_index()

def robotide.lib.robot.utils.connectioncache.ConnectionCache._resolve_index (   self,
  index 
)
private

Definition at line 164 of file connectioncache.py.

◆ close_all()

def robotide.lib.robot.utils.connectioncache.ConnectionCache.close_all (   self,
  closer_method = 'close' 
)

Closes connections using given closer method and empties cache.

    If simply calling the closer method is not adequate for closing
    connections, clients should close connections themselves and use
    :meth:`empty_cache` afterwards.

Definition at line 119 of file connectioncache.py.

◆ current_index() [1/2]

def robotide.lib.robot.utils.connectioncache.ConnectionCache.current_index (   self)
private

Definition at line 46 of file connectioncache.py.

◆ current_index() [2/2]

def robotide.lib.robot.utils.connectioncache.ConnectionCache.current_index (   self,
  index 
)
private

Definition at line 55 of file connectioncache.py.

◆ empty_cache()

def robotide.lib.robot.utils.connectioncache.ConnectionCache.empty_cache (   self)

Empties the connection cache.

    Indexes of the new connections starts from 1 after this.

Definition at line 129 of file connectioncache.py.

◆ get_connection()

def robotide.lib.robot.utils.connectioncache.ConnectionCache.get_connection (   self,
  alias_or_index = None 
)

Get the connection specified by the given alias or index.

    If ``alias_or_index`` is ``None``, returns the current connection
    if it is active, or raises an error if it is not.

    Alias is whatever was given to :meth:`register` method and indices
    are returned by it. Index can be given either as an integer or
    as a string that can be converted to an integer. Raises an error
    if no connection with the given index or alias found.

Definition at line 100 of file connectioncache.py.

◆ register()

def robotide.lib.robot.utils.connectioncache.ConnectionCache.register (   self,
  connection,
  alias = None 
)

Registers given connection with optional alias and returns its index.

    Given connection is set to be the :attr:`current` connection.

    If alias is given, it must be a string. Aliases are case and space
    insensitive.

    The index of the first connection after initialization, and after
    :meth:`close_all` or :meth:`empty_cache`, is 1, second is 2, etc.

Definition at line 69 of file connectioncache.py.

◆ resolve_alias_or_index()

def robotide.lib.robot.utils.connectioncache.ConnectionCache.resolve_alias_or_index (   self,
  alias_or_index 
)

Definition at line 143 of file connectioncache.py.

◆ switch()

def robotide.lib.robot.utils.connectioncache.ConnectionCache.switch (   self,
  alias_or_index 
)

Switches to the connection specified by the given alias or index.

    Updates :attr:`current` and also returns its new value.

    Alias is whatever was given to :meth:`register` method and indices
    are returned by it. Index can be given either as an integer or
    as a string that can be converted to an integer. Raises an error
    if no connection with the given index or alias found.

Definition at line 86 of file connectioncache.py.

Member Data Documentation

◆ __getitem__

def robotide.lib.robot.utils.connectioncache.ConnectionCache.__getitem__ = get_connection
staticprivate

Definition at line 111 of file connectioncache.py.

◆ _aliases

robotide.lib.robot.utils.connectioncache.ConnectionCache._aliases
private

Definition at line 41 of file connectioncache.py.

◆ _connections

robotide.lib.robot.utils.connectioncache.ConnectionCache._connections
private

Definition at line 40 of file connectioncache.py.

◆ _no_current

robotide.lib.robot.utils.connectioncache.ConnectionCache._no_current
private

Definition at line 38 of file connectioncache.py.

◆ current

robotide.lib.robot.utils.connectioncache.ConnectionCache.current

Definition at line 39 of file connectioncache.py.

Property Documentation

◆ current_index

robotide.lib.robot.utils.connectioncache.ConnectionCache.current_index = property
static

Definition at line 44 of file connectioncache.py.


The documentation for this class was generated from the following file: