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
评论列表
文章目录