==============
Client Mocking
==============

For testing purposes it is often useful to replace the client used for
communication with the CrateDB server with a stub or mock.

This can be done by passing a object of the Client class when calling the
``connect`` method::

    >>> from crate import client
    >>> class MyConnectionClient:
    ...     active_servers = ["localhost:4200"]
    ...     def __init__(self):
    ...         pass
    ...     def sql(self, stmt=None, parameters=None):
    ...         pass
    ...     def server_infos(self, server):
    ...         return ("localhost:4200", "my server", "0.42.0")
    >>> connection = client.connect([crate_host], client=MyConnectionClient())
