本文整理汇总了Python中silverberg.client.CQLClient.disconnect方法的典型用法代码示例。如果您正苦于以下问题:Python CQLClient.disconnect方法的具体用法?Python CQLClient.disconnect怎么用?Python CQLClient.disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类silverberg.client.CQLClient
的用法示例。
在下文中一共展示了CQLClient.disconnect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_disconnect
# 需要导入模块: from silverberg.client import CQLClient [as 别名]
# 或者: from silverberg.client.CQLClient import disconnect [as 别名]
def test_disconnect(self):
"""
When disconnect is called, the on demand thrift client is disconnected
"""
client = CQLClient(self.endpoint, 'blah')
self.assertFired(client.describe_version())
client.disconnect()
self.twisted_transport.loseConnection.assert_called_once_with()
示例2: test_disconnect_on_cancel_returns_correct_value
# 需要导入模块: from silverberg.client import CQLClient [as 别名]
# 或者: from silverberg.client.CQLClient import disconnect [as 别名]
def test_disconnect_on_cancel_returns_correct_value(self):
"""
with disconnect_on_cancel=True, the value from execute_cql3_query is
returned before cancellation
"""
exec_d = defer.Deferred()
self.client_proto.execute_cql3_query.side_effect = lambda *_: exec_d
client = CQLClient(self.endpoint, "abc", disconnect_on_cancel=True)
client.disconnect = mock.Mock()
d = client.execute("query", {}, ConsistencyLevel.ONE)
self.assertNoResult(d)
self.assertFalse(client.disconnect.called)
exec_d.callback(self.mock_results)
self.assertEqual(self.successResultOf(d), 1)
self.assertFalse(client.disconnect.called)
示例3: test_no_disconnect_on_cancel
# 需要导入模块: from silverberg.client import CQLClient [as 别名]
# 或者: from silverberg.client.CQLClient import disconnect [as 别名]
def test_no_disconnect_on_cancel(self):
"""
If not given, cancellation of running query should not try to disconnect
the TCP connection
"""
self.client_proto.execute_cql3_query.side_effect = lambda *_: defer.Deferred()
client = CQLClient(self.endpoint, "abc", disconnect_on_cancel=False)
client.disconnect = mock.Mock()
d = client.execute("query", {}, ConsistencyLevel.ONE)
self.assertNoResult(d)
self.assertFalse(client.disconnect.called)
d.cancel()
self.failureResultOf(d, defer.CancelledError)
self.assertFalse(client.disconnect.called)
示例4: test_disconnect_on_cancel
# 需要导入模块: from silverberg.client import CQLClient [as 别名]
# 或者: from silverberg.client.CQLClient import disconnect [as 别名]
def test_disconnect_on_cancel(self):
"""
If allowed, cancellation of running query will also try to disconnect
the TCP connection
"""
self.client_proto.execute_cql3_query.side_effect = lambda *_: defer.Deferred()
client = CQLClient(self.endpoint, 'abc', disconnect_on_cancel=True)
client.disconnect = mock.Mock()
d = client.execute('query', {}, ConsistencyLevel.ONE)
self.assertNoResult(d)
self.assertFalse(client.disconnect.called)
d.cancel()
self.failureResultOf(d, defer.CancelledError)
client.disconnect.assert_called_one_with()