示例#1
0
 def test_warn_if_deprecated_settings_are_used(self):
     config = Configurator(settings={'cliquet.cache_pool_maxconn': '1'})
     with mock.patch('cliquet.warnings.warn') as mocked:
         cliquet.initialize(config, '0.0.1')
         msg = ("'cliquet.cache_pool_maxconn' setting is deprecated. "
                "Use 'cliquet.cache_pool_size' instead.")
         mocked.assert_called_with(msg, DeprecationWarning)
示例#2
0
def main(global_config, config=None, **settings):
    if not config:
        config = Configurator(settings=settings, root_factory=RouteFactory)

    # Force project name, since it determines settings prefix.
    config.add_settings({'cliquet.project_name': 'kinto'})

    cliquet.initialize(config,
                       version=__version__,
                       default_settings=DEFAULT_SETTINGS)

    settings = config.get_settings()

    # In Kinto API 1.x, a default bucket is available.
    # Force its inclusion if not specified in settings.
    if 'kinto.plugins.default_bucket' not in settings['includes']:
        config.include('kinto.plugins.default_bucket')

    # Retro-compatibility with first Kinto clients.
    config.registry.public_settings.add('cliquet.batch_max_requests')

    # Scan Kinto views.
    kwargs = {}
    flush_enabled = asbool(settings.get('flush_endpoint_enabled'))
    if not flush_enabled:
        kwargs['ignore'] = 'kinto.views.flush'
    config.scan("kinto.views", **kwargs)

    app = config.make_wsgi_app()

    # Install middleware (idempotent if disabled)
    return cliquet.install_middlewares(app, settings)
示例#3
0
def main(global_config, **settings):
    config = Configurator(settings=settings, root_factory=RouteFactory)

    # Force project name, since it determines settings prefix.
    config.add_settings({'cliquet.project_name': 'kinto'})

    cliquet.initialize(config,
                       version=__version__,
                       default_settings=DEFAULT_SETTINGS)

    # Redirect default to the right endpoint
    config.add_route('default_bucket_collection',
                     '/buckets/default/{subpath:.*}')
    config.add_route('default_bucket', '/buckets/default')

    # Retro-compatibility with first Kinto clients.
    config.registry.public_settings.add('cliquet.batch_max_requests')

    # Scan Kinto views.
    settings = config.get_settings()
    kwargs = {}
    flush_enabled = asbool(settings.get('flush_endpoint_enabled'))
    if not flush_enabled:
        kwargs['ignore'] = 'kinto.views.flush'
    config.scan("kinto.views", **kwargs)

    app = config.make_wsgi_app()

    # Install middleware (idempotent if disabled)
    return cliquet.install_middlewares(app, settings)
示例#4
0
 def test_statsd_counts_unique_users(self, mocked, digest_mocked):
     digest_mocked.return_value = u'mat'
     cliquet.initialize(self.config, '0.0.1', 'project_name')
     app = webtest.TestApp(self.config.make_wsgi_app())
     headers = {'Authorization': 'Basic bWF0Og=='}
     app.get('/v0/', headers=headers)
     mocked().count.assert_any_call('users', unique='basicauth:mat')
示例#5
0
def main(global_config, **settings):
    config = Configurator(settings=settings, root_factory=RouteFactory)

    # Force project name, since it determines settings prefix.
    config.add_settings({'cliquet.project_name': 'kinto'})

    cliquet.initialize(config,
                       version=__version__,
                       default_settings=DEFAULT_SETTINGS)

    # Redirect default to the right endpoint
    config.add_route('default_bucket_collection',
                     '/buckets/default/{subpath:.*}')
    config.add_route('default_bucket', '/buckets/default')

    # Provide helpers
    config.add_request_method(default_bucket_id, reify=True)
    # Override Cliquet default user info
    config.add_request_method(get_user_info)

    # Retro-compatibility with first Kinto clients.
    config.registry.public_settings.add('cliquet.batch_max_requests')

    # Scan Kinto views.
    settings = config.get_settings()
    kwargs = {}
    flush_enabled = asbool(settings.get('flush_endpoint_enabled'))
    if not flush_enabled:
        kwargs['ignore'] = 'kinto.views.flush'
    config.scan("kinto.views", **kwargs)

    app = config.make_wsgi_app()

    # Install middleware (idempotent if disabled)
    return cliquet.install_middlewares(app, settings)
示例#6
0
 def test_statsd_counts_unique_users(self, mocked, digest_mocked):
     digest_mocked.return_value = u'mat'
     cliquet.initialize(self.config, '0.0.1')
     app = webtest.TestApp(self.config.make_wsgi_app())
     headers = {'Authorization': 'Basic bWF0Og=='}
     app.get('/v0/__heartbeat__', headers=headers)
     mocked().count.assert_any_call('users', unique='mat')
示例#7
0
def main(global_config, **settings):
    config = Configurator(settings=settings)

    cliquet.initialize(config, __version__, 'syncto',
                       default_settings=DEFAULT_SETTINGS)

    # Retro-compatibility with first Kinto clients.
    config.registry.public_settings.add('cliquet.batch_max_requests')

    settings = config.get_settings()
    config.registry.heartbeats['sync'] = ping_sync_cluster

    # For the use of a valid cache_hmac_secret key.
    if settings['cache_hmac_secret'] is None:
        error_msg = "Please configure the `syncto.cache_hmac_secret` settings."
        raise ValueError(error_msg)

    # Handle Certificate Pinning file.
    ca_bundle_path = settings['certificate_ca_bundle']
    if ca_bundle_path is not None:
        ca_bundle_abspath = os.path.abspath(ca_bundle_path)
        if not os.path.isfile(ca_bundle_abspath):
            error_msg = "File %s cannot be found." % ca_bundle_abspath
            raise ValueError(error_msg)

        config.add_settings({
            'certificate_ca_bundle': ca_bundle_abspath
        })

    config.scan("syncto.views")
    return config.make_wsgi_app()
def main(global_config, **settings):
    config = Configurator(settings=settings)

    cliquet.initialize(config,
                       __version__,
                       'syncto',
                       default_settings=DEFAULT_SETTINGS)

    # Retro-compatibility with first Kinto clients.
    config.registry.public_settings.add('cliquet.batch_max_requests')

    settings = config.get_settings()
    config.registry.heartbeats['sync'] = ping_sync_cluster

    # For the use of a valid cache_hmac_secret key.
    if settings['cache_hmac_secret'] is None:
        error_msg = "Please configure the `syncto.cache_hmac_secret` settings."
        raise ValueError(error_msg)

    # Handle Certificate Pinning file.
    ca_bundle_path = settings['certificate_ca_bundle']
    if ca_bundle_path is not None:
        ca_bundle_abspath = os.path.abspath(ca_bundle_path)
        if not os.path.isfile(ca_bundle_abspath):
            error_msg = "File %s cannot be found." % ca_bundle_abspath
            raise ValueError(error_msg)

        config.add_settings({'certificate_ca_bundle': ca_bundle_abspath})

    config.scan("syncto.views")
    return config.make_wsgi_app()
示例#9
0
文件: __init__.py 项目: is00hcw/kinto
def main(global_config, config=None, **settings):
    if not config:
        config = Configurator(settings=settings, root_factory=RouteFactory)

    # Force project name, since it determines settings prefix.
    config.add_settings({"cliquet.project_name": "kinto"})

    cliquet.initialize(config, version=__version__, default_settings=DEFAULT_SETTINGS)

    # Redirect default to the right endpoint
    config.add_route("default_bucket_collection", "/buckets/default/{subpath:.*}")
    config.add_route("default_bucket", "/buckets/default")

    # Provide helpers
    config.add_request_method(default_bucket_id, reify=True)
    # Override Cliquet default user info
    config.add_request_method(get_user_info)

    # Retro-compatibility with first Kinto clients.
    config.registry.public_settings.add("cliquet.batch_max_requests")

    # Scan Kinto views.
    settings = config.get_settings()
    kwargs = {}
    flush_enabled = asbool(settings.get("flush_endpoint_enabled"))
    if not flush_enabled:
        kwargs["ignore"] = "kinto.views.flush"
    config.scan("kinto.views", **kwargs)

    app = config.make_wsgi_app()

    # Install middleware (idempotent if disabled)
    return cliquet.install_middlewares(app, settings)
示例#10
0
def main(global_config, config=None, **settings):
    if not config:
        config = Configurator(settings=settings, root_factory=RouteFactory)

    # Force project name, since it determines settings prefix.
    config.add_settings({'cliquet.project_name': 'kinto'})

    cliquet.initialize(config,
                       version=__version__,
                       default_settings=DEFAULT_SETTINGS)

    settings = config.get_settings()

    # In Kinto API 1.x, a default bucket is available.
    # Force its inclusion if not specified in settings.
    if 'kinto.plugins.default_bucket' not in settings['includes']:
        config.include('kinto.plugins.default_bucket')

    # Retro-compatibility with first Kinto clients.
    config.registry.public_settings.add('cliquet.batch_max_requests')

    # Scan Kinto views.
    kwargs = {}
    flush_enabled = asbool(settings.get('flush_endpoint_enabled'))
    if not flush_enabled:
        kwargs['ignore'] = 'kinto.views.flush'
    config.scan("kinto.views", **kwargs)

    app = config.make_wsgi_app()

    # Install middleware (idempotent if disabled)
    return cliquet.install_middlewares(app, settings)
示例#11
0
def main(settings=None, *args, **additional_settings):
    if settings is None:
        settings = {}
    settings.update(additional_settings)
    config = Configurator(settings=settings)
    cliquet.initialize(config, version='0.0.1')
    config.include(includeme)
    return config.make_wsgi_app()
示例#12
0
 def make_app(self):
     config = Configurator(settings=cliquet.DEFAULT_SETTINGS)
     config.add_settings({
         'permission_backend': 'cliquet.permission.memory',
         'includes': 'cliquet.tests.testplugin'
     })
     cliquet.initialize(config, '0.0.1', 'name')
     return webtest.TestApp(config.make_wsgi_app())
示例#13
0
 def make_app(self):
     config = Configurator(settings=cliquet.DEFAULT_SETTINGS)
     config.add_settings({
         'permission_backend': 'cliquet.permission.memory',
         'includes': 'cliquet.tests.testplugin'
     })
     cliquet.initialize(config, '0.0.1', 'name')
     return webtest.TestApp(config.make_wsgi_app())
示例#14
0
 def test_specified_default_settings_are_overriden_by_application(self):
     config = Configurator(settings={'cliquet.paginate_by': 5})
     defaults = {'cliquet.paginate_by': 10}
     cliquet.initialize(config,
                        '0.0.1',
                        'project_name',
                        default_settings=defaults)
     self.assertEqual(config.registry.settings['paginate_by'], 5)
示例#15
0
 def _get_app(self, settings={}):
     app_settings = {
         'cliquet.storage_backend': 'cliquet.storage.memory',
         'cliquet.cache_backend': 'cliquet.cache.redis',
     }
     app_settings.update(**settings)
     config = Configurator(settings=app_settings)
     cliquet.initialize(config, '0.0.1', 'name')
     return webtest.TestApp(config.make_wsgi_app())
示例#16
0
 def _get_app(self, settings={}):
     app_settings = {
         'storage_backend': 'cliquet.storage.memory',
         'cache_backend': 'cliquet.cache.redis',
     }
     app_settings.update(**settings)
     config = Configurator(settings=app_settings)
     cliquet.initialize(config, '0.0.1', 'name')
     return webtest.TestApp(config.make_wsgi_app())
示例#17
0
def main(settings=None, config=None, *args, **additional_settings):
    if settings is None:
        settings = {}
    settings.update(additional_settings)
    if config is None:
        config = Configurator(settings=settings)
    cliquet.initialize(config, version='0.0.1')
    config.include(includeme)
    app = config.make_wsgi_app()
    # Install middleware (no-op if not enabled in setting)
    return cliquet.install_middlewares(app, settings)
示例#18
0
def main(global_config, **settings):
    config = Configurator(settings=settings)

    patch_gevent(settings)

    cliquet.initialize(config, version=__version__,
                       default_settings=DEFAULT_SETTINGS)

    config.scan("readinglist.views")
    app = config.make_wsgi_app()
    return cliquet.install_middlewares(app, settings)
示例#19
0
    def test_requests_have_a_bound_data_attribute(self):
        config = Configurator()
        cliquet.initialize(config, '0.0.1', 'name')

        def on_new_request(event):
            data = event.request.bound_data
            self.assertEqual(data, {})
            self.assertEqual(id(data), id(event.request.bound_data))

        config.add_subscriber(on_new_request, NewRequest)
        app = webtest.TestApp(config.make_wsgi_app())
        app.get('/v0/')
示例#20
0
    def test_requests_have_a_bound_data_attribute(self):
        config = Configurator()
        cliquet.initialize(config, '0.0.1', 'name')

        def on_new_request(event):
            data = event.request.bound_data
            self.assertEqual(data, {})
            self.assertEqual(id(data), id(event.request.bound_data))

        config.add_subscriber(on_new_request, NewRequest)
        app = webtest.TestApp(config.make_wsgi_app())
        app.get('/v0/')
def main(global_config, **settings):
    config = Configurator(settings=settings)

    patch_gevent(settings)

    cliquet.initialize(config,
                       version=__version__,
                       default_settings=DEFAULT_SETTINGS)

    config.scan("readinglist.views")
    app = config.make_wsgi_app()
    return cliquet.install_middlewares(app, settings)
示例#22
0
def main(global_config, config=None, **settings):
    if not config:
        config = Configurator(settings=settings, root_factory=RouteFactory)

    # Force project name, since it determines settings prefix.
    config.add_settings({'cliquet.project_name': 'kinto'})

    cliquet.initialize(config,
                       version=__version__,
                       default_settings=DEFAULT_SETTINGS)

    settings = config.get_settings()

    # In Kinto API 1.x, a default bucket is available.
    # Force its inclusion if not specified in settings.
    if 'kinto.plugins.default_bucket' not in settings['includes']:
        config.include('kinto.plugins.default_bucket')

    # Retro-compatibility with first Kinto clients.
    config.registry.public_settings.add('cliquet.batch_max_requests')

    # Expose capability
    schema_enabled = asbool(
        settings['experimental_collection_schema_validation']
    )
    if schema_enabled:
        config.add_api_capability(
            "schema",
            description="Validates collection records with JSON schemas.",
            url="http://kinto.readthedocs.org/en/latest/api/1.x/"
                "collections.html#collection-json-schema")

    # Scan Kinto views.
    kwargs = {}
    flush_enabled = asbool(settings.get('flush_endpoint_enabled'))

    if flush_enabled:
        config.add_api_capability(
            "flush_endpoint",
            description="The __flush__ endpoint can be used to remove all "
                        "data from all backends.",
            url="http://kinto.readthedocs.org/en/latest/configuration/"
                "settings.html#activating-the-flush-endpoint"
        )
    else:
        kwargs['ignore'] = 'kinto.views.flush'
    config.scan("kinto.views", **kwargs)

    app = config.make_wsgi_app()

    # Install middleware (idempotent if disabled)
    return cliquet.install_middlewares(app, settings)
示例#23
0
    def test_environment_values_override_configuration(self):
        import os

        envkey = 'CLIQUET_PROJECT_NAME'
        os.environ[envkey] = 'abc'

        config = Configurator(settings={'cliquet.project_name': 'kinto'})
        cliquet.initialize(config, '0.0.1')

        os.environ.pop(envkey)

        project_used = config.registry.settings['cliquet.project_name']
        self.assertEqual(project_used, 'abc')
示例#24
0
    def test_subrequests_share_parent_bound_data(self):
        config = Configurator()
        cliquet.initialize(config, '0.0.1', 'name')

        bound_datas = set()

        def on_new_request(event):
            bound_datas.add(id(event.request.bound_data))

        config.add_subscriber(on_new_request, NewRequest)
        app = webtest.TestApp(config.make_wsgi_app())
        app.post_json('/v0/batch', {'requests': [{'path': '/'}]})
        self.assertEqual(len(bound_datas), 1)
示例#25
0
    def test_environment_values_override_configuration(self):
        import os

        envkey = 'CLIQUET_PROJECT_NAME'
        os.environ[envkey] = 'abc'

        config = Configurator(settings={'cliquet.project_name': 'kinto'})
        cliquet.initialize(config, '0.0.1')

        os.environ.pop(envkey)

        project_used = config.registry.settings['project_name']
        self.assertEqual(project_used, 'abc')
示例#26
0
    def test_subrequests_share_parent_bound_data(self):
        config = Configurator()
        cliquet.initialize(config, '0.0.1', 'name')

        bound_datas = set()

        def on_new_request(event):
            bound_datas.add(id(event.request.bound_data))

        config.add_subscriber(on_new_request, NewRequest)
        app = webtest.TestApp(config.make_wsgi_app())
        app.post_json('/v0/batch', {'requests': [{'path': '/'}]})
        self.assertEqual(len(bound_datas), 1)
示例#27
0
def main(global_config, **settings):
    config = Configurator(settings=settings, root_factory=RouteFactory)
    cliquet.initialize(config,
                       version=__version__,
                       default_settings=DEFAULT_SETTINGS)

    settings = config.get_settings()
    kwargs = {}
    flush_enabled = asbool(settings.get('kinto.flush_endpoint_enabled'))
    if not flush_enabled:
        kwargs['ignore'] = 'kinto.views.flush'

    # Redirect default to the right endpoint
    config.add_route('default_bucket', '/buckets/default{subpath:.*}')

    config.scan("kinto.views", **kwargs)
    return config.make_wsgi_app()
示例#28
0
def main(global_config, **settings):
    config = Configurator(settings=settings)

    cliquet.initialize(config, __version__, 'syncto',
                       default_settings=DEFAULT_SETTINGS)

    # Retro-compatibility with first Kinto clients.
    config.registry.public_settings.add('cliquet.batch_max_requests')

    settings = config.get_settings()
    config.registry.heartbeats['sync'] = ping_sync_cluster

    if settings['cache_hmac_secret'] is None:
        error_msg = "Please configure the `syncto.cache_hmac_secret` settings."
        raise ValueError(error_msg)

    config.scan("syncto.views")
    return config.make_wsgi_app()
示例#29
0
def main(global_config, **settings):
    config = Configurator(settings=settings, root_factory=RouteFactory)
    cliquet.initialize(config,
                       version=__version__,
                       default_settings=DEFAULT_SETTINGS)

    settings = config.get_settings()
    kwargs = {}
    flush_enabled = asbool(settings.get('kinto.flush_endpoint_enabled'))
    if not flush_enabled:
        kwargs['ignore'] = 'kinto.views.flush'

    # Redirect default to the right endpoint
    config.add_route('default_bucket_collection',
                     '/buckets/default/{subpath:.*}')
    config.add_route('default_bucket', '/buckets/default')

    config.scan("kinto.views", **kwargs)
    return config.make_wsgi_app()
示例#30
0
    def __init__(self, *args, **kwargs):
        super(BaseWebTest, self).__init__(*args, **kwargs)
        self.config = testing.setUp()

        self.config.add_settings({
            'cliquet.storage_backend': 'cliquet.storage.memory',
            'cliquet.project_version': '0.0.1',
            'cliquet.project_name': 'cliquet',
            'cliquet.project_docs': 'https://cliquet.rtfd.org/',
        })

        cliquet.initialize(self.config)
        self.config.scan("cliquet.tests.testapp.views")

        self.app = webtest.TestApp(self.config.make_wsgi_app())
        self.app.RequestClass = get_request_class(self.config.route_prefix)

        self.collection_url = '/mushrooms'
        self.item_url = '/mushrooms/{id}'
示例#31
0
    def __init__(self, *args, **kwargs):
        super(BaseWebTest, self).__init__(*args, **kwargs)
        self.config = testing.setUp()

        self.config.add_settings(
            {
                "cliquet.storage_backend": "cliquet.storage.memory",
                "cliquet.project_version": "0.0.1",
                "cliquet.project_name": "cliquet",
                "cliquet.project_docs": "https://cliquet.rtfd.org/",
                "multiauth.authorization_policy": self.authorization_policy,
            }
        )

        cliquet.initialize(self.config)
        self.config.scan("cliquet.tests.testapp.views")

        self.app = webtest.TestApp(self.config.make_wsgi_app())
        self.app.RequestClass = get_request_class(self.config.route_prefix)
        self.principal = USER_PRINCIPAL

        self.headers = {"Content-Type": "application/json", "Authorization": "Basic bWF0OjE="}
示例#32
0
def main(global_config, **settings):
    config = Configurator(settings=settings, root_factory=RouteFactory)
    cliquet.initialize(config,
                       version=__version__,
                       default_settings=DEFAULT_SETTINGS)

    # Redirect default to the right endpoint
    config.add_route('default_bucket_collection',
                     '/buckets/default/{subpath:.*}')
    config.add_route('default_bucket', '/buckets/default')

    # Scan Kinto views.
    settings = config.get_settings()
    kwargs = {}
    flush_enabled = asbool(settings.get('kinto.flush_endpoint_enabled'))
    if not flush_enabled:
        kwargs['ignore'] = 'kinto.views.flush'
    config.scan("kinto.views", **kwargs)

    app = config.make_wsgi_app()

    # Install middleware (idempotent if disabled)
    return cliquet.install_middlewares(app, settings)
示例#33
0
    def __init__(self, *args, **kwargs):
        super(BaseWebTest, self).__init__(*args, **kwargs)
        self.config = testing.setUp()

        self.config.add_settings({
            'cliquet.storage_backend': 'cliquet.storage.memory',
            'cliquet.project_version': '0.0.1',
            'cliquet.project_name': 'cliquet',
            'cliquet.project_docs': 'https://cliquet.rtfd.org/',
            'multiauth.authorization_policy': self.authorization_policy
        })

        cliquet.initialize(self.config)
        self.config.scan("cliquet.tests.testapp.views")

        self.app = webtest.TestApp(self.config.make_wsgi_app())
        self.app.RequestClass = get_request_class(self.config.route_prefix)
        self.item_url = '/mushrooms/{id}'
        self.principal = USER_PRINCIPAL

        self.headers = {
            'Content-Type': 'application/json',
            'Authorization': 'Basic bWF0OjE='
        }
示例#34
0
 def test_set_the_project_version_from_settings_even_if_specified(self):
     config = Configurator(settings={'cliquet.project_version': '1.0.0'})
     cliquet.initialize(config, '0.0.1', 'name')
     self.assertEqual(config.registry.settings['cliquet.project_version'],
                      '1.0.0')
示例#35
0
 def test_uses_the_version_for_prefix(self):
     config = Configurator()
     cliquet.initialize(config, '0.0.1', 'name')
     self.assertEqual(config.route_prefix, 'v0')
示例#36
0
 def test_statsd_counts_authentication_types(self, mocked):
     cliquet.initialize(self.config, '0.0.1')
     app = webtest.TestApp(self.config.make_wsgi_app())
     headers = {'Authorization': 'Basic bWF0Og=='}
     app.get('/v0/__heartbeat__', headers=headers)
     mocked().count.assert_any_call('authn_type.BasicAuth')
示例#37
0
 def config_fails(settings):
     config = Configurator(settings=settings)
     with self.assertRaises(ConfigurationError):
         cliquet.initialize(config, '0.0.1', 'project_name')
示例#38
0
 def settings(self, provided):
     config = Configurator(settings=provided)
     cliquet.initialize(config, '1.0', 'kinto')
     return config.get_settings()
示例#39
0
 def test_set_the_project_name_from_settings_even_if_specified(self):
     config = Configurator(settings={'cliquet.project_name': 'kinto'})
     cliquet.initialize(config, '0.0.1', 'readinglist')
     self.assertEqual(config.registry.settings['cliquet.project_name'],
                      'kinto')
示例#40
0
 def test_statsd_counts_views_and_methods(self, mocked):
     cliquet.initialize(self.config, '0.0.1', 'project_name')
     app = webtest.TestApp(self.config.make_wsgi_app())
     app.get('/v0/__heartbeat__')
     mocked().count.assert_any_call('view.heartbeat.GET')
示例#41
0
 def test_http_api_version_relies_on_project_version_by_default(self):
     config = Configurator()
     cliquet.initialize(config, '0.1.0', 'name')
     self.assertEqual(config.registry.settings['http_api_version'], '0.1')
示例#42
0
 def test_statsd_counts_authentication_types(self, mocked):
     cliquet.initialize(self.config, '0.0.1', 'project_name')
     app = webtest.TestApp(self.config.make_wsgi_app())
     headers = {'Authorization': 'Basic bWF0Og=='}
     app.get('/v0/', headers=headers)
     mocked().count.assert_any_call('authn_type.basicauth')
示例#43
0
 def test_http_api_version_uses_setting_if_specified(self):
     config = Configurator(settings={'cliquet.http_api_version': '1.3'})
     cliquet.initialize(config, '0.0.1', 'name')
     self.assertEqual(config.registry.settings['http_api_version'], '1.3')
示例#44
0
 def test_set_the_project_name_if_specified(self):
     config = Configurator()
     cliquet.initialize(config, '0.0.1', 'kinto')
     self.assertEqual(config.registry.settings['project_name'], 'kinto')
示例#45
0
 def test_set_the_project_name_from_settings_even_if_specified(self):
     config = Configurator(settings={'cliquet.project_name': 'kinto'})
     cliquet.initialize(config, '0.0.1', 'readinglist')
     self.assertEqual(config.registry.settings['project_name'], 'kinto')
示例#46
0
 def test_warns_if_project_name_is_missing(self):
     config = Configurator()
     with mock.patch('cliquet.warnings.warn') as mocked:
         cliquet.initialize(config, '0.0.1')
         error_msg = 'No value specified for `project_name`'
         mocked.assert_called_with(error_msg)
示例#47
0
 def test_set_the_project_name_if_specified(self):
     config = Configurator()
     cliquet.initialize(config, '0.0.1', 'kinto')
     self.assertEqual(config.registry.settings['cliquet.project_name'],
                      'kinto')
示例#48
0
 def test_statsd_counts_nothing_on_anonymous_requests(self, mocked):
     cliquet.initialize(self.config, '0.0.1')
     app = webtest.TestApp(self.config.make_wsgi_app())
     app.get('/')
     self.assertFalse(mocked.count.called)
示例#49
0
 def test_overriden_default_settings(self):
     config = Configurator()
     defaults = {'cliquet.paginate_by': 102}
     cliquet.initialize(config, '0.0.1', default_settings=defaults)
     self.assertEqual(config.registry.settings['cliquet.paginate_by'], 102)
示例#50
0
 def test_statsd_counts_views_and_methods(self, mocked):
     cliquet.initialize(self.config, '0.0.1')
     app = webtest.TestApp(self.config.make_wsgi_app())
     app.get('/v0/__heartbeat__')
     mocked().count.assert_any_call('view.heartbeat.GET')
示例#51
0
 def test_uses_the_version_for_prefix(self):
     config = Configurator()
     cliquet.initialize(config, '0.0.1', 'name')
     self.assertEqual(config.route_prefix, 'v0')
示例#52
0
 def test_statsd_counts_nothing_on_anonymous_requests(self, mocked):
     cliquet.initialize(self.config, '0.0.1', 'project_name')
     app = webtest.TestApp(self.config.make_wsgi_app())
     app.get('/')
     self.assertFalse(mocked.count.called)
示例#53
0
 def test_warns_if_project_name_is_missing(self):
     config = Configurator()
     with mock.patch('cliquet.initialization.warnings.warn') as mocked:
         cliquet.initialize(config, '0.0.1')
         error_msg = 'No value specified for `project_name`'
         mocked.assert_called_with(error_msg)
示例#54
0
 def test_backends_are_not_instantiated_by_default(self):
     config = Configurator(settings=cliquet.DEFAULT_SETTINGS)
     cliquet.initialize(config, '0.0.1', 'project_name')
     self.assertFalse(hasattr(config.registry, 'storage'))
     self.assertFalse(hasattr(config.registry, 'cache'))
     self.assertFalse(hasattr(config.registry, 'permission'))