Beispiel #1
0
def test_get_extensions():
    with mock.patch('girder_worker.__main__.app'):
        main()
        extensions = sorted(entrypoint.get_extensions())
        if six.PY2:
            assert extensions == ['core', 'plugin1', 'plugin2']
        else:
            assert extensions == ['plugin1', 'plugin2']
def test_register_extension():
    @decorators.argument('n', types.Integer)
    def echo(n):
        return n

    @app.task
    @decorators.argument('n', types.Integer)
    def echo_celery(n):
        return n

    tasks = {
        '%s.echo' % __name__: echo,
        '%s.echo_celery' % __name__: echo_celery
    }
    entrypoint.register_extension('echo_tasks', tasks)

    exts = entrypoint.get_extensions()
    assert 'echo_tasks' in exts
    assert entrypoint.get_extension_tasks('echo_tasks') == tasks

    celery_tasks = entrypoint.get_extension_tasks('echo_tasks',
                                                  celery_only=True)
    assert list(celery_tasks.keys()) == ['%s.echo_celery' % __name__]
    def test_register_extension(self):
        @decorators.argument('n', types.Integer)
        def echo(n):
            return n

        @app.task
        @decorators.argument('n', types.Integer)
        def echo_celery(n):
            return n

        tasks = {
            '%s.echo' % __name__: echo,
            '%s.echo_celery' % __name__: echo_celery
        }
        entrypoint.register_extension('echo_tasks', tasks)

        exts = entrypoint.get_extensions()
        self.assertIn('echo_tasks', exts)
        self.assertEqual(entrypoint.get_extension_tasks('echo_tasks'), tasks)

        celery_tasks = entrypoint.get_extension_tasks('echo_tasks',
                                                      celery_only=True)
        self.assertEqual(celery_tasks.keys(), ['%s.echo_celery' % __name__])
 def test_get_extensions(self, app):
     main()
     extensions = sorted(entrypoint.get_extensions())
     self.assertEqual(extensions, ['core', 'plugin1', 'plugin2'])
Beispiel #5
0
def listGirderWorkerExtensions(self):
    return sorted(get_extensions())
Beispiel #6
0
def listGirderWorkerExtensions(self):
    return sorted(get_extensions())