Пример #1
0
def test_settings_email_activate_with_unexpected_error(users, dummy_request):
    from aarau.views.console.settings.action import settings_email_activate
    from aarau.models.user_email import UserEmail

    user_email = users['weenie'].emails.where(
        UserEmail.email == '*****@*****.**').get()
    assert 'pending' == user_email.activation_state

    dummy_request.subdomain = 'console'
    dummy_request.user = users['weenie']
    dummy_request.matchdict = {'token': user_email.activation_token}

    try:
        from aarau import get_settings
        settings = get_settings()
        secret = settings['token.secret']
        settings['token.secret'] = None  # emulate as not set

        res = settings_email_activate(dummy_request)

        assert dummy_request.session.peek_flash('failure')
        assert '302 Found' == res.status
        assert '/settings/email' == res.location
    finally:
        # restore for following tests
        settings['token.secret'] = secret
Пример #2
0
def _db(db_kind):
    from aarau import get_settings
    from aarau.models import init_db

    settings = get_settings()
    db = init_db(settings, db_kind)

    if db.is_closed():
        db.connect()

    yield db

    if not db.in_transaction() and not db.is_closed():
        db.close()
Пример #3
0
 def _settings(self):  # pylint: disable=no-self-use
     from aarau import get_settings
     return get_settings()
Пример #4
0
    def settings(self):
        from aarau import get_settings

        return get_settings() or {}
Пример #5
0
        from aarau.env import Env
        env = Env()

        config_uri = '{0!s}/config/{1!s}.ini#aarau'.format(
            os.path.dirname(__file__) + '/../..', env.name)
        settings = get_appsettings(config_uri)
        settings = resolve_env_vars(dict(settings))

    options = {  # duplicated for consistency
        'broker_url': settings['queue.url'],
    }
    _worker.conf.update(**options)
    return _worker


worker = init_worker(get_settings())  # pylint: disable=invalid-name


def blank_request():
    """Returns blank dummy request object."""
    from aarau.request import CustomRequest

    # The variables wsgi.url_scheme, HTTP_HOST and SCRIPT_NAME
    # will be filled from pseudo base_url.
    request = CustomRequest.blank('/', base_url=None)
    request.registry = get_current_registry()
    return request


def includeme(config):
    """Initializes the celery task worker.