def test_get_msg(self): body = b'test-body' name = 'queue-name-get' rabbitpy.create_queue(queue_name=name) rabbitpy.publish(routing_key=name, body=body) result = rabbitpy.get(queue_name=name) self.assertEqual(result.body, body) rabbitpy.delete_queue(queue_name=name)
def test_get_msg(self): body = b'test-body' name = 'queue-name-get' rabbitpy.create_queue(os.environ['RABBITMQ_URL'], queue_name=name) rabbitpy.publish(os.environ['RABBITMQ_URL'], routing_key=name, body=body) result = rabbitpy.get(os.environ['RABBITMQ_URL'], queue_name=name) self.assertEqual(result.body, body) rabbitpy.delete_queue(os.environ['RABBITMQ_URL'], queue_name=name)
def test_publish_with_confirm(self): body = b'test-body' name = 'simple-publish' rabbitpy.create_queue(queue_name=name) self.assertTrue(rabbitpy.publish(routing_key=name, body=body, confirm=True)) result = rabbitpy.get(queue_name=name) self.assertEqual(result.body, body) rabbitpy.delete_queue(queue_name=name)
def test_publish_with_confirm(self): body = b'test-body' name = 'simple-publish' rabbitpy.create_queue(queue_name=name) self.assertTrue( rabbitpy.publish(routing_key=name, body=body, confirm=True)) result = rabbitpy.get(queue_name=name) self.assertEqual(result.body, body) rabbitpy.delete_queue(queue_name=name)
def test_get_empty(self): name = 'queue-name-get' rabbitpy.create_queue(queue_name=name) self.assertIsNone(rabbitpy.get(queue_name=name)) rabbitpy.delete_queue(queue_name=name)
def test_get_empty(self): name = 'queue-name-get' rabbitpy.create_queue(os.environ['RABBITMQ_URL'], queue_name=name) self.assertIsNone( rabbitpy.get(os.environ['RABBITMQ_URL'], queue_name=name)) rabbitpy.delete_queue(os.environ['RABBITMQ_URL'], queue_name=name)
import rabbitpy message = rabbitpy.get(queue_name='mqtt-messages') if message: message.pprint(True) message.ack() else: print('No message in queue')