test_db.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:openag_python 作者: OpenAgInitiative 项目源码 文件源码
def test_init_without_cloud_server(
    config, push_design_documents, get_or_create, generate_config
):
    runner = CliRunner()

    generate_config.return_value = {"test": {"test": "test"}}
    httpretty.register_uri(
        httpretty.GET, "http://localhost:5984/_config/test/test",
        body='"test_val"'
    )
    httpretty.register_uri(
        httpretty.PUT, "http://localhost:5984/_config/test/test"
    )

    # Show -- Should throw an error because no local server is selected
    res = runner.invoke(show)
    assert res.exit_code, res.output

    # Init -- Should work and push the design documents but not replicate
    # anything
    res = runner.invoke(init)
    assert res.exit_code == 0, res.exception or res.output
    assert get_or_create.call_count == len(all_dbs)
    assert push_design_documents.call_count == 1
    push_design_documents.reset_mock()

    # Show -- Should work
    res = runner.invoke(show)
    assert res.exit_code == 0, res.exception or res.output

    # Init -- Should throw an error because a different database is already
    # selected
    res = runner.invoke(init, ["--db_url", "http://test.test:5984"])
    assert res.exit_code, res.output
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号