Skip to content

Commit

Permalink
Merge cc40646 into cbfb780
Browse files Browse the repository at this point in the history
  • Loading branch information
egabancho committed May 16, 2017
2 parents cbfb780 + cc40646 commit d9075bf
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 7 deletions.
12 changes: 10 additions & 2 deletions docs/_ext/ultramock.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,21 @@
try:
import unittest.mock as mock
except ImportError:
import mock
from mock import mock

# skip `_is_magic` check.
orig_is_magic = mock._is_magic


def always_false(*args, **kwargs):
return False


# avoid spec configuration for mocked classes with super classes.
# honestly this does not happen very often and is kind of a tricky case.
orig_mock_add_spec = mock.NonCallableMock._mock_add_spec


def mock_add_spec_fake(self, spec, spec_set):
orig_mock_add_spec(self, None, None)

Expand Down Expand Up @@ -77,15 +81,19 @@ def __getattr__(self, key):

# overwrite imports
orig_import = __import__


def import_mock(name, *args, **kwargs):
try:
return orig_import(name, *args, **kwargs)
except ImportError:
return MockedModule(name)
import_patch = mock.patch('__builtin__.__import__', side_effect=import_mock)


# public methods
import_patch = mock.patch('__builtin__.__import__', side_effect=import_mock)


def activate():
mock._is_magic = always_false
mock.NonCallableMock._mock_add_spec = mock_add_spec_fake
Expand Down
4 changes: 3 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@

# Get the version string. Cannot be done with import!
g = {}
with open(os.path.join('..', 'invenio_celery', 'version.py'), 'rt') as fp:
with open(os.path.join(os.path.dirname(__file__), '..',
'invenio_celery', 'version.py'),
'rt') as fp:
exec(fp.read(), g)
version = g['__version__']

Expand Down
20 changes: 20 additions & 0 deletions invenio_celery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,26 @@ def sum(x, y):
from mymoudle.tasks import sum
result = sum.delay(2, 2)
Periodic tasks
--------------
Periodic tasks can be configured via ``CELERYBEAT_SCHEDULE`` configuration
variable:
.. code-block:: python
# config.py
CELERYBEAT_SCHEDULE = {
'indexer': {
'task': 'invenio_indexer.tasks.process_bulk_queue',
'schedule': timedelta(minutes=5),
},
}
For further information about see `Periodic Tasks
<http://docs.celeryproject.org/en/latest/userguide/periodic-tasks.html>`_
chapter of the `Celery documentation
<http://docs.celeryproject.org/en/latest/index.html>`_.
Celery workers
--------------
Expand Down
3 changes: 2 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
# as an Intergovernmental Organization or submit itself to any jurisdiction.

[pytest]
addopts = --pep8 --ignore=docs --cov=invenio_celery --cov-report=term-missing
pep8ignore = docs/conf.py ALL
addopts = --pep8 --doctest-glob="*.rst" --doctest-modules --cov=invenio_celery --cov-report=term-missing docs tests invenio_celery
3 changes: 1 addition & 2 deletions run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ pydocstyle invenio_celery tests && \
isort -rc -c -df && \
check-manifest --ignore ".travis-*" && \
sphinx-build -qnNW docs docs/_build/html && \
python setup.py test && \
sphinx-build -qnNW -b doctest docs docs/_build/doctest
python setup.py test
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
]

install_requires = [
'Flask-CeleryExt>=0.2.0',
'Flask-CeleryExt>=0.3.0',
'Flask>=0.11',
'redis>=2.10.0',
'msgpack-python>=0.4.6',
Expand Down

0 comments on commit d9075bf

Please sign in to comment.