コード例 #1
0
ファイル: test_frame.py プロジェクト: z1pp4/python-stomp
 def should_not_get_message(self):
     my_frame = Frame()
     my_frame._getline = Dingus()
     my_frame._getline.return_value = None
     my_frame.iqueue.get = Dingus()
     my_frame.iqueue.get.return_value = None
     ret_frame = my_frame.get_message(nb=True)
     assert ret_frame is None
コード例 #2
0
ファイル: test_frame.py プロジェクト: z1pp4/python-stomp
    def should_fail_to_get_headers(self):
        my_frame = Frame()
        my_frame._getline = Dingus()
        my_frame._getline.return_value = \
                'RECEIPTreceipt-id:ID:nose-receipt123'

        nose_tools.assert_raises(UnknownBrokerResponseError,
                                 my_frame.parse_frame)
コード例 #3
0
 def __init__(self, hostname, port=61613):
     self.host = hostname
     self.port = port
     self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     self._subscribed_to = {}
     self._subscribed = None
     self._callback = None
     self.connected = None
     self.frame = Frame()
コード例 #4
0
ファイル: test_frame.py プロジェクト: z1pp4/python-stomp
    def should_set_bytes_message(self):
        my_frame = Frame()
        my_frame._getline = Dingus()
        body = 'Test 1'
        my_frame._getline.return_value = ('MESSAGE\nsession:ID:nose-session123'
                                          '\ncontent-length:%d\n\n%s\x00\n' %
                                          (len(body), body))
        this_frame = my_frame.parse_frame()

        assert 'bytes_message' in this_frame.headers
コード例 #5
0
ファイル: test_frame.py プロジェクト: z1pp4/python-stomp
    def should_get_error_from_broker(self):
        my_frame = Frame()
        my_frame._getline = Dingus()
        command = 'ERROR'
        header = 'message:Illegal command'
        body = 'Error Message'
        my_frame._getline.return_value = \
            '%s\n%s\ncontent-length:%d\n\n%s\n\x00' % (command,
                                                       header,
                                                       len(body),
                                                       body)

        nose_tools.assert_raises(BrokerErrorResponse, my_frame.parse_frame)
コード例 #6
0
ファイル: test_frame.py プロジェクト: z1pp4/python-stomp
 def should_not_get_reply(self):
     my_frame = Frame()
     command = 'SEND'
     body = 'Test 1'
     headers = {
         'destination': '/queue/nose_test',
         'persistent': 'true',
         'bytes_message': 'true'
     }
     my_frame.parse_frame = Dingus()
     this_frame = my_frame.build_frame({
         'command': command,
         'headers': headers,
         'body': body
     })
     my_frame.parse_frame.return_value = None
     ret_frame = my_frame.get_reply(nb=True)
     assert ret_frame is None
コード例 #7
0
ファイル: test_frame.py プロジェクト: z1pp4/python-stomp
 def should_get_message_and_return_frame(self):
     my_frame = Frame()
     my_frame._getline = Dingus()
     command = 'MESSAGE'
     body = 'Test 1'
     headers = {
         'session': 'ID:nose-session123',
         'content-length': '%d' % len(body)
     }
     my_frame.parse_frame = Dingus()
     this_frame = my_frame.build_frame({
         'command': command,
         'headers': headers,
         'body': body
     })
     my_frame.parse_frame.return_value = this_frame
     ret_frame = my_frame.get_message(nb=True)
     assert isinstance(ret_frame, Frame)
コード例 #8
0
ファイル: test_frame.py プロジェクト: z1pp4/python-stomp
    def should_get_line(self):
        command = 'CONNECTED'
        headers = {'session': 'ID:nose-session123'}
        body = '\x00'
        my_frame = Frame()
        self.frame.parse_frame = Dingus()
        this_frame = my_frame.build_frame({
            'command': command,
            'headers': headers,
            'body': body
        })
        self.frame.parse_frame.return_value = this_frame
        self.frame.connect(self.sockobj.connect(('localhost', 99999)))
        header = "session:%(session)s\n" % headers
        ret = '\n'.join([command, header, body])
        self.frame.sock.recv.return_value = ret
        self.frame._getline()

        assert self.frame.sock.calls('recv', 1)
コード例 #9
0
ファイル: test_frame.py プロジェクト: z1pp4/python-stomp
    def should_send_frame_and_return_frame(self):
        my_frame = Frame()
        my_frame._getline = Dingus()
        headers = {'destination': '/queue/nose_test', 'persistent': 'true'}
        body = {'body': 'Testing'}
        my_frame._getline.return_value = \
                'CONNECTED\nsession:ID:nose-session123\n\n\x00\n'
        my_frame.connect(self.sockobj.connect('localhost', 99999))
        this_frame = my_frame.build_frame(
            {
                'command': 'SEND',
                'headers': headers,
                'body': body
            },
            want_receipt=True)
        my_frame._getline.return_value = \
                'RECEIPT\nreceipt-id:ID:nose-receipt123\n\n\x00\n'
        send_frame = my_frame.send_frame(this_frame.as_string())

        assert isinstance(my_frame, Frame)
コード例 #10
0
ファイル: test_frame.py プロジェクト: z1pp4/python-stomp
 def setup(self):
     super(WhenBuildingFrames, self).setup()
     self.frame = Frame()
     self.sockobj = frame.socket.socket(socket.AF_INET, socket.SOCK_STREAM)
コード例 #11
0
ファイル: test_frame.py プロジェクト: z1pp4/python-stomp
 def should_return_frame_repr(self):
     my_frame = Frame()
     assert isinstance(repr(my_frame), type(''))
コード例 #12
0
ファイル: test_frame.py プロジェクト: z1pp4/python-stomp
 def should_not_get_line(self):
     my_frame = Frame()
     my_frame._getline = Dingus()
     my_frame._getline.return_value = None
     ret_value = my_frame.parse_frame()
     assert ret_value is None
コード例 #13
0
ファイル: test_frame.py プロジェクト: z1pp4/python-stomp
 def setup(self):
     super(WhenUsingIntermediateMQueue, self).setup()
     self.queue = IntermediateMessageQueue()
     self.frame = Frame()
     self.frame.sock = Dingus()
コード例 #14
0
ファイル: test_frame.py プロジェクト: z1pp4/python-stomp
 def setup(self):
     super(WhenSettingUp, self).setup()
     self.frame = Frame()
     self.sockobj = frame.socket.socket(socket.AF_INET, socket.SOCK_STREAM)