Exemple #1
0
def flask_celery_app(flask_celery):
    test_app = flask_celery.get_celery_app()
    test_app.loader.import_task_module("celery.contrib.testing.tasks")
    with setup_default_app(test_app):
        test_app.set_default()
        test_app.set_current()
        yield test_app
Exemple #2
0
    def setUp(self):
        celery_app = TestApp(set_as_current=False,
                             enable_logging=True,
                             config=self['celery_config'],
                             **self['celery_parameters'])
        self['celery_app_fixture'] = setup_default_app(celery_app)
        self['celery_app_fixture'].__enter__()

        for module in self['celery_includes']:
            celery_app.loader.import_task_module(module)

        self['celery_worker_fixture'] = start_worker(
            celery_app, pool='prefork', **self['celery_worker_parameters'])
        self['celery_worker_fixture'].__enter__()
Exemple #3
0
def _create_app(enable_logging=False,
                use_trap=False,
                parameters={},
                **config):
    # type: (Any, **Any) -> Celery
    """Utility context used to setup Celery app for pytest fixtures."""
    test_app = TestApp(
        set_as_current=False,
        enable_logging=enable_logging,
        config=config,
        **parameters
    )
    with setup_default_app(test_app, use_trap=use_trap):
        yield test_app
def swh_scheduler_celery_app():
    """Set up a Celery app as swh.scheduler and swh worker tests would expect it"""
    test_app = TestApp(
        set_as_current=True,
        enable_logging=True,
        task_cls="swh.scheduler.task:SWHTask",
        config={
            "accept_content": ["application/x-msgpack", "application/json"],
            "task_serializer": "msgpack",
            "result_serializer": "json",
        },
    )
    with setup_default_app(test_app, use_trap=False):
        from swh.scheduler.celery_backend import config

        config.app = test_app
        test_app.set_default()
        test_app.set_current()
        yield test_app
Exemple #5
0
def dagster_celery_app():
    app = make_app()
    with setup_default_app(app, use_trap=False):
        yield app
Exemple #6
0
def dagster_celery_app(rabbitmq):  # pylint: disable=redefined-outer-name, unused-argument
    app = make_app()
    execute_plan = create_task(app)  # pylint: disable=unused-variable

    with setup_default_app(app, use_trap=False):
        yield app