def test_credentials(self): connection = FakeConnection() connection.parameters['username'] = '******' connection.parameters['password'] = '******' channel = Channel0(connection) credentials = channel._credentials() self.assertEqual(credentials, '\0guest\0password')
def test_forcefully_closed_connection(self): connection = FakeConnection() connection.set_state(connection.OPEN) channel = Channel0(connection) channel._close_connection( Connection.Close(reply_text=b'', reply_code=500) ) self.assertTrue(connection.is_closed) self.assertRaises(AMQPConnectionError, connection.check_for_errors)
def test_close_connection(self): connection = FakeConnection() connection.set_state(connection.OPEN) channel = Channel0(connection) self.assertTrue(connection.is_open) channel._close_connection( Connection.Close(reply_text=b'', reply_code=200) ) self.assertEqual(connection.exceptions, []) self.assertTrue(connection.is_closed)
def test_send_start_ok_frame(self): connection = FakeConnection() connection.parameters['username'] = '******' connection.parameters['password'] = '******' channel = Channel0(connection) channel._send_start_ok_frame() self.assertNotEqual(connection.frames_out, []) channel_id, frame_out = connection.frames_out.pop() self.assertEqual(channel_id, 0) self.assertIsInstance(frame_out, Connection.StartOk) self.assertNotEqual(frame_out.locale, '') self.assertIsNotNone(frame_out.locale)