This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!
Project Description

The missing test library for the Celery Python library. Some of the things graveolens can help with include:

  • Provide resultss to Celery task calls without hitting your broker.
  • Ensuring that you know exactly which tasks are called.
  • Easily assert the arguments of task calls.
  • Easily handle results when using send_task in Celery.

Returning Results

from my_app.celery import app
import gravelons

def test_my_task():
    with gravelons.activate() as celery:
        celery.add('my_app.task', {'done': True, 'status': 'OK'})

        result = app.send_task('my_app.task', 'test', id=3)

        # The result is an EagerResult from Celery.
        assert result.get() == {'done': True, 'status': 'OK'}

        # You can also check ALL the calls that Celery received.
        assert len(celery.calls) == 1
        assert celery.calls[0].name == 'http://twitter.com/api/1/foobar'
        assert celery.calls[0].args == ('test', )
        assert celery.calls[0].kwargs == {'id': 3}

Asserting Celery Calls

By default, if a result is added and unused this raises an AssertionError when the context manager exits, e.g.:

import gravelons

def test_my_task():
    with gravelons.activate() as celery:
        celery.add('my_app.task')

    # Assertion will be raised here because 'my_app.task' is never called.

This can be configured using the assert_all_tasks_called flag to activate().

Additionally, if a Celery task is called without having a result set-up then graveolens.NotMockedTask will be raised.

from my_app.celery import app
import gravelons

def test_my_task():
    with gravelons.activate() as celery:
        try:
            result = app.send_task('my_app.task', 'test', id=3)
        except graveolens.NotMockedTask:
            # Exception will be raised since my_app.task has no result.
            pass
Release History

Release History

0.1.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
graveolens-0.1.1-py2.py3-none-any.whl (5.5 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Nov 15, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting