QueueFetcher makes dealing with SQS queues in Django easier
Project description
QueueFetcher allows you to deal with Amazon SQS queues in an easier manner in Django.
It provides:
run_queue management task to start the task from cli
QueueFetcher class to do the heavy lifting with the pieces seperated out and testable
Getting started
Install queue-fetcher from pip
Add queue_fetcher to INSTALLED_APPLICATIONS
Add to your settings.py:
TEST_SQS = False
QUEUES = {
'Internal Name': 'Name On Amazon'
}
Now build your tasks in your tasks package:
from queue_fetcher.tasks import QueueFetcher class SampleQueueTask(QueueFetcher): queue = 'test' def process_sample(self, msg): raise NotImplementedError('This does nothing.. yet')
QueueFetcher expects messages from SQS to contain a list of events, with each event containing a message_type attribute of something like update_transaction.
This is then dispatched to a function prefixed with process_.
Testing your Code
The queue-fetcher app includes a QueueTestCase class that removes the need to handle SQS in your test code. To use it, simple extend the class and use get_yaml or get_json to get your fixtures, located in the same app as your test.
from queue_fetcher.test import QueueTestCase
from .tasks import ExampleTaskClass
class ExampleTestCase(QueueTestCase):
"""
"""
def test_my_app(self):
"""
"""
fixture = self.get_json('exampleapp/test.sqs.json')
task = ExampleTaskClass()
task.read(fixture)
# Insert your assertions here
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for queue_fetcher-1.8.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0dcd6c5930baf204d2649c6c2fbb4d1a876354f8d3c8aa4b501fa52a29d6ee37 |
|
MD5 | 25ea1459ba5001821165b3bc719d769a |
|
BLAKE2b-256 | 4b65b052a44cd8269c8a3c23e125c8d44aee21805f7b5a6266cae9e05e083761 |