Python Microservices Development by Tarek Ziade

Python Microservices Development by Tarek Ziade

Author:Tarek Ziade [Ziade, Tarek]
Language: eng
Format: azw3, epub
Tags: COM060160 - COMPUTERS / Web / Web Programming, COM051360 - COMPUTERS / Programming Languages / Python, COM051000 - COMPUTERS / Programming / General
Publisher: Packt Publishing
Published: 2017-07-25T04:00:00+00:00


Mocking other asynchronous calls

If you do some messaging with Pika and RabbitMQ, the Pika library directly uses the socket module to interact with the server, and that makes it painful to mock because we would need to track what data is sent and received over the wire.

Like for Celery, you could just run a local RabbitMQ server for your tests--Travis-CI also making it available (https://docs.travis-ci.com/user/database-setup/).

Sending messages, in that case, is done as usual, and you can create a script that picks them in the Rabbit queues to verify them.

When you need to test a process where an event is received from RabbitMQ, if that happens via an HTTP call, as in our little AMQP-to-HTTP bridge, you can simply manually trigger the events from the tests.

What's important is to make sure you can run your tests without depending on other microservices. But dependencies on messaging servers such as Redis or RabbitMQ are not a problem as long as you can run them in a dedicated testing environment.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.