[REF] factorize code : allways set --log-level=DEBUG in test framework

This commit is contained in:
Sylvain LE GAL 2024-03-22 23:47:04 +01:00
parent e5b0ebe6e8
commit e124f3d27f
17 changed files with 13 additions and 68 deletions

View File

@ -0,0 +1 @@
Factorize code. Allways set --log-level=DEBUG in tests.

View File

@ -30,10 +30,13 @@ def move_to_test_folder():
def cli_runner_invoke(cmd, expect_success=True):
if not cmd:
cmd = []
cmd = ["--log-level=DEBUG"] + cmd
try:
result = CliRunner().invoke(
main,
cmd,
args=cmd,
catch_exceptions=False,
)
if expect_success:

View File

@ -11,7 +11,6 @@ def test_cli_init():
cli_runner_invoke(
[
"--log-level=DEBUG",
"init",
"--project-name=test-cli",
"--initial-version=14.0",

View File

@ -6,12 +6,7 @@ from . import cli_runner_invoke, move_to_test_folder
def test_cli_get_code():
move_to_test_folder()
cli_runner_invoke(
[
"--log-level=DEBUG",
"get-code",
],
)
cli_runner_invoke(["get-code"])
# Check V14
web_path = Path("./src/env_14.0/src/OCA/web")

View File

@ -19,13 +19,7 @@ def test_cli_docker_build():
# be sure that the call (environment, etc...) is correct now.)
kill_container(ctx.obj["config"]["postgres_container_name"])
cli_runner_invoke(
[
"--log-level=DEBUG",
"docker-build",
"--versions=14.0,15.0",
],
)
cli_runner_invoke(["docker-build", "--versions=14.0,15.0"])
docker_client = get_docker_client()

View File

@ -22,7 +22,6 @@ def test_cli_run():
cli_runner_invoke(
[
"--log-level=DEBUG",
"run",
"--step=1",
"--database=%s" % db_name,

View File

@ -32,7 +32,6 @@ def test_cli_execute_script_python():
# Install Odoo on V14 with base installed
cli_runner_invoke(
[
"--log-level=DEBUG",
"run",
"--step=1",
"--database=%s" % db_name,
@ -50,7 +49,6 @@ def test_cli_execute_script_python():
# Execute Custom Python Script
cli_runner_invoke(
[
"--log-level=DEBUG",
"execute-script-python",
"--step=1",
"--database=%s" % db_name,

View File

@ -34,12 +34,7 @@ def test_cli_execute_script_sql():
# TODO call with script-file-path
# to avoid to copy file in scripts/step_xxx folder
cli_runner_invoke(
[
"--log-level=DEBUG",
"execute-script-sql",
"--step=1",
"--database=%s" % db_name,
],
["execute-script-sql", "--step=1", "--database=%s" % db_name]
)
# Ensure that the request has been done correctly

View File

@ -20,7 +20,6 @@ def test_cli_upgrade():
cli_runner_invoke(
[
"--log-level=DEBUG",
"run",
"--step=1",
"--database=%s" % db_name,
@ -42,7 +41,6 @@ def test_cli_upgrade():
cli_runner_invoke(
[
"--log-level=DEBUG",
"upgrade",
"--database=%s" % db_name,
"--first-step=1",

View File

@ -10,7 +10,6 @@ class TestCliEstimateWorkload(unittest.TestCase):
cli_runner_invoke(
[
"--log-level=DEBUG",
"estimate-workload",
"--extra-modules="
# Done Module

View File

@ -21,13 +21,7 @@ def test_cli_install_from_csv(mocker):
ensure_database(ctx, db_name, state="absent")
cli_runner_invoke(
[
"--log-level=DEBUG",
"install-from-csv",
"--database=%s" % db_name,
],
)
cli_runner_invoke(["install-from-csv", "--database=%s" % db_name])
# Ensure that 'base' is installed
request = (

View File

@ -32,7 +32,6 @@ def test_cli_generate_module_analysis(mocker):
analysis_file_path
cli_runner_invoke(
[
"--log-level=DEBUG",
"generate-module-analysis",
"--step=2",
"--database=%s" % db_name,

View File

@ -20,13 +20,7 @@ def test_cli_dumpdb(mocker):
ctx = build_ctx_from_config_file()
ensure_database(ctx, db_name, state="absent")
cli_runner_invoke(
[
"--log-level=DEBUG",
"install-from-csv",
f"--database={db_name}",
],
)
cli_runner_invoke(["install-from-csv", f"--database={db_name}"])
# Dump database and filestore
formatlist = [("p", "d"), ("c", "tgz"), ("t", "t"), ("d", "d")]

View File

@ -33,7 +33,6 @@ def test_cli_restoredb(mocker):
cli_runner_invoke(
[
"--log-level=DEBUG",
"restoredb",
f"--database={db_name}",
f"--database-path={database_path}",

View File

@ -22,7 +22,6 @@ def test_cli_psql():
# initialize database
cli_runner_invoke(
[
"--log-level=DEBUG",
"run",
"--step=1",
"--database=%s" % db_name,
@ -49,7 +48,6 @@ def test_cli_psql():
# test via cli ok
cli_runner_invoke(
[
"--log-level=DEBUG",
"psql",
"--database=%s" % db_name,
'--command "%s"' % request,
@ -62,7 +60,6 @@ def test_cli_psql():
with raises(Exception):
cli_runner_invoke(
[
"--log-level=DEBUG",
"psql",
"--database=%s" % db_name,
'--command "%s"' % request,

View File

@ -26,18 +26,11 @@ def test_cli_copydb(mocker):
shutil.rmtree(dest_filestore_path, ignore_errors=True)
# Initialize database
cli_runner_invoke(
[
"--log-level=DEBUG",
"install-from-csv",
f"--database={db_name}",
],
)
cli_runner_invoke(["install-from-csv", f"--database={db_name}"])
# Copy database
cli_runner_invoke(
[
"--log-level=DEBUG",
"copydb",
f"--source={db_name}",
f"--dest={db_dest_name}",

View File

@ -25,22 +25,10 @@ def test_cli_dropdb(mocker):
shutil.rmtree(filestore_path, ignore_errors=True)
# Initialize database
cli_runner_invoke(
[
"--log-level=DEBUG",
"install-from-csv",
f"--database={db_name}",
],
)
cli_runner_invoke(["install-from-csv", f"--database={db_name}"])
# Drop database
cli_runner_invoke(
[
"--log-level=DEBUG",
"dropdb",
f"--database={db_name}",
],
)
cli_runner_invoke(["dropdb", f"--database={db_name}"])
# Check database does not exists
assert_database(ctx, db_name, "absent")