def setUp(self): self.factory_patcher = mock.patch( 'silverberg.thrift_client._ThriftClientFactory') self.factory = self.factory_patcher.start() def _create_factory(client_class, connection_lost): self.connection_lost = connection_lost self.factory.side_effect = _create_factory self.addCleanup(self.factory_patcher.stop) self.endpoint = mock.Mock() self.twisted_transport = mock.Mock() self.thrift_cassandra_client = mock.Mock(Client) def _connect(factory): self.connect_d = Deferred() wrapper = mock.Mock() wrapper.transport = self.twisted_transport wrapper.wrapped.client = self.thrift_cassandra_client return self.connect_d.addCallback(lambda _: wrapper) self.endpoint.connect.side_effect = _connect self.client = OnDemandThriftClient(self.endpoint, mock.Mock())
def __init__(self, cass_endpoint, keyspace, user=None, password=None, disconnect_on_cancel=False): self._client = OnDemandThriftClient(cass_endpoint, Cassandra.Client) self._keyspace = keyspace self._user = user self._password = password self._disconnect_on_cancel = disconnect_on_cancel
def __init__(self, cass_endpoint, keyspace, user=None, password=None): self._client = OnDemandThriftClient(cass_endpoint, Cassandra.Client) self._keyspace = keyspace self._user = user self._password = password