本文整理汇总了Python中haigha.connection.Connection.__new__方法的典型用法代码示例。如果您正苦于以下问题:Python Connection.__new__方法的具体用法?Python Connection.__new__怎么用?Python Connection.__new__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类haigha.connection.Connection
的用法示例。
在下文中一共展示了Connection.__new__方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_init_without_keyword_args
# 需要导入模块: from haigha.connection import Connection [as 别名]
# 或者: from haigha.connection.Connection import __new__ [as 别名]
def test_init_without_keyword_args(self):
conn = Connection.__new__(Connection)
strategy = mock()
transport = mock()
mock(connection, 'ConnectionChannel')
expect(connection.ConnectionChannel).args(conn, 0, {}).returns('connection_channel')
expect(socket_transport.SocketTransport).args(conn).returns(transport)
expect(conn.connect).args('localhost', 5672)
conn.__init__()
assert_false(conn._debug)
assert_equal(logging.root, conn._logger)
assert_equal('guest', conn._user)
assert_equal('guest', conn._password)
assert_equal('localhost', conn._host)
assert_equal(5672, conn._port)
assert_equal('/', conn._vhost)
assert_equal(5, conn._connect_timeout)
assert_equal(None, conn._sock_opts)
assert_equal(None, conn._sock)
assert_equal(None, conn._heartbeat)
assert_equal(None, conn._open_cb)
assert_equal(None, conn._close_cb)
assert_equal('AMQPLAIN', conn._login_method)
assert_equal('en_US', conn._locale)
assert_equal(None, conn._client_properties)
assert_equal(conn._properties, {
'library': 'Haigha',
'library_version': __version__,
})
assert_false(conn._closed)
assert_false(conn._connected)
assert_equal(conn._close_info, {
'reply_code': 0,
'reply_text': 'first connect',
'class_id': 0,
'method_id': 0
})
assert_equals({
20: ChannelClass,
40: ExchangeClass,
50: QueueClass,
60: BasicClass,
90: TransactionClass
}, conn._class_map)
assert_equal({0: 'connection_channel'}, conn._channels)
assert_equal('\x05LOGINS\x00\x00\x00\x05guest\x08PASSWORDS\x00\x00\x00\x05guest',
conn._login_response)
assert_equal(0, conn._channel_counter)
assert_equal(65535, conn._channel_max)
assert_equal(65535, conn._frame_max)
assert_equal([], conn._output_frame_buffer)
assert_equal(transport, conn._transport)
transport.synchronous = True
assert_false(conn._synchronous)
assert_true(conn.synchronous)
assert_true(conn._synchronous_connect)
示例2: test_init_with_event_transport
# 需要导入模块: from haigha.connection import Connection [as 别名]
# 或者: from haigha.connection.Connection import __new__ [as 别名]
def test_init_with_event_transport(self):
conn = Connection.__new__( Connection )
strategy = mock()
mock( connection, 'ConnectionChannel' )
expect(connection.ConnectionChannel).args( conn, 0, {} ).returns( 'connection_channel' )
expect(event_transport.EventTransport).args( conn ).returns( 'EventTransport' )
expect(conn.connect).args( 'localhost', 5672 )
conn.__init__(transport='event')
示例3: test_init_without_keyword_args
# 需要导入模块: from haigha.connection import Connection [as 别名]
# 或者: from haigha.connection.Connection import __new__ [as 别名]
def test_init_without_keyword_args(self):
conn = Connection.__new__( Connection )
strategy = mock()
mock( connection, 'ConnectionChannel' )
mock( connection, 'ConnectionStrategy' )
expect(connection.ConnectionChannel).args( conn, 0 ).returns( 'connection_channel' )
expect(connection.ConnectionStrategy).args( conn, 'localhost', reconnect_cb=None ).returns( strategy )
expect(strategy.connect)
conn.__init__()
self.assertFalse( conn._debug )
self.assertEqual( logging.root, conn._logger )
self.assertEqual( 'guest', conn._user )
self.assertEqual( 'guest', conn._password )
self.assertEqual( 'localhost', conn._host )
self.assertEqual( '/', conn._vhost )
self.assertEqual( 5, conn._connect_timeout )
self.assertEqual( None, conn._sock_opts )
self.assertEqual( None, conn._sock )
self.assertEqual( None, conn._heartbeat )
self.assertEqual( None, conn._reconnect_cb )
self.assertEqual( None, conn._close_cb )
self.assertEqual( 'AMQPLAIN', conn._login_method )
self.assertEqual( 'en_US', conn._locale )
self.assertEqual( None, conn._client_properties )
self.assertEqual( conn._properties, {
'library': 'Haigha',
'library_version': VERSION,
} )
self.assertFalse( conn._closed )
self.assertFalse( conn._connected )
self.assertEqual( conn._close_info, {
'reply_code' : 0,
'reply_text' : 'first connect',
'class_id' : 0,
'method_id' : 0
} )
self.assertEqual( {0:'connection_channel'}, conn._channels )
self.assertEqual( '\x05LOGINS\x00\x00\x00\x05guest\x08PASSWORDS\x00\x00\x00\x05guest', conn._login_response )
self.assertEqual( 0, conn._channel_counter )
self.assertEqual( 65535, conn._channel_max )
self.assertEqual( 65535, conn._frame_max )
self.assertEqual( strategy, conn._strategy )
self.assertEqual( None, conn._output_buffer )
self.assertEqual( [], conn._output_frame_buffer )
示例4: setUp
# 需要导入模块: from haigha.connection import Connection [as 别名]
# 或者: from haigha.connection.Connection import __new__ [as 别名]
def setUp(self):
super(ConnectionTest,self).setUp()
self.connection = Connection.__new__( Connection )
self.connection._debug = False
self.connection._logger = self.mock()
self.connection._user = 'guest'
self.connection._password = 'guest'
self.connection._host = 'localhost'
self.connection._vhost = '/'
self.connection._connect_timeout = 5
self.connection._sock_opts = None
self.connection._sock = None # mock anything?
self.connection._heartbeat = None
self.connection._open_cb = self.mock()
self.connection._close_cb = self.mock()
self.connection._login_method = 'AMQPLAIN'
self.connection._locale = 'en_US'
self.connection._client_properties = None
self.connection._properties = {
'library': 'Haigha',
'library_version': 'x.y.z',
}
self.connection._closed = False
self.connection._connected = False
self.connection._close_info = {
'reply_code' : 0,
'reply_text' : 'first connect',
'class_id' : 0,
'method_id' : 0
}
self.connection._class_map = {}
self.connection._channels = {
0 : self.mock()
}
self.connection._login_response = 'loginresponse'
self.connection._channel_counter = 0
self.connection._channel_max = 65535
self.connection._frame_max = 65535
self.connection._frames_read = 0
self.connection._frames_written = 0
self.connection._strategy = self.mock()
self.connection._output_frame_buffer = []
self.connection._transport = mock()
self.connection._synchronous = False
self.connection._synchronous_connect = False