当前位置: 首页>>代码示例>>Python>>正文


Python StompParser.get方法代码示例

本文整理汇总了Python中stompest.protocol.StompParser.get方法的典型用法代码示例。如果您正苦于以下问题:Python StompParser.get方法的具体用法?Python StompParser.get怎么用?Python StompParser.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stompest.protocol.StompParser的用法示例。


在下文中一共展示了StompParser.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_frames_with_optional_newlines_succeeds

# 需要导入模块: from stompest.protocol import StompParser [as 别名]
# 或者: from stompest.protocol.StompParser import get [as 别名]
 def test_frames_with_optional_newlines_succeeds(self):
     parser = StompParser()
     disconnect = commands.disconnect()
     frame = '\n%s\n' % disconnect
     parser.add(2 * frame)
     for _ in xrange(2):
         self.assertEqual(parser.get(), disconnect)
     self.assertEqual(parser.get(), None)
开发者ID:IngoScholtes,项目名称:stompest,代码行数:10,代码来源:parser_test.py

示例2: test_frames_with_optional_newlines_succeeds

# 需要导入模块: from stompest.protocol import StompParser [as 别名]
# 或者: from stompest.protocol.StompParser import get [as 别名]
 def test_frames_with_optional_newlines_succeeds(self):
     parser = StompParser()
     disconnect = commands.disconnect()
     frame = b'\n' + binaryType(disconnect) + b'\n'
     parser.add(2 * frame)
     for _ in range(2):
         self.assertEqual(parser.get(), disconnect)
     self.assertIsNone(parser.get())
开发者ID:nikipore,项目名称:stompest,代码行数:10,代码来源:parser_test.py

示例3: test_dont_unescape_bad_characters

# 需要导入模块: from stompest.protocol import StompParser [as 别名]
# 或者: from stompest.protocol.StompParser import get [as 别名]
 def test_dont_unescape_bad_characters(self):
     parser = StompParser(StompSpec.VERSION_1_2)
     frame = commands.send('*queue')
     parser.add(binaryType(frame))
     self.assertEqual(parser.get(), frame)
     for badCharacter in (b'\r', b'\n', b'\c', b'\\', b':', b'\\h'):
         self.assertRaises(StompFrameError, parser.add, binaryType(frame).replace(b'*', badCharacter))
     self.assertRaises(StompFrameError, parser.add, binaryType(commands.send('queue\\')))
     self.assertIsNone(parser.get())
开发者ID:nikipore,项目名称:stompest,代码行数:11,代码来源:parser_test.py

示例4: test_frames_with_heart_beats_succeeds

# 需要导入模块: from stompest.protocol import StompParser [as 别名]
# 或者: from stompest.protocol.StompParser import get [as 别名]
 def test_frames_with_heart_beats_succeeds(self):
     parser = StompParser(version=StompSpec.VERSION_1_1)
     disconnect = commands.disconnect()
     frame = b'\n' + binaryType(disconnect) + b'\n'
     parser.add(2 * frame)
     frames = []
     while parser.canRead():
         frames.append(parser.get())
     self.assertEqual(frames, [StompHeartBeat(), disconnect, StompHeartBeat(), StompHeartBeat(), disconnect, StompHeartBeat()])
     self.assertIsNone(parser.get())
开发者ID:nikipore,项目名称:stompest,代码行数:12,代码来源:parser_test.py

示例5: test_invalid_command

# 需要导入模块: from stompest.protocol import StompParser [as 别名]
# 或者: from stompest.protocol.StompParser import get [as 别名]
 def test_invalid_command(self):
     messages = ['RECEIPT\nreceipt-id:message-12345\n\n\x00', 'NACK\nsubscription:0\nmessage-id:007\n\n\x00']
     parser = StompParser('1.0')
     parser.add(messages[0])
     self.assertRaises(StompFrameError, parser.add, messages[1])
     self.assertEquals(parser.get(), StompFrame(StompSpec.RECEIPT, rawHeaders=((u'receipt-id', u'message-12345'),)))
     self.assertFalse(parser.canRead())
     self.assertEquals(parser.get(), None)
     parser = StompParser('1.1')
     parser.add(messages[1])
     self.assertEquals(parser.get(), StompFrame(command=u'NACK', rawHeaders=((u'subscription', u'0'), (u'message-id', u'007'))))
开发者ID:IngoScholtes,项目名称:stompest,代码行数:13,代码来源:parser_test.py

示例6: test_frame_parse_succeeds

# 需要导入模块: from stompest.protocol import StompParser [as 别名]
# 或者: from stompest.protocol.StompParser import get [as 别名]
    def test_frame_parse_succeeds(self):
        frame = StompFrame(
            StompSpec.SEND,
            {'foo': 'bar', 'hello ': 'there-world with space ', 'empty-value':'', '':'empty-header', StompSpec.DESTINATION_HEADER: '/queue/blah'},
            b'some stuff\nand more'
        )

        parser = StompParser()
        parser.add(binaryType(frame))
        self.assertEqual(parser.get(), frame)
        self.assertIsNone(parser.get())
开发者ID:nikipore,项目名称:stompest,代码行数:13,代码来源:parser_test.py

示例7: main

# 需要导入模块: from stompest.protocol import StompParser [as 别名]
# 或者: from stompest.protocol.StompParser import get [as 别名]
def main():
    parser = StompParser(version=StompSpec.VERSION_1_2)
    frame = binaryType(binaryFrame) + binaryType(textFrame) + binaryType(heartBeatFrame)
    for _ in createRange(N):
        for j in itertools.count():
            packet = frame[j * SLICE:(j + 1) * SLICE]
            if not packet:
                break
            parser.add(packet)
        while parser.canRead():
            parser.get()
开发者ID:nikipore,项目名称:stompest,代码行数:13,代码来源:parser_profile.py

示例8: test_invalid_command

# 需要导入模块: from stompest.protocol import StompParser [as 别名]
# 或者: from stompest.protocol.StompParser import get [as 别名]
 def test_invalid_command(self):
     messages = [b'RECEIPT\nreceipt-id:message-12345\n\n\x00', b'NACK\nsubscription:0\nmessage-id:007\n\n\x00']
     parser = StompParser(StompSpec.VERSION_1_0)
     parser.add(messages[0])
     self.assertRaises(StompFrameError, parser.add, messages[1])
     self.assertEqual(parser.get(), StompFrame(StompSpec.RECEIPT, rawHeaders=(('receipt-id', 'message-12345'),)))
     self.assertFalse(parser.canRead())
     self.assertIsNone(parser.get())
     parser = StompParser(StompSpec.VERSION_1_1)
     parser.add(messages[1])
     self.assertEqual(parser.get(), StompFrame(command='NACK', rawHeaders=(('subscription', '0'), ('message-id', '007')), version=StompSpec.VERSION_1_1))
开发者ID:nikipore,项目名称:stompest,代码行数:13,代码来源:parser_test.py

示例9: test_no_newline

# 需要导入模块: from stompest.protocol import StompParser [as 别名]
# 或者: from stompest.protocol.StompParser import get [as 别名]
 def test_no_newline(self):
     headers = {'x': 'y'}
     body = b'testing 1 2 3'
     frameBytes = binaryType(StompFrame(StompSpec.MESSAGE, headers, body))
     self.assertTrue(frameBytes.endswith(b'\x00'))
     parser = StompParser()
     parser.add(frameBytes)
     frame = parser.get()
     self.assertEqual(StompSpec.MESSAGE, frame.command)
     self.assertEqual(headers, frame.headers)
     self.assertEqual(body, frame.body)
     self.assertEqual(parser.get(), None)
开发者ID:nikipore,项目名称:stompest,代码行数:14,代码来源:parser_test.py

示例10: test_no_newline

# 需要导入模块: from stompest.protocol import StompParser [as 别名]
# 或者: from stompest.protocol.StompParser import get [as 别名]
 def test_no_newline(self):
     headers = {'x': 'y'}
     body = 'testing 1 2 3'
     frameBytes = str(StompFrame(StompSpec.MESSAGE, headers, body))
     self.assertTrue(frameBytes.endswith('\x00'))
     parser = StompParser()
     parser.add(self._generate_bytes(frameBytes))
     frame = parser.get()
     self.assertEquals(StompSpec.MESSAGE, frame.command)
     self.assertEquals(headers, frame.headers)
     self.assertEquals(body, frame.body)
     self.assertEquals(parser.get(), None)
开发者ID:IngoScholtes,项目名称:stompest,代码行数:14,代码来源:parser_test.py

示例11: test_binary_body

# 需要导入模块: from stompest.protocol import StompParser [as 别名]
# 或者: from stompest.protocol.StompParser import get [as 别名]
    def test_binary_body(self):
        body = binascii.a2b_hex('f0000a09')
        headers = {'content-length': str(len(body))}
        frameBytes = str(StompFrame(StompSpec.MESSAGE, headers, body))
        self.assertTrue(frameBytes.endswith('\x00'))
        parser = StompParser()
        parser.add(frameBytes)
        frame = parser.get()
        self.assertEquals(StompSpec.MESSAGE, frame.command)
        self.assertEquals(headers, frame.headers)
        self.assertEquals(body, frame.body)

        self.assertEquals(parser.get(), None)
开发者ID:IngoScholtes,项目名称:stompest,代码行数:15,代码来源:parser_test.py

示例12: test_reset_succeeds

# 需要导入模块: from stompest.protocol import StompParser [as 别名]
# 或者: from stompest.protocol.StompParser import get [as 别名]
    def test_reset_succeeds(self):
        frame = StompFrame(
            command=StompSpec.SEND,
            headers={'foo': 'bar', 'hello ': 'there-world with space ', 'empty-value':'', '':'empty-header', StompSpec.DESTINATION_HEADER: '/queue/blah'},
            body=b'some stuff\nand more'
        )
        parser = StompParser()

        parser.add(binaryType(frame))
        parser.reset()
        self.assertIsNone(parser.get())
        parser.add(binaryType(frame)[:20])
        self.assertIsNone(parser.get())
开发者ID:nikipore,项目名称:stompest,代码行数:15,代码来源:parser_test.py

示例13: test_duplicate_headers

# 需要导入模块: from stompest.protocol import StompParser [as 别名]
# 或者: from stompest.protocol.StompParser import get [as 别名]
    def test_duplicate_headers(self):
        command = StompSpec.SEND
        rawFrame = '%s\nfoo:bar1\nfoo:bar2\n\nsome stuff\nand more\x00' % (command,)

        parser = StompParser()
        parser.add(rawFrame.encode())
        parsedFrame = parser.get()
        self.assertIsNone(parser.get())

        self.assertEqual(parsedFrame.command, command)
        self.assertEqual(parsedFrame.headers, {'foo': 'bar1'})
        self.assertEqual(parsedFrame.rawHeaders, [('foo', 'bar1'), ('foo', 'bar2')])
        self.assertEqual(parsedFrame.body, b'some stuff\nand more')
开发者ID:nikipore,项目名称:stompest,代码行数:15,代码来源:parser_test.py

示例14: test_add_throws_FrameError_on_invalid_command

# 需要导入模块: from stompest.protocol import StompParser [as 别名]
# 或者: from stompest.protocol.StompParser import get [as 别名]
    def test_add_throws_FrameError_on_invalid_command(self):
        parser = StompParser()

        self.assertRaises(StompFrameError, parser.add, b'HELLO\n\n\x00')
        self.assertFalse(parser.canRead())
        parser.add(('%s\n\n\x00' % StompSpec.DISCONNECT).encode())
        self.assertEqual(StompFrame(StompSpec.DISCONNECT), parser.get())
        self.assertFalse(parser.canRead())
开发者ID:nikipore,项目名称:stompest,代码行数:10,代码来源:parser_test.py

示例15: test_strip_line_delimiter

# 需要导入模块: from stompest.protocol import StompParser [as 别名]
# 或者: from stompest.protocol.StompParser import get [as 别名]
    def test_strip_line_delimiter(self):
        queue = '/queue/test'
        frame = commands.send(queue)
        frameWithStripLineDelimiter = commands.send(queue + '\r')
        for (version, stripLineDelimiter) in [
            (StompSpec.VERSION_1_0, False),
            (StompSpec.VERSION_1_1, False),
            (StompSpec.VERSION_1_2, True)
        ]:
            parser = StompParser(version)
            parser.add(binaryType(frameWithStripLineDelimiter))
            self.assertEqual(parser.get(), frame if stripLineDelimiter else frameWithStripLineDelimiter)

        frameWithCarriageReturn = commands.send(queue + '\r', version=StompSpec.VERSION_1_2)
        parser = StompParser(StompSpec.VERSION_1_2)
        parser.add(binaryType(frameWithCarriageReturn))
        self.assertEqual(parser.get().headers[StompSpec.DESTINATION_HEADER], queue + '\r')
开发者ID:nikipore,项目名称:stompest,代码行数:19,代码来源:parser_test.py


注:本文中的stompest.protocol.StompParser.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。