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 |
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.
| def robotide.lib.robot.utils.connectioncache.ConnectionCache.__init__ | ( | self, | |
no_current_msg = 'No open connection.' |
|||
| ) |
Definition at line 37 of file connectioncache.py.
| def robotide.lib.robot.utils.connectioncache.ConnectionCache.__iter__ | ( | self | ) |
Definition at line 134 of file connectioncache.py.
| def robotide.lib.robot.utils.connectioncache.ConnectionCache.__len__ | ( | self | ) |
Definition at line 137 of file connectioncache.py.
| def robotide.lib.robot.utils.connectioncache.ConnectionCache.__nonzero__ | ( | self | ) |
Definition at line 140 of file connectioncache.py.
|
private |
Definition at line 159 of file connectioncache.py.
|
private |
Definition at line 151 of file connectioncache.py.
|
private |
Definition at line 164 of file connectioncache.py.
| 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.
|
private |
Definition at line 46 of file connectioncache.py.
|
private |
Definition at line 55 of file connectioncache.py.
| 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.
| 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.
| 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.
| def robotide.lib.robot.utils.connectioncache.ConnectionCache.resolve_alias_or_index | ( | self, | |
| alias_or_index | |||
| ) |
Definition at line 143 of file connectioncache.py.
| 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.
|
staticprivate |
Definition at line 111 of file connectioncache.py.
|
private |
Definition at line 41 of file connectioncache.py.
|
private |
Definition at line 40 of file connectioncache.py.
|
private |
Definition at line 38 of file connectioncache.py.
| robotide.lib.robot.utils.connectioncache.ConnectionCache.current |
Definition at line 39 of file connectioncache.py.
|
static |
Definition at line 44 of file connectioncache.py.