Beispiel #1
0
    async def test_it_calls_on_queue_error_if_message_length_is_too_big(self):
        content = {
            "artist": "Mr. Big",
            "album": "Big, Bigger, Biggest! The Best of Mr. Big",
            "song": "Rock & Roll Over"
        }
        json_content = json.dumps(content)

        Actual_Size = len(json_content)
        self.queue.max_message_length = Actual_Size - 1

        with patch.object(self.queue, '_handle_callback',
                          CoroutineMock()) as _handle_callback:
            await self.queue._handle_message(channel=self.queue._channel,
                                             body=json_content,
                                             envelope=self.envelope,
                                             properties=self.properties)

            consumer = self.queue.delegate
            self.assertFalse(consumer.on_queue_message.called)

            _handle_callback.assert_called_once_with(
                consumer.on_queue_error,
                body=json_content,
                delivery_tag=self.envelope.delivery_tag,
                error=typed_any(InvalidMessageSizeException),
                queue=self.queue)
Beispiel #2
0
    async def test_it_calls_on_queue_error_if_message_isnt_a_valid_json(self):
        content = "Subirusdoitiozin"
        with patch.object(self.queue, '_handle_callback',
                          CoroutineMock()) as _handle_callback:
            await self.queue._handle_message(channel=self.queue._channel,
                                             body=content,
                                             envelope=self.envelope,
                                             properties=self.properties)

            consumer = self.queue.delegate
            self.assertFalse(consumer.on_queue_message.called)

            _handle_callback.assert_called_once_with(
                consumer.on_queue_error,
                body=content,
                delivery_tag=self.envelope.delivery_tag,
                error=typed_any(UndecodableMessageException),
                queue=self.queue)
Beispiel #3
0
 def test_isntances_of_different_calsses_arent_equal(self):
     self.assertNotEqual(5, typed_any(str))
     self.assertNotEqual("abc", typed_any(int))
     self.assertNotEqual(ValueError(), typed_any(Exception))
Beispiel #4
0
 def test_instances_of_the_same_classes_are_equal(self):
     self.assertEqual(5, typed_any(int))
     self.assertEqual("abc", typed_any(str))
     self.assertEqual(Exception(), typed_any(ValueError))