[REF] factorize code : allways set --log-level=DEBUG in test framework
This commit is contained in:
parent
e5b0ebe6e8
commit
e124f3d27f
|
|
@ -0,0 +1 @@
|
||||||
|
Factorize code. Allways set --log-level=DEBUG in tests.
|
||||||
|
|
@ -30,10 +30,13 @@ def move_to_test_folder():
|
||||||
|
|
||||||
|
|
||||||
def cli_runner_invoke(cmd, expect_success=True):
|
def cli_runner_invoke(cmd, expect_success=True):
|
||||||
|
if not cmd:
|
||||||
|
cmd = []
|
||||||
|
cmd = ["--log-level=DEBUG"] + cmd
|
||||||
try:
|
try:
|
||||||
result = CliRunner().invoke(
|
result = CliRunner().invoke(
|
||||||
main,
|
main,
|
||||||
cmd,
|
args=cmd,
|
||||||
catch_exceptions=False,
|
catch_exceptions=False,
|
||||||
)
|
)
|
||||||
if expect_success:
|
if expect_success:
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ def test_cli_init():
|
||||||
|
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(
|
||||||
[
|
[
|
||||||
"--log-level=DEBUG",
|
|
||||||
"init",
|
"init",
|
||||||
"--project-name=test-cli",
|
"--project-name=test-cli",
|
||||||
"--initial-version=14.0",
|
"--initial-version=14.0",
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,7 @@ from . import cli_runner_invoke, move_to_test_folder
|
||||||
def test_cli_get_code():
|
def test_cli_get_code():
|
||||||
move_to_test_folder()
|
move_to_test_folder()
|
||||||
|
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(["get-code"])
|
||||||
[
|
|
||||||
"--log-level=DEBUG",
|
|
||||||
"get-code",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
# Check V14
|
# Check V14
|
||||||
web_path = Path("./src/env_14.0/src/OCA/web")
|
web_path = Path("./src/env_14.0/src/OCA/web")
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,7 @@ def test_cli_docker_build():
|
||||||
# be sure that the call (environment, etc...) is correct now.)
|
# be sure that the call (environment, etc...) is correct now.)
|
||||||
kill_container(ctx.obj["config"]["postgres_container_name"])
|
kill_container(ctx.obj["config"]["postgres_container_name"])
|
||||||
|
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(["docker-build", "--versions=14.0,15.0"])
|
||||||
[
|
|
||||||
"--log-level=DEBUG",
|
|
||||||
"docker-build",
|
|
||||||
"--versions=14.0,15.0",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
docker_client = get_docker_client()
|
docker_client = get_docker_client()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ def test_cli_run():
|
||||||
|
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(
|
||||||
[
|
[
|
||||||
"--log-level=DEBUG",
|
|
||||||
"run",
|
"run",
|
||||||
"--step=1",
|
"--step=1",
|
||||||
"--database=%s" % db_name,
|
"--database=%s" % db_name,
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ def test_cli_execute_script_python():
|
||||||
# Install Odoo on V14 with base installed
|
# Install Odoo on V14 with base installed
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(
|
||||||
[
|
[
|
||||||
"--log-level=DEBUG",
|
|
||||||
"run",
|
"run",
|
||||||
"--step=1",
|
"--step=1",
|
||||||
"--database=%s" % db_name,
|
"--database=%s" % db_name,
|
||||||
|
|
@ -50,7 +49,6 @@ def test_cli_execute_script_python():
|
||||||
# Execute Custom Python Script
|
# Execute Custom Python Script
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(
|
||||||
[
|
[
|
||||||
"--log-level=DEBUG",
|
|
||||||
"execute-script-python",
|
"execute-script-python",
|
||||||
"--step=1",
|
"--step=1",
|
||||||
"--database=%s" % db_name,
|
"--database=%s" % db_name,
|
||||||
|
|
|
||||||
|
|
@ -34,12 +34,7 @@ def test_cli_execute_script_sql():
|
||||||
# TODO call with script-file-path
|
# TODO call with script-file-path
|
||||||
# to avoid to copy file in scripts/step_xxx folder
|
# to avoid to copy file in scripts/step_xxx folder
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(
|
||||||
[
|
["execute-script-sql", "--step=1", "--database=%s" % db_name]
|
||||||
"--log-level=DEBUG",
|
|
||||||
"execute-script-sql",
|
|
||||||
"--step=1",
|
|
||||||
"--database=%s" % db_name,
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Ensure that the request has been done correctly
|
# Ensure that the request has been done correctly
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ def test_cli_upgrade():
|
||||||
|
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(
|
||||||
[
|
[
|
||||||
"--log-level=DEBUG",
|
|
||||||
"run",
|
"run",
|
||||||
"--step=1",
|
"--step=1",
|
||||||
"--database=%s" % db_name,
|
"--database=%s" % db_name,
|
||||||
|
|
@ -42,7 +41,6 @@ def test_cli_upgrade():
|
||||||
|
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(
|
||||||
[
|
[
|
||||||
"--log-level=DEBUG",
|
|
||||||
"upgrade",
|
"upgrade",
|
||||||
"--database=%s" % db_name,
|
"--database=%s" % db_name,
|
||||||
"--first-step=1",
|
"--first-step=1",
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ class TestCliEstimateWorkload(unittest.TestCase):
|
||||||
|
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(
|
||||||
[
|
[
|
||||||
"--log-level=DEBUG",
|
|
||||||
"estimate-workload",
|
"estimate-workload",
|
||||||
"--extra-modules="
|
"--extra-modules="
|
||||||
# Done Module
|
# Done Module
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,7 @@ def test_cli_install_from_csv(mocker):
|
||||||
|
|
||||||
ensure_database(ctx, db_name, state="absent")
|
ensure_database(ctx, db_name, state="absent")
|
||||||
|
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(["install-from-csv", "--database=%s" % db_name])
|
||||||
[
|
|
||||||
"--log-level=DEBUG",
|
|
||||||
"install-from-csv",
|
|
||||||
"--database=%s" % db_name,
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
# Ensure that 'base' is installed
|
# Ensure that 'base' is installed
|
||||||
request = (
|
request = (
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ def test_cli_generate_module_analysis(mocker):
|
||||||
analysis_file_path
|
analysis_file_path
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(
|
||||||
[
|
[
|
||||||
"--log-level=DEBUG",
|
|
||||||
"generate-module-analysis",
|
"generate-module-analysis",
|
||||||
"--step=2",
|
"--step=2",
|
||||||
"--database=%s" % db_name,
|
"--database=%s" % db_name,
|
||||||
|
|
|
||||||
|
|
@ -20,13 +20,7 @@ def test_cli_dumpdb(mocker):
|
||||||
ctx = build_ctx_from_config_file()
|
ctx = build_ctx_from_config_file()
|
||||||
ensure_database(ctx, db_name, state="absent")
|
ensure_database(ctx, db_name, state="absent")
|
||||||
|
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(["install-from-csv", f"--database={db_name}"])
|
||||||
[
|
|
||||||
"--log-level=DEBUG",
|
|
||||||
"install-from-csv",
|
|
||||||
f"--database={db_name}",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
# Dump database and filestore
|
# Dump database and filestore
|
||||||
formatlist = [("p", "d"), ("c", "tgz"), ("t", "t"), ("d", "d")]
|
formatlist = [("p", "d"), ("c", "tgz"), ("t", "t"), ("d", "d")]
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@ def test_cli_restoredb(mocker):
|
||||||
|
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(
|
||||||
[
|
[
|
||||||
"--log-level=DEBUG",
|
|
||||||
"restoredb",
|
"restoredb",
|
||||||
f"--database={db_name}",
|
f"--database={db_name}",
|
||||||
f"--database-path={database_path}",
|
f"--database-path={database_path}",
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ def test_cli_psql():
|
||||||
# initialize database
|
# initialize database
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(
|
||||||
[
|
[
|
||||||
"--log-level=DEBUG",
|
|
||||||
"run",
|
"run",
|
||||||
"--step=1",
|
"--step=1",
|
||||||
"--database=%s" % db_name,
|
"--database=%s" % db_name,
|
||||||
|
|
@ -49,7 +48,6 @@ def test_cli_psql():
|
||||||
# test via cli ok
|
# test via cli ok
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(
|
||||||
[
|
[
|
||||||
"--log-level=DEBUG",
|
|
||||||
"psql",
|
"psql",
|
||||||
"--database=%s" % db_name,
|
"--database=%s" % db_name,
|
||||||
'--command "%s"' % request,
|
'--command "%s"' % request,
|
||||||
|
|
@ -62,7 +60,6 @@ def test_cli_psql():
|
||||||
with raises(Exception):
|
with raises(Exception):
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(
|
||||||
[
|
[
|
||||||
"--log-level=DEBUG",
|
|
||||||
"psql",
|
"psql",
|
||||||
"--database=%s" % db_name,
|
"--database=%s" % db_name,
|
||||||
'--command "%s"' % request,
|
'--command "%s"' % request,
|
||||||
|
|
|
||||||
|
|
@ -26,18 +26,11 @@ def test_cli_copydb(mocker):
|
||||||
shutil.rmtree(dest_filestore_path, ignore_errors=True)
|
shutil.rmtree(dest_filestore_path, ignore_errors=True)
|
||||||
|
|
||||||
# Initialize database
|
# Initialize database
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(["install-from-csv", f"--database={db_name}"])
|
||||||
[
|
|
||||||
"--log-level=DEBUG",
|
|
||||||
"install-from-csv",
|
|
||||||
f"--database={db_name}",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
# Copy database
|
# Copy database
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(
|
||||||
[
|
[
|
||||||
"--log-level=DEBUG",
|
|
||||||
"copydb",
|
"copydb",
|
||||||
f"--source={db_name}",
|
f"--source={db_name}",
|
||||||
f"--dest={db_dest_name}",
|
f"--dest={db_dest_name}",
|
||||||
|
|
|
||||||
|
|
@ -25,22 +25,10 @@ def test_cli_dropdb(mocker):
|
||||||
shutil.rmtree(filestore_path, ignore_errors=True)
|
shutil.rmtree(filestore_path, ignore_errors=True)
|
||||||
|
|
||||||
# Initialize database
|
# Initialize database
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(["install-from-csv", f"--database={db_name}"])
|
||||||
[
|
|
||||||
"--log-level=DEBUG",
|
|
||||||
"install-from-csv",
|
|
||||||
f"--database={db_name}",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
# Drop database
|
# Drop database
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(["dropdb", f"--database={db_name}"])
|
||||||
[
|
|
||||||
"--log-level=DEBUG",
|
|
||||||
"dropdb",
|
|
||||||
f"--database={db_name}",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
# Check database does not exists
|
# Check database does not exists
|
||||||
assert_database(ctx, db_name, "absent")
|
assert_database(ctx, db_name, "absent")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user