class documentation

class Session: (source)

View In Hierarchy

A mock remote session of a single connection and 1 or more command execs. Allows quick configuration of expected remote state, and also helps generate the necessary test mocks used by `MockRemote` itself. Only useful when handed into `MockRemote`. The parameters ``cmd``, ``out``, ``err``, ``exit`` and ``waits`` are all shorthand for the same constructor arguments for a single anonymous `.Command`; see `.Command` for details. To give fully explicit `.Command` objects, use the ``commands`` parameter. :param str user: :param str host: :param int port: Sets up expectations that a connection will be generated to the given user, host and/or port. If ``None`` (default), no expectations are generated / any value is accepted. :param commands: Iterable of `.Command` objects, used when mocking nontrivial sessions involving >1 command execution per host. Default: ``None``. .. note:: Giving ``cmd``, ``out`` etc alongside explicit ``commands`` is not allowed and will result in an error. .. versionadded:: 2.1

Method __init__ Undocumented
Method generate_mocks Mocks `~paramiko.client.SSHClient` and `~paramiko.channel.Channel`.
Method sanity_check Undocumented
Instance Variable channels Undocumented
Instance Variable client Undocumented
Instance Variable commands Undocumented
Instance Variable host Undocumented
Instance Variable port Undocumented
Instance Variable user Undocumented
def __init__(self, host=None, user=None, port=None, commands=None, cmd=None, out=None, in_=None, err=None, exit=None, waits=None): (source)

Undocumented

def generate_mocks(self): (source)

Mocks `~paramiko.client.SSHClient` and `~paramiko.channel.Channel`. Specifically, the client will expect itself to be connected to ``self.host`` (if given), the channels will be associated with the client's `~paramiko.transport.Transport`, and the channels will expect/provide command-execution behavior as specified on the `.Command` objects supplied to this `.Session`. The client is then attached as ``self.client`` and the channels as ``self.channels``. :returns: ``None`` - this is mostly a "deferred setup" method and callers will just reference the above attributes (and call more methods) as needed. .. versionadded:: 2.1

def sanity_check(self): (source)

Undocumented

channels = (source)

Undocumented

Undocumented

commands = (source)

Undocumented

Undocumented

Undocumented

Undocumented