• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python application.Warehouse类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中warehouse.application.Warehouse的典型用法代码示例。如果您正苦于以下问题:Python Warehouse类的具体用法?Python Warehouse怎么用?Python Warehouse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Warehouse类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_static_middleware

def test_static_middleware(monkeypatch):
    WhiteNoise = pretend.call_recorder(lambda app, root, prefix, max_age: app)

    monkeypatch.setattr(
        application,
        "WhiteNoise",
        WhiteNoise,
    )

    Warehouse.from_yaml(
        os.path.abspath(os.path.join(
            os.path.dirname(__file__),
            "test_config.yml",
        )),
    )

    assert WhiteNoise.calls == [
        pretend.call(
            mock.ANY,
            root=os.path.abspath(
                os.path.join(
                    os.path.dirname(warehouse.__file__),
                    "static",
                    "compiled",
                ),
            ),
            prefix="/static/",
            max_age=31557600,
        )
    ]
开发者ID:meatballhat,项目名称:warehouse,代码行数:30,代码来源:test_application.py


示例2: test_static_middleware

def test_static_middleware(monkeypatch):
    SharedDataMiddleware = pretend.call_recorder(lambda app, c: app)

    monkeypatch.setattr(
        application,
        "SharedDataMiddleware",
        SharedDataMiddleware,
    )

    Warehouse.from_yaml(
        os.path.abspath(os.path.join(
            os.path.dirname(__file__),
            "test_config.yml",
        )),
    )

    assert SharedDataMiddleware.calls == [
        pretend.call(
            mock.ANY,
            {
                "/static/": os.path.abspath(
                    os.path.join(
                        os.path.dirname(warehouse.__file__),
                        "static",
                    ),
                ),
            },
        )
    ]
开发者ID:Ivoz,项目名称:warehouse,代码行数:29,代码来源:test_application.py


示例3: test_header_rewrite_middleware

def test_header_rewrite_middleware(monkeypatch):
    HeaderRewriterFix = pretend.call_recorder(lambda app, **kw: app)

    monkeypatch.setattr(application, "HeaderRewriterFix", HeaderRewriterFix)

    Warehouse.from_yaml(
        os.path.abspath(os.path.join(
            os.path.dirname(__file__),
            "test_config.yml",
        )),
    )

    assert HeaderRewriterFix.calls == [
        pretend.call(
            mock.ANY,
            add_headers=[
                (
                    "X-Powered-By",
                    "Warehouse {__version__} ({__build__})".format(
                        __version__=warehouse.__version__,
                        __build__=warehouse.__build__,
                    ),
                ),
            ],
        ),
    ]
开发者ID:meatballhat,项目名称:warehouse,代码行数:26,代码来源:test_application.py


示例4: test_yaml_instantiation

def test_yaml_instantiation():
    Warehouse.from_yaml(
        os.path.abspath(os.path.join(
            os.path.dirname(__file__),
            "test_config.yml",
        )),
    )
开发者ID:meatballhat,项目名称:warehouse,代码行数:7,代码来源:test_application.py


示例5: test_cli_instantiation

def test_cli_instantiation(capsys):
    with pytest.raises(SystemExit):
        Warehouse.from_cli(["-h"])

    out, err = capsys.readouterr()

    assert "usage: warehouse" in out
    assert not err
开发者ID:pombredanne,项目名称:warehouse-1,代码行数:8,代码来源:test_application.py


示例6: test_running_cli_command

def test_running_cli_command(monkeypatch):
    commands = {"serve": pretend.call_recorder(lambda *a, **k: None)}
    monkeypatch.setattr(cli, "__commands__", commands)

    config = os.path.abspath(os.path.join(os.path.dirname(__file__), "test_config.yml"))

    Warehouse.from_cli(["-c", config, "serve"])

    assert commands["serve"].calls == [pretend.call(mock.ANY)]
开发者ID:pombredanne,项目名称:warehouse-1,代码行数:9,代码来源:test_application.py


示例7: test_guard_middleware

def test_guard_middleware(monkeypatch):
    ContentSecurityPolicy = pretend.call_recorder(lambda app, policy: app)

    monkeypatch.setattr(guard, "ContentSecurityPolicy", ContentSecurityPolicy)

    Warehouse.from_yaml(
        os.path.abspath(os.path.join(
            os.path.dirname(__file__),
            "test_config.yml",
        )),
    )

    assert ContentSecurityPolicy.calls == [pretend.call(mock.ANY, mock.ANY)]
开发者ID:meatballhat,项目名称:warehouse,代码行数:13,代码来源:test_application.py


示例8: test_guard_middleware_theme_debug

def test_guard_middleware_theme_debug(monkeypatch):
    ContentSecurityPolicy = pretend.call_recorder(lambda app, policy: app)

    monkeypatch.setattr(guard, "ContentSecurityPolicy", ContentSecurityPolicy)

    Warehouse.from_yaml(
        os.path.abspath(os.path.join(
            os.path.dirname(__file__),
            "test_config.yml",
        )),
        override={"theme_debug": True},
    )

    assert ContentSecurityPolicy.calls == []
开发者ID:robhudson,项目名称:warehouse,代码行数:14,代码来源:test_application.py


示例9: app

def app():
    from warehouse.application import Warehouse

    def connect():
        raise RuntimeError(
            "Cannot access the database through the app fixture"
        )

    engine = pretend.stub(connect=connect)

    return Warehouse.from_yaml(
        override={
            "site": {
                "access_token": "testing",
                "hosts": "localhost",
            },
            "database": {"url": "postgresql:///nonexistant"},
            "redis": {
                "downloads": "redis://nonexistant/0",
                "sessions": "redis://nonexistant/0",
            },
            "search": {"hosts": []},
        },
        engine=engine,
        redis_class=ErrorRedis,
    )
开发者ID:greatestape,项目名称:warehouse,代码行数:26,代码来源:conftest.py


示例10: dbapp

def dbapp(database, _database):
    from warehouse.application import Warehouse

    return Warehouse.from_yaml(
        override={"database": {"url": _database}},
        engine=database,
    )
开发者ID:domenkozar,项目名称:warehouse,代码行数:7,代码来源:conftest.py


示例11: _database_url

def _database_url(request):
    from warehouse.application import Warehouse

    def _get_name():
        tag = "".join(
            random.choice(string.ascii_lowercase + string.digits)
            for x in range(7)
        )
        return "warehousetest_{}".format(tag)

    def _check_name(engine, name):
        with engine.connect() as conn:
            results = conn.execute(
                "SELECT datname FROM pg_database WHERE datistemplate = false"
            )
            return name not in [r[0] for r in results]

    database_url_default = 'postgresql://localhost/test_warehouse'
    database_url_environ = os.environ.get("WAREHOUSE_DATABASE_URL")
    database_url_option = request.config.getvalue("database_url")

    if (not database_url_default and not database_url_environ
            and not database_url_option):
        pytest.skip("No database provided")

    # Configure our engine so that we can empty the database
    database_url = (
        database_url_option or database_url_environ or database_url_default
    )

    # Create the database schema
    engine = sqlalchemy.create_engine(
        database_url,
        poolclass=sqlalchemy.pool.NullPool,
    )
    app = Warehouse.from_yaml(
        override={
            "database": {
                "url": database_url,
            },
            "search": {"hosts": []},
        },
        engine=engine,
        redis=False,
    )
    with app.engine.connect() as conn:
        conn.execute("DROP SCHEMA public CASCADE")
        conn.execute("CREATE SCHEMA public")
        conn.execute("CREATE EXTENSION IF NOT EXISTS citext")
        conn.execute('CREATE EXTENSION IF NOT EXISTS "uuid-ossp"')
    alembic_cfg = alembic.config.Config()
    alembic_cfg.set_main_option(
        "script_location",
        "warehouse:migrations",
    )
    alembic_cfg.set_main_option("url", app.config.database.url)
    alembic.command.upgrade(alembic_cfg, "head")
    engine.dispose()

    return database_url
开发者ID:b-jazz,项目名称:warehouse,代码行数:60,代码来源:conftest.py


示例12: test_shared_static

def test_shared_static():
    app = Warehouse.from_yaml(
        os.path.abspath(os.path.join(
            os.path.dirname(__file__),
            "test_config.yml",
        )),
        override={"debug": True},
    )

    assert isinstance(app.wsgi_app, SharedDataMiddleware)
开发者ID:robhudson,项目名称:warehouse,代码行数:10,代码来源:test_application.py


示例13: test_camo_settings

def test_camo_settings(monkeypatch):
    ContentSecurityPolicy = pretend.call_recorder(lambda app, policy: app)

    monkeypatch.setattr(guard, "ContentSecurityPolicy", ContentSecurityPolicy)

    Warehouse.from_yaml(
        os.path.abspath(os.path.join(
            os.path.dirname(__file__),
            "test_config.yml",
        )),
        override={"camo": {"url": "https://camo.example.com/", "key": "skey"}},
    )

    assert ContentSecurityPolicy.calls == [pretend.call(mock.ANY, mock.ANY)]
    assert set(ContentSecurityPolicy.calls[0].args[1]["img-src"]) == {
        "'self'",
        "https://camo.example.com",
        "https://secure.gravatar.com",
    }
开发者ID:meatballhat,项目名称:warehouse,代码行数:19,代码来源:test_application.py


示例14: test_sentry_middleware

def test_sentry_middleware(monkeypatch):
    Sentry = pretend.call_recorder(lambda app, client: app)
    client_obj = pretend.stub()
    Client = pretend.call_recorder(lambda **kw: client_obj)

    monkeypatch.setattr(application, "Sentry", Sentry)
    monkeypatch.setattr(application, "Client", Client)

    Warehouse.from_yaml(
        os.path.abspath(os.path.join(
            os.path.dirname(__file__),
            "test_config.yml",
        )),
        override={"sentry": {"dsn": "http://public:[email protected]/1"}}
    )

    assert Sentry.calls == [pretend.call(mock.ANY, client_obj)]
    assert Client.calls == [
        pretend.call(dsn="http://public:[email protected]/1"),
    ]
开发者ID:meatballhat,项目名称:warehouse,代码行数:20,代码来源:test_application.py


示例15: dbapp

def dbapp(database, _database_url):
    from warehouse.application import Warehouse

    return Warehouse.from_yaml(
        override={
            "database": {"url": _database_url},
            "search": {"hosts": []},
        },
        engine=database,
        redis=False,
    )
开发者ID:Ivoz,项目名称:warehouse,代码行数:11,代码来源:conftest.py


示例16: dbapp

def dbapp(engine):
    from warehouse.application import Warehouse

    return Warehouse.from_yaml(
        override={
            "site": {"access_token": "testing", "hosts": "localhost"},
            "redis": {"downloads": "redis://nonexistant/0", "sessions": "redis://nonexistant/0"},
            "search": {"hosts": []},
        },
        engine=engine,
        redis_class=ErrorRedis,
    )
开发者ID:r1chardj0n3s,项目名称:warehouse,代码行数:12,代码来源:conftest.py


示例17: app

def app():
    from warehouse.application import Warehouse

    def connect():
        raise RuntimeError(
            "Cannot access the database through the app fixture"
        )

    engine = pretend.stub(connect=connect)

    return Warehouse.from_yaml(
        override={"database": {"url": "postgresql:///nonexistant"}},
        engine=engine,
    )
开发者ID:domenkozar,项目名称:warehouse,代码行数:14,代码来源:conftest.py


示例18: dbapp

def dbapp(database, engine):
    from warehouse.application import Warehouse

    return Warehouse.from_yaml(
        override={
            "site": {"hosts": "localhost"},
            "database": {"url": database},
            "redis": {
                "downloads": "redis://nonexistant/0",
                "sessions": "redis://nonexistant/0",
            },
            "search": {"hosts": []},
        },
        engine=engine,
        redis_class=ErrorRedis,
    )
开发者ID:fugisawa,项目名称:warehouse,代码行数:16,代码来源:conftest.py


示例19: test_passlib_context

def test_passlib_context():
    app = Warehouse.from_yaml(
        os.path.abspath(os.path.join(
            os.path.dirname(__file__),
            "test_config.yml",
        )),
    )

    assert app.passlib.to_dict() == {
        "schemes": [
            "bcrypt_sha256",
            "bcrypt",
            "django_bcrypt",
            "unix_disabled",
        ],
        "default": "bcrypt_sha256",
        "deprecated": ["auto"],
    }
开发者ID:AaronLaw,项目名称:warehouse,代码行数:18,代码来源:test_application.py


示例20: main

def main():
    return Warehouse.from_cli(sys.argv[1:])
开发者ID:Ivoz,项目名称:warehouse,代码行数:2,代码来源:__main__.py



注:本文中的warehouse.application.Warehouse类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python origin.origin_cache函数代码示例发布时间:2022-05-26
下一篇:
Python warara_middleware.get_server函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap