Example #1
0
def fix_settings():
    settings = Settings(dev_mode=False, test_mode=True)
    assert not settings.dev_mode
    glove._settings = settings

    yield settings

    glove._settings = None
Example #2
0
def fix_alt_settings(settings: Settings):
    return settings.copy(update=dict(
        pg_dsn='postgres://postgres@localhost:5432/foxglove_demo_alt'))
Example #3
0
def _fix_create_request(settings: Settings):
    app = settings.create_app()

    async def endpoint(request: Request):
        return Response()

    class CreateRequest:
        def __init__(self, _app):
            self.app = _app

        def __call__(self,
                     method='GET',
                     path='/',
                     headers=None,
                     client_addr='testclient',
                     **extra_scope):
            _headers = {
                'host': 'testserver',
                'user-agent': 'testclient',
                'connection': 'keep-alive'
            }
            if headers:
                _headers.update(headers)
            scope = {
                'type':
                'http',
                'http_version':
                '1.1',
                'method':
                method,
                'path':
                path,
                'root_path':
                '',
                'scheme':
                'http',
                'query_string':
                b'',
                'headers': [(k.lower().encode(), v.encode())
                            for k, v in _headers.items()],
                'client': [
                    client_addr,
                    50000,
                ],
                'server': [
                    'testserver',
                    80,
                ],
                'extensions': {
                    'http.response.template': {},
                },
                'app':
                app,
                'state': {},
                'session': {},
                'endpoint':
                endpoint,
                'path_params': {},
                **extra_scope,
            }
            return Request(scope, None, None)

    return CreateRequest(app)
Example #4
0
def fix_client_sentry(settings: Settings, db_conn, glove):
    settings.sentry_dsn = 'https://[email protected]/789'
    glove._settings = settings
    app = settings.create_app()
    with Client(app) as client:
        yield client
Example #5
0
def fix_client(settings: Settings, db_conn, glove):
    app = settings.create_app()
    with Client(app) as client:
        yield client
Example #6
0
def _fix_settings(dummy_server: DummyServer, request, tmpdir):
    return Settings(**{f: f'{dummy_server.server_name}/{f}/' for f in replaced_url_fields}, **settings_args)
Example #7
0
def _fix_settings_session():
    return Settings(**settings_args)