Ejemplo n.º 1
0
 def setup(self):
     super(WhenUsingIntermediateMQueue, self).setup()
     self.queue = IntermediateMessageQueue()
     self.frame = Frame()
     self.frame.sock = Dingus()
Ejemplo n.º 2
0
 def setup(self):
     super(WhenUsingIntermediateMQueue, self).setup()
     self.queue = IntermediateMessageQueue()
     self.frame = Frame()
     self.frame.sock = Dingus()
Ejemplo n.º 3
0
class WhenUsingIntermediateMQueue(DingusTestCase(IntermediateMessageQueue,
    exclude=['Queue', 'QueueEmpty'])):

    def setup(self):
        super(WhenUsingIntermediateMQueue, self).setup()
        self.queue = IntermediateMessageQueue()
        self.frame = Frame()
        self.frame.sock = Dingus()

    def should_put_into_queue_and_get(self):
        headers = {'destination': '/queue/nose_test',
                   'persistent': 'true',
                   'bytes_message': 'true'}
        body = 'Testing'

        this_frame = self.frame.build_frame({'command': 'SEND',
                                             'headers': headers,
                                             'body': body})

        self.queue.put(this_frame)
        extracted_frame = self.queue.get(this_frame)

        assert 'destination' in extracted_frame.headers

    def should_not_put_into_queue(self):
        headers = {'persistent': 'true',
                   'bytes_message': 'true'}
        body = 'Testing'
        this_frame = self.frame.build_frame({'command': 'SEND',
                                             'headers': headers,
                                             'body': body})

        this_frame = Dingus()
        self.queue.put(this_frame)
        ret_frame = self.queue.get(this_frame)
        assert this_frame.calls('parse_frame', nb=False)

    def should_not_get_from_queue(self):
        headers = {'destination': '/queue/nose_test',
                   'persistent': 'true',
                   'bytes_message': 'true'}
        body = 'Testing'

        this_frame = self.frame.build_frame({'command': 'SEND',
                                             'headers': headers,
                                             'body': body})

        this_frame = Dingus()
        extracted_frame = self.queue.get(this_frame)
        print this_frame.calls
        assert this_frame.calls('parse_frame', nb=False)

    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

    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)

    def should_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 = this_frame
        my_frame.rqueue.put_nowait(my_frame)
        ret_frame = my_frame.get_reply(nb=True)
        assert isinstance(ret_frame, Frame)

    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
Ejemplo n.º 4
0
class WhenUsingIntermediateMQueue(
        DingusTestCase(IntermediateMessageQueue,
                       exclude=['Queue', 'QueueEmpty'])):
    def setup(self):
        super(WhenUsingIntermediateMQueue, self).setup()
        self.queue = IntermediateMessageQueue()
        self.frame = Frame()
        self.frame.sock = Dingus()

    def should_put_into_queue_and_get(self):
        headers = {
            'destination': '/queue/nose_test',
            'persistent': 'true',
            'bytes_message': 'true'
        }
        body = 'Testing'

        this_frame = self.frame.build_frame({
            'command': 'SEND',
            'headers': headers,
            'body': body
        })

        self.queue.put(this_frame)
        extracted_frame = self.queue.get(this_frame)

        assert 'destination' in extracted_frame.headers

    def should_not_put_into_queue(self):
        headers = {'persistent': 'true', 'bytes_message': 'true'}
        body = 'Testing'
        this_frame = self.frame.build_frame({
            'command': 'SEND',
            'headers': headers,
            'body': body
        })

        this_frame = Dingus()
        self.queue.put(this_frame)
        ret_frame = self.queue.get(this_frame)
        assert this_frame.calls('parse_frame', nb=False)

    def should_not_get_from_queue(self):
        headers = {
            'destination': '/queue/nose_test',
            'persistent': 'true',
            'bytes_message': 'true'
        }
        body = 'Testing'

        this_frame = self.frame.build_frame({
            'command': 'SEND',
            'headers': headers,
            'body': body
        })

        this_frame = Dingus()
        extracted_frame = self.queue.get(this_frame)
        print this_frame.calls
        assert this_frame.calls('parse_frame', nb=False)

    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

    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)

    def should_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 = this_frame
        my_frame.rqueue.put_nowait(my_frame)
        ret_frame = my_frame.get_reply(nb=True)
        assert isinstance(ret_frame, Frame)

    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