Ejemplo n.º 1
0
def script_info(app, datastore):
    try:
        from flask.cli import ScriptInfo
    except ImportError:
        from flask_cli import ScriptInfo

    def create_app(info):
        app.config.update(
            **{'SECURITY_USER_IDENTITY_ATTRIBUTES': ('email', 'username')})
        app.security = Security(app, datastore=datastore)
        return app

    return ScriptInfo(create_app=create_app)
Ejemplo n.º 2
0
def set_settings(ctx, instance=None):
    """Pick correct settings instance and set it to a global variable."""

    global settings

    settings = None

    if instance is not None:
        sys.path.insert(0, ".")
        settings = import_settings(instance)
    elif "FLASK_APP" in os.environ:  # pragma: no cover
        with suppress(ImportError, click.UsageError):
            from flask.cli import ScriptInfo  # noqa

            flask_app = ScriptInfo().load_app()
            settings = flask_app.config
            click.echo(
                click.style("Flask app detected",
                            fg="white",
                            bg="bright_black"))
    elif "DJANGO_SETTINGS_MODULE" in os.environ:  # pragma: no cover
        sys.path.insert(0, os.path.abspath(os.getcwd()))
        try:
            # Django extension v2
            from django.conf import settings  # noqa

            settings.DYNACONF.configure()
        except AttributeError:
            settings = LazySettings()

        if settings is not None:
            click.echo(
                click.style("Django app detected",
                            fg="white",
                            bg="bright_black"))

    if settings is None:

        if instance is None and "--help" not in click.get_os_args():
            if ctx.invoked_subcommand and ctx.invoked_subcommand not in [
                    "init",
            ]:
                warnings.warn(
                    "Starting on 3.x the param --instance/-i is now required. "
                    "try passing it `dynaconf -i path.to.settings <cmd>` "
                    "Example `dynaconf -i config.settings list` ")
                settings = legacy_settings
            else:
                settings = LazySettings(create_new_settings=True)
        else:
            settings = LazySettings()
Ejemplo n.º 3
0
def test_migrate_secret_key():
    """Test cli command for SECRET_KEY change."""
    def _config_loader(app, **kwargs):
        app.config['CONFIG_LOADER'] = True
        app.config.update(kwargs)

    create_app = create_app_factory('test', config_loader=_config_loader)
    app = create_app(KWARGS_TEST=True)
    script_info = ScriptInfo(create_app=lambda info: app)

    # Check that CLI command fails when the SECRET_KEY is not set.
    with app.app_context():
        runner = CliRunner()
        result = runner.invoke(
            instance, ['migrate-secret-key', '--old-key', 'OLD_SECRET_KEY'],
            obj=script_info)
        assert result.exit_code == 1
        assert 'Error: SECRET_KEY is not set in the configuration.' in \
            result.output

    app.secret_key = "SECRET"
    with patch('pkg_resources.EntryPoint') as MockEntryPoint:
        # Test that the CLI command succeeds when the entrypoint does
        # return a function.
        entrypoint = MockEntryPoint('ep1', 'ep1')
        entrypoint.load.return_value = MagicMock()
        with patch('invenio_base.cli.iter_entry_points',
                   return_value=[entrypoint]):
            result = runner.invoke(
                instance,
                ['migrate-secret-key', '--old-key', 'OLD_SECRET_KEY'],
                obj=script_info)
            assert result.exit_code == 0
            assert entrypoint.load.called
            entrypoint.load.return_value.assert_called_with(
                old_key='OLD_SECRET_KEY')
            assert 'Successfully changed secret key.' in result.output

        # Test that the CLI command fails correctly when the entrypoint does
        # not return a function.
        entrypoint = MockEntryPoint('ep2', 'ep2')
        entrypoint.load.return_value = 'ep2'
        with patch('invenio_base.cli.iter_entry_points',
                   return_value=[entrypoint]):
            result = runner.invoke(
                instance,
                ['migrate-secret-key', '--old-key', 'OLD_SECRET_KEY'],
                obj=script_info)
            assert result.exit_code == -1
            assert entrypoint.load.called
            assert 'Failed to initialize entry point' in result.output
Ejemplo n.º 4
0
def test_harvest(app, apiharvester_config_vs, apiharvester_apiresponse_vs):
    """Test harvest cli."""
    runner = CliRunner()
    script_info = ScriptInfo(create_app=lambda info: app)
    """Mock a request response."""
    responses.add_passthru(re.compile('http://localhost:9200/(.*)'))
    url = '{url}{static}'.format(
        url=apiharvester_config_vs.get('url'),
        static=('/v1/resources.json?start_at=1900-01-01T00:00:00'
                '&page={page}{available}'))
    headers1 = {
        'X-Total-Pages': '1',
        'X-Total-Items': '1',
        'X-Per-Page': '20',
        'X-Current-Page': '1'
    }
    responses.add(responses.GET,
                  url=url.format(page=1, available='&available=1'),
                  status=200,
                  json=apiharvester_apiresponse_vs,
                  headers=headers1)
    responses.add(
        responses.GET,
        url=url.format(page=2, available='&available=1'),
        status=400,
    )
    responses.add(responses.GET,
                  url=url.format(page=1, available=''),
                  status=200,
                  json=apiharvester_apiresponse_vs,
                  headers=headers1)
    responses.add(
        responses.GET,
        url=url.format(page=2, available=''),
        status=400,
    )

    res = runner.invoke(cli.harvest, ['-n', 'VS', '-v'], obj=script_info)

    assert 0 == res.exit_code
    assert res.output.strip().split('\n') == [
        'Harvest api: VS',
        ('API page: 1 url: http://mediatheque-valais.cantookstation.eu/v1/'
         'resources.json?start_at=1900-01-01T00:00:00&page=1&available=1'),
        ('API page: 1 url: http://mediatheque-valais.cantookstation.eu/v1/'
         'resources.json?start_at=1900-01-01T00:00:00&page=1'),
        '1: cantook:mv-cantook cantook-immateriel.frO692039 = CREATE',
        ('API harvest items=1 available=1 |'
         ' got=1 new=1 updated=0 deleted=0 from VS.')
    ]
Ejemplo n.º 5
0
def test_cli_commands_raise(app):
    if not hasattr(app, "cli"):
        pytest.skip("Too old flask version")

    from flask.cli import ScriptInfo

    @app.cli.command()
    def foo():
        1 / 0

    with pytest.raises(ZeroDivisionError):
        app.cli.main(args=["foo"],
                     prog_name="myapp",
                     obj=ScriptInfo(create_app=lambda _: app))
Ejemplo n.º 6
0
def cli_run(app):
    """Fixture for CLI runner function.

    Returns a function accepting a single parameter (CLI command as string).
    """
    runner = CliRunner()
    script_info = ScriptInfo(create_app=lambda info: app)

    def run(command):
        """Run the command from the CLI."""
        command_args = command.split()
        return runner.invoke(github, command_args, obj=script_info)

    yield run
Ejemplo n.º 7
0
def test_with_appcontext(runner):
    """Test of with_appcontext."""
    @click.command()
    @with_appcontext
    def testcmd():
        click.echo(current_app.name)

    obj = ScriptInfo(create_app=lambda info: Flask("testapp"))
    runner = CliRunner()
    result = runner.invoke(testcmd, obj=obj)
    assert result.exit_code == 0


    assert result.output == 'testapp\n'
Ejemplo n.º 8
0
def script_info_assets(app, static_dir, testcss):
    """Get ScriptInfo object for testing CLI."""
    InvenioAssets(app)

    blueprint = Blueprint(__name__, 'test_bp', static_folder=static_dir)

    class Ext(object):
        def __init__(self, app):
            assets = app.extensions['invenio-assets']
            app.register_blueprint(blueprint)

    Ext(app)

    yield ScriptInfo(create_app=lambda info: app)
Ejemplo n.º 9
0
def script_info(base_app):
    """Get ScriptInfo object for testing a CLI command.

    Scope: module

    .. code-block:: python

        def test_cmd(script_info):
            runner = CliRunner()
            result = runner.invoke(mycmd, obj=script_info)
            assert result.exit_code == 0
    """
    from flask.cli import ScriptInfo
    return ScriptInfo(create_app=lambda info: base_app)
Ejemplo n.º 10
0
def test_delete_without_queues(app, test_queues):
    """Test delete without any queue declared."""
    with app.app_context():
        deleted = [conf['name'] for conf in test_queues]
        runner = CliRunner()
        script_info = ScriptInfo(create_app=lambda info: app)
        # Delete a first time
        result = runner.invoke(
            queues, ['delete'] + deleted, obj=script_info)
        assert result.exit_code == 0
        # Delete without any queue declared
        result = runner.invoke(
            queues, ['delete'] + deleted, obj=script_info)
        assert result.exit_code == 0
Ejemplo n.º 11
0
def test_declare_existing(app, test_queues_entrypoints):
    """Test the scenario of declaring a tasks that already exists."""
    with app.app_context():
        configured = [conf['name'] for conf in test_queues_entrypoints]
        runner = CliRunner()
        script_info = ScriptInfo(create_app=lambda info: app)
        # Declare all the configured queues
        result = runner.invoke(
            queues, ['declare'] + configured, obj=script_info)
        assert result.exit_code == 0
        # Declare configured queues again without deletion
        result = runner.invoke(
            queues, ['declare'] + configured, obj=script_info)
        assert result.exit_code == 0
Ejemplo n.º 12
0
def script_info(app, sqlalchemy_datastore):
    from flask.cli import ScriptInfo

    def create_app(info):
        uia = [
            {"email": {"mapper": uia_email_mapper}},
            {"username": {"mapper": lambda x: x}},
        ]

        app.config.update(**{"SECURITY_USER_IDENTITY_ATTRIBUTES": uia})
        app.security = Security(app, datastore=sqlalchemy_datastore)
        return app

    return ScriptInfo(create_app=create_app)
Ejemplo n.º 13
0
def set_settings(instance=None):
    """Pick correct settings instance and set it to a global variable."""

    global settings

    settings = None

    if instance:
        settings = import_settings(instance)

    elif "INSTANCE_FOR_DYNACONF" in os.environ:
        settings = import_settings(os.environ["INSTANCE_FOR_DYNACONF"])

    elif "FLASK_APP" in os.environ:  # pragma: no cover
        with suppress(ImportError, click.UsageError):
            from flask.cli import ScriptInfo

            flask_app = ScriptInfo().load_app()
            settings = flask_app.config
            click.echo(
                click.style(
                    "Flask app detected", fg="white", bg="bright_black"
                )
            )

    elif "DJANGO_SETTINGS_MODULE" in os.environ:  # pragma: no cover
        sys.path.insert(0, os.path.abspath(os.getcwd()))
        try:
            # Django extension v2
            from django.conf import settings

            settings.DYNACONF.configure()
        except (ImportError, AttributeError):
            # Backwards compatible with old django extension (pre 2.0.0)
            import dynaconf.contrib.django_dynaconf  # noqa
            from django.conf import settings as django_settings

            django_settings.configure()
            settings = django_settings

        if settings is not None:
            click.echo(
                click.style(
                    "Django app detected", fg="white", bg="bright_black"
                )
            )

    if settings is None:
        settings = LazySettings()
Ejemplo n.º 14
0
def test_pid_unassign(app):
    """Test pid object unassignment."""
    runner = CliRunner()
    script_info = ScriptInfo(create_app=lambda info: app)

    with runner.isolated_filesystem():
        rec_uuid = uuid.uuid4()
        # Assigned object
        result = runner.invoke(cmd, [
            'create', 'recid', '101',
            '-t', 'rec', '-i', str(rec_uuid)
        ], obj=script_info)
        assert 0 == result.exit_code

        result = runner.invoke(cmd, [
            'get', 'recid', '101',
        ], obj=script_info)
        assert 0 == result.exit_code
        assert 'rec {0} N\n'.format(str(rec_uuid)) == result.output

        result = runner.invoke(cmd, [
            'dereference', 'rec', str(rec_uuid),
        ], obj=script_info)
        assert 0 == result.exit_code
        assert 'recid 101 None\n' == result.output

        result = runner.invoke(cmd, [
            'dereference', 'rec', str(rec_uuid), '-s', 'NEW',
        ], obj=script_info)
        assert 0 == result.exit_code
        assert 'recid 101 None\n' == result.output

        with app.app_context():
            pid = PersistentIdentifier.get('recid', '101')
            assert pid.has_object()
            assert pid.get_assigned_object() == rec_uuid
            assert pid.get_assigned_object('rec') == rec_uuid

        # Unassign the object
        result = runner.invoke(cmd, [
            'unassign', 'recid', '101',
        ], obj=script_info)
        assert 0 == result.exit_code

        with app.app_context():
            pid = PersistentIdentifier.get('recid', '101')
            assert not pid.has_object()
            assert pid.get_assigned_object() is None
            assert pid.get_assigned_object('rec') is None
Ejemplo n.º 15
0
def test_delete(app, test_queues, deleted):
    """Test the "delete" CLI."""
    with app.app_context():
        configured = [conf['name'] for conf in test_queues]
        expected = deleted or configured
        assert queues_exist(configured)
        runner = CliRunner()
        script_info = ScriptInfo(create_app=lambda info: app)
        result = runner.invoke(
            queues, ['delete'] + deleted, obj=script_info)
        assert result.exit_code == 0
        assert not queues_exist(expected)
        other = [name for name in configured if name not in expected]
        if other:
            assert queues_exist(other)
Ejemplo n.º 16
0
 def _run():
     with freeze_time("2019-11-27 18:50"):
         # See https://github.com/pallets/flask/blob/master/src/flask/cli.py#L829
         debug = get_debug_flag()
         app = DispatchingApp(ScriptInfo().load_app, use_eager_loading=None)
         run_simple(
             "127.0.0.1",
             5000,
             app,
             use_reloader=debug,
             use_debugger=debug,
             threaded=True,
             ssl_context=None,
             extra_files=None,
         )
Ejemplo n.º 17
0
def run():
    from flask.helpers import get_load_dotenv
    from flask.cli import ScriptInfo, load_dotenv

    from mini_fiction.management import manager

    manager.populate_commands()

    # Необходимо создать приложение заранее для загрузки команд из плагинов
    if get_load_dotenv(manager.cli.load_dotenv):
        load_dotenv()
    obj = ScriptInfo(create_app=manager.cli.create_app)
    obj.load_app()

    return manager.cli(obj=obj)
Ejemplo n.º 18
0
def test_cli_action_deny(app, community, authenticated_user, db):
    runner = CliRunner()
    script_info = ScriptInfo(create_app=lambda info: app)
    app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv(
        'SQLALCHEMY_DATABASE_URI', 'sqlite://')

    role = community[1].roles[0]
    current_datastore.add_role_to_user(authenticated_user, role)

    login_user(authenticated_user)

    db.session.add(
        ActionRoles(action=COMMUNITY_READ, argument=community[0], role=role))

    assert Permission(ParameterizedActionNeed(COMMUNITY_READ,
                                              community[0])).allows(g.identity)
Ejemplo n.º 19
0
def test_purge_force(app, test_queues):
    """Test purge function with the --force option."""
    with app.app_context():
        purged = [conf['name'] for conf in test_queues]
        runner = CliRunner()
        script_info = ScriptInfo(create_app=lambda info: app)
        result = runner.invoke(
            queues, ['delete'] + purged, obj=script_info)
        # Test with regular call
        result = runner.invoke(
            queues, ['purge'] + purged, obj=script_info)
        assert not result.exit_code == 0
        # Test with the --force
        result = runner.invoke(
            queues, ['purge', '--force'] + purged, obj=script_info)
        assert result.exit_code == 0
Ejemplo n.º 20
0
def test_cli_custom_obj(app):
    class NS(object):
        called = False

    def create_app():
        NS.called = True
        return app

    @app.cli.command('hello')
    def hello_command():
        click.echo('Hello, World!')

    script_info = ScriptInfo(create_app=create_app)
    runner = app.test_cli_runner()
    runner.invoke(hello_command, obj=script_info)
    assert NS.called
Ejemplo n.º 21
0
def test_find_best_app():
    script_info = ScriptInfo()

    class Module:
        @staticmethod
        def create_app(foo):
            return Flask('appname')
    assert isinstance(find_best_app(script_info, Module), Flask)
    assert find_best_app(script_info, Module).name == 'appname'

    class Module:
        @staticmethod
        def create_app(foo=None, script_info=None):
            return Flask('appname')
    assert isinstance(find_best_app(script_info, Module), Flask)
    assert find_best_app(script_info, Module).name == 'appname'
Ejemplo n.º 22
0
def upgrade_run(app):
    """Run the "b2share upgrade" command."""
    # unset SERVER_NAME as we want to check that it is not needed.
    server_name = app.config['SERVER_NAME']
    app.config.update(dict(SERVER_NAME=None))
    # Upgrade B2SHARE with `b2share upgrade run`
    runner = CliRunner()
    script_info = ScriptInfo(create_app=lambda info: app)
    result = runner.invoke(run, ['-v'], obj=script_info)
    ## Uncomment this in order to test without Click. ##
    # from b2share.modules.upgrade.api import upgrade_to_last_version
    # with app.app_context():
    #     upgrade_to_last_version(False)

    # Set the SERVER_NAME to its previous value
    app.config.update(dict(SERVER_NAME=server_name))
    return result
Ejemplo n.º 23
0
def test_create_block_schema(app, test_communities):
    """Test creation of a block schema"""
    #happy flow
    with app.app_context():
        runner = CliRunner()
        script_info = ScriptInfo(create_app=lambda info: app)
        result = runner.invoke(schemas_cmd, [
            'block_schema_add', 'cccccccc-1111-1111-1111-111111111111',
            'Block Schema Name'
        ],
                               obj=script_info)
        assert result.exit_code == 0
        result = runner.invoke(schemas_cmd, ['block_schema_list'],
                               obj=script_info)
        # search only for "Block Schema Na", as the rest of the string is cut
        # by the pretty printer (multiple columns)
        assert (result.output.find("Block Schema Na") > 0)
Ejemplo n.º 24
0
def test_scriptinfo(test_apps, monkeypatch):
    """Test of ScriptInfo."""
    obj = ScriptInfo(app_import_path="cliapp.app:testapp")
    app = obj.load_app()
    assert app.name == "testapp"
    assert obj.load_app() is app

    # import app with module's absolute path
    cli_app_path = os.path.abspath(
        os.path.join(os.path.dirname(__file__), 'test_apps', 'cliapp',
                     'app.py'))
    obj = ScriptInfo(app_import_path=cli_app_path)
    app = obj.load_app()
    assert app.name == 'testapp'
    assert obj.load_app() is app
    obj = ScriptInfo(app_import_path=cli_app_path + ':testapp')
    app = obj.load_app()
    assert app.name == 'testapp'
    assert obj.load_app() is app

    def create_app(info):
        return Flask("createapp")

    obj = ScriptInfo(create_app=create_app)
    app = obj.load_app()
    assert app.name == "createapp"
    assert obj.load_app() is app

    obj = ScriptInfo()
    pytest.raises(NoAppException, obj.load_app)

    # import app from wsgi.py in current directory
    monkeypatch.chdir(
        os.path.abspath(
            os.path.join(os.path.dirname(__file__), 'test_apps',
                         'helloworld')))
    obj = ScriptInfo()
    app = obj.load_app()
    assert app.name == 'hello'

    # import app from app.py in current directory
    monkeypatch.chdir(
        os.path.abspath(
            os.path.join(os.path.dirname(__file__), 'test_apps', 'cliapp')))
    obj = ScriptInfo()
    app = obj.load_app()
    assert app.name == 'testapp'
Ejemplo n.º 25
0
def flask(ctx, detach=None, loglevel=None, logfile=None,
          pidfile=None, uid=None, gid=None, umask=None, **kwargs):
    # Look up Celery app
    celery_app = ctx.obj.app

    # Prepare to pass Flask app to Flask CLI
    ctx.obj = ScriptInfo(create_app=lambda *args, **kwargs: app)

    # Detach from the tty if requested.
    # FIXME: After we update to click >= 8, replace the elaborate construction
    # below with ctx.with_resource(maybe_detached(...))
    exit_stack = ExitStack()
    ctx.call_on_close(exit_stack.close)
    exit_stack.enter_context(maybe_detached(detach=detach,
                                            logfile=logfile, pidfile=pidfile,
                                            uid=uid, gid=gid, umask=umask))

    celery_app.log.setup(loglevel, logfile)
Ejemplo n.º 26
0
def webassets(app):
    """Flask application fixture with assets."""
    initial_dir = os.getcwd()
    os.chdir(app.instance_path)

    script_info = ScriptInfo(create_app=lambda info: app)
    script_info._loaded_app = app

    runner = CliRunner()
    runner.invoke(npm, obj=script_info)

    subprocess.call(['npm', 'install'])
    runner.invoke(collect, ['-v'], obj=script_info)
    runner.invoke(assets, ['build'], obj=script_info)

    yield app

    os.chdir(initial_dir)
Ejemplo n.º 27
0
def test_scriptinfo(test_apps, monkeypatch):
    obj = ScriptInfo(app_import_path="cliapp.app:testapp")
    app = obj.load_app()
    assert app.name == "testapp"
    assert obj.load_app() is app

    # import app with module's absolute path
    cli_app_path = os.path.abspath(
        os.path.join(os.path.dirname(__file__), "test_apps", "cliapp",
                     "app.py"))
    obj = ScriptInfo(app_import_path=cli_app_path)
    app = obj.load_app()
    assert app.name == "testapp"
    assert obj.load_app() is app
    obj = ScriptInfo(app_import_path=f"{cli_app_path}:testapp")
    app = obj.load_app()
    assert app.name == "testapp"
    assert obj.load_app() is app

    def create_app():
        return Flask("createapp")

    obj = ScriptInfo(create_app=create_app)
    app = obj.load_app()
    assert app.name == "createapp"
    assert obj.load_app() is app

    obj = ScriptInfo()
    pytest.raises(NoAppException, obj.load_app)

    # import app from wsgi.py in current directory
    monkeypatch.chdir(
        os.path.abspath(
            os.path.join(os.path.dirname(__file__), "test_apps",
                         "helloworld")))
    obj = ScriptInfo()
    app = obj.load_app()
    assert app.name == "hello"

    # import app from app.py in current directory
    monkeypatch.chdir(
        os.path.abspath(
            os.path.join(os.path.dirname(__file__), "test_apps", "cliapp")))
    obj = ScriptInfo()
    app = obj.load_app()
    assert app.name == "testapp"
Ejemplo n.º 28
0
def test_create_put_and_delete(app):
    runner = CliRunner()
    script_info = ScriptInfo(create_app=lambda info: app)
    name = 'test-index-name'

    result = runner.invoke(cmd, [
        'create',
        '--verbose',
        name,
        '--body',
        './tests/mock_module/mappings/authors/authors-v1.0.0.json',
    ],
                           obj=script_info)
    assert result.exit_code == 0
    assert name in list(current_search_client.indices.get('*').keys())

    doc_type = '_doc' if ES_VERSION[0] > 5 else 'recid'
    result = runner.invoke(cmd, [
        'put',
        name,
        doc_type,
        '--verbose',
        '--identifier',
        1,
        '--body',
        './tests/mock_module/mappings/authors/authors-v1.0.0.json',
    ],
                           obj=script_info)
    assert result.exit_code == 0
    current_search_client.get(index=name, doc_type=doc_type, id=1)
    with pytest.raises(NotFoundError):
        current_search_client.get(index=name, doc_type=doc_type, id=2)

    result = runner.invoke(cmd, [
        'delete',
        '--verbose',
        '--yes-i-know',
        '--force',
        name,
    ],
                           obj=script_info)
    assert result.exit_code == 0
    assert name not in list(current_search_client.indices.get('*').keys())
Ejemplo n.º 29
0
def test_flask_seed_model_cli_seeds_to_db_with_staff_option(cli_app):
    """
    Tests that staff table is populated `flask seed model` when passed a
    `staff` option.

    Args:
        cli_app (function): a flask app factory function that also manages its
            context.
    """
    # Create a script for running application.
    obj = ScriptInfo(create_app=cli_app)

    # Call command, apply arguments and create app.
    result = CliRunner().invoke(seed_model, ['staff'], obj=obj)

    staffs = Staff.get_all()

    assert len(staffs) == 3
    assert result.exit_code == 0
Ejemplo n.º 30
0
def test_purge(app, test_queues, purged):
    """Test the "purge" CLI."""
    with app.app_context():
        configured = [conf['name'] for conf in test_queues]
        expected = purged or configured
        data = [1, 2, 3]
        for conf in test_queues:
            current_queues.queues[conf['name']].publish(data)
        runner = CliRunner()
        script_info = ScriptInfo(create_app=lambda info: app)
        result = runner.invoke(queues, ['purge'] + purged, obj=script_info)
        assert result.exit_code == 0
        for conf in test_queues:
            if conf['name'] in expected:
                assert len(list(
                    current_queues._queues[conf['name']].consume())) == 0
            else:
                assert list(
                    current_queues.queues[conf['name']].consume()) == data