diff --git a/newsfragments/set-log-level-debug-default-in-cli_runner_invoke.feature b/newsfragments/set-log-level-debug-default-in-cli_runner_invoke.feature new file mode 100644 index 0000000..01b5225 --- /dev/null +++ b/newsfragments/set-log-level-debug-default-in-cli_runner_invoke.feature @@ -0,0 +1 @@ +Factorize code. Allways set --log-level=DEBUG in tests. diff --git a/tests/__init__.py b/tests/__init__.py index b1fe69d..b6de448 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -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: diff --git a/tests/cli_01_init_test.py b/tests/cli_01_init_test.py index 4456971..8a4342f 100644 --- a/tests/cli_01_init_test.py +++ b/tests/cli_01_init_test.py @@ -11,7 +11,6 @@ def test_cli_init(): cli_runner_invoke( [ - "--log-level=DEBUG", "init", "--project-name=test-cli", "--initial-version=14.0", diff --git a/tests/cli_02_get_code_test.py b/tests/cli_02_get_code_test.py index a686c65..35da9ab 100644 --- a/tests/cli_02_get_code_test.py +++ b/tests/cli_02_get_code_test.py @@ -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") diff --git a/tests/cli_03_docker_build_test.py b/tests/cli_03_docker_build_test.py index 14a5009..ce44e0d 100644 --- a/tests/cli_03_docker_build_test.py +++ b/tests/cli_03_docker_build_test.py @@ -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() diff --git a/tests/cli_04_run_test.py b/tests/cli_04_run_test.py index e0a4a59..2bc76fd 100644 --- a/tests/cli_04_run_test.py +++ b/tests/cli_04_run_test.py @@ -22,7 +22,6 @@ def test_cli_run(): cli_runner_invoke( [ - "--log-level=DEBUG", "run", "--step=1", "--database=%s" % db_name, diff --git a/tests/cli_05_execute_script_python_test.py b/tests/cli_05_execute_script_python_test.py index 4f44e4f..6c1774e 100644 --- a/tests/cli_05_execute_script_python_test.py +++ b/tests/cli_05_execute_script_python_test.py @@ -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, diff --git a/tests/cli_06_execute_script_sql_test.py b/tests/cli_06_execute_script_sql_test.py index 524f780..9c1511d 100644 --- a/tests/cli_06_execute_script_sql_test.py +++ b/tests/cli_06_execute_script_sql_test.py @@ -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 diff --git a/tests/cli_07_upgrade_test.py b/tests/cli_07_upgrade_test.py index a8b610d..3ddffb5 100644 --- a/tests/cli_07_upgrade_test.py +++ b/tests/cli_07_upgrade_test.py @@ -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", diff --git a/tests/cli_08_estimate_workload_test.py b/tests/cli_08_estimate_workload_test.py index 7007611..9f4954b 100644 --- a/tests/cli_08_estimate_workload_test.py +++ b/tests/cli_08_estimate_workload_test.py @@ -10,7 +10,6 @@ class TestCliEstimateWorkload(unittest.TestCase): cli_runner_invoke( [ - "--log-level=DEBUG", "estimate-workload", "--extra-modules=" # Done Module diff --git a/tests/cli_20_install_from_csv_test.py b/tests/cli_20_install_from_csv_test.py index 784f4c0..95e97a7 100644 --- a/tests/cli_20_install_from_csv_test.py +++ b/tests/cli_20_install_from_csv_test.py @@ -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 = ( diff --git a/tests/cli_21_generate_module_analysis_test.py b/tests/cli_21_generate_module_analysis_test.py index e59fca6..23695d8 100644 --- a/tests/cli_21_generate_module_analysis_test.py +++ b/tests/cli_21_generate_module_analysis_test.py @@ -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, diff --git a/tests/cli_22_dumpdb_test.py b/tests/cli_22_dumpdb_test.py index b28e0fe..5af95c1 100644 --- a/tests/cli_22_dumpdb_test.py +++ b/tests/cli_22_dumpdb_test.py @@ -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")] diff --git a/tests/cli_23_restoredb_test.py b/tests/cli_23_restoredb_test.py index c1e4f91..f452c5a 100644 --- a/tests/cli_23_restoredb_test.py +++ b/tests/cli_23_restoredb_test.py @@ -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}", diff --git a/tests/cli_30_psql_test.py b/tests/cli_30_psql_test.py index bc32b60..c98760a 100644 --- a/tests/cli_30_psql_test.py +++ b/tests/cli_30_psql_test.py @@ -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, diff --git a/tests/cli_31_copydb_test.py b/tests/cli_31_copydb_test.py index 29db47a..66d1e82 100644 --- a/tests/cli_31_copydb_test.py +++ b/tests/cli_31_copydb_test.py @@ -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}", diff --git a/tests/cli_32_dropdb_test.py b/tests/cli_32_dropdb_test.py index 671edb4..36aa106 100644 --- a/tests/cli_32_dropdb_test.py +++ b/tests/cli_32_dropdb_test.py @@ -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")