diff --git a/tests/__init__.py b/tests/__init__.py index a94b917..d2616bb 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -28,7 +28,7 @@ def move_to_test_folder(): os.chdir(test_folder_path) -def cli_runner_invoke(ctx, cmd): +def cli_runner_invoke(cmd): try: result = CliRunner().invoke( main, @@ -42,8 +42,8 @@ def cli_runner_invoke(ctx, cmd): except Exception as exception: log_files = [ - ctx.obj["log_folder_path"] / Path(f) - for f in os.listdir(ctx.obj["log_folder_path"]) + Path("log") / Path(f) + for f in os.listdir(Path("log")) if f[-4:] == ".log" ] for log_file in log_files: @@ -77,5 +77,4 @@ def build_ctx_from_config_file() -> dict: ctx.obj["env_folder_path"] = env_folder_path ctx.obj["src_folder_path"] = env_folder_path / Path("src") - ctx.obj["log_folder_path"] = env_folder_path / Path("log") return ctx diff --git a/tests/cli_01_init_test.py b/tests/cli_01_init_test.py index eb20d9e..01e1b0c 100644 --- a/tests/cli_01_init_test.py +++ b/tests/cli_01_init_test.py @@ -1,21 +1,15 @@ import filecmp from pathlib import Path -from . import ( - build_ctx_from_config_file, - cli_runner_invoke, - move_to_test_folder, -) +from . import cli_runner_invoke, move_to_test_folder def test_cli_init(): move_to_test_folder() - ctx = build_ctx_from_config_file() expected_folder_path = Path("../output_expected").absolute() cli_runner_invoke( - ctx, [ "--log-level=DEBUG", "init", diff --git a/tests/cli_02_get_code_test.py b/tests/cli_02_get_code_test.py index ef7d9b5..a686c65 100644 --- a/tests/cli_02_get_code_test.py +++ b/tests/cli_02_get_code_test.py @@ -1,18 +1,12 @@ from pathlib import Path -from . import ( - build_ctx_from_config_file, - cli_runner_invoke, - move_to_test_folder, -) +from . import cli_runner_invoke, move_to_test_folder def test_cli_get_code(): move_to_test_folder() - ctx = build_ctx_from_config_file() cli_runner_invoke( - ctx, [ "--log-level=DEBUG", "get-code", diff --git a/tests/cli_03_docker_build_test.py b/tests/cli_03_docker_build_test.py index 649ab7a..a2b0be3 100644 --- a/tests/cli_03_docker_build_test.py +++ b/tests/cli_03_docker_build_test.py @@ -1,18 +1,12 @@ from odoo_openupgrade_wizard.tools.tools_docker import get_docker_client -from . import ( - build_ctx_from_config_file, - cli_runner_invoke, - move_to_test_folder, -) +from . import cli_runner_invoke, move_to_test_folder def test_cli_docker_build(): move_to_test_folder() - ctx = build_ctx_from_config_file() cli_runner_invoke( - ctx, [ "--log-level=DEBUG", "docker-build", diff --git a/tests/cli_04_run_test.py b/tests/cli_04_run_test.py index 834256f..e0a4a59 100644 --- a/tests/cli_04_run_test.py +++ b/tests/cli_04_run_test.py @@ -21,7 +21,6 @@ def test_cli_run(): ensure_database(ctx, db_name, state="absent") cli_runner_invoke( - ctx, [ "--log-level=DEBUG", "run", diff --git a/tests/cli_05_execute_script_python_test.py b/tests/cli_05_execute_script_python_test.py index a151b8c..4f44e4f 100644 --- a/tests/cli_05_execute_script_python_test.py +++ b/tests/cli_05_execute_script_python_test.py @@ -31,7 +31,6 @@ def test_cli_execute_script_python(): # Install Odoo on V14 with base installed cli_runner_invoke( - ctx, [ "--log-level=DEBUG", "run", @@ -50,7 +49,6 @@ def test_cli_execute_script_python(): # Execute Custom Python Script cli_runner_invoke( - ctx, [ "--log-level=DEBUG", "execute-script-python", diff --git a/tests/cli_06_execute_script_sql_test.py b/tests/cli_06_execute_script_sql_test.py index fa71486..54294df 100644 --- a/tests/cli_06_execute_script_sql_test.py +++ b/tests/cli_06_execute_script_sql_test.py @@ -16,6 +16,8 @@ from . import ( def test_cli_execute_script_sql(): move_to_test_folder() + ctx = build_ctx_from_config_file() + extra_script_path = Path( "../extra_script/pre-migration-custom_test.sql" ).absolute() @@ -23,7 +25,6 @@ def test_cli_execute_script_sql(): # Deploy SQL Script destination_path = Path("scripts/step_01__update__14.0") cp([extra_script_path, destination_path]) - ctx = build_ctx_from_config_file() # Reset database db_name = "database_test_cli___execute_script_sql" diff --git a/tests/cli_07_upgrade_test.py b/tests/cli_07_upgrade_test.py index e1b0c63..a8b610d 100644 --- a/tests/cli_07_upgrade_test.py +++ b/tests/cli_07_upgrade_test.py @@ -19,7 +19,6 @@ def test_cli_upgrade(): ensure_database(ctx, db_name, state="absent") cli_runner_invoke( - ctx, [ "--log-level=DEBUG", "run", @@ -42,7 +41,6 @@ def test_cli_upgrade(): assert latest_version[0][0].startswith("14.") cli_runner_invoke( - ctx, [ "--log-level=DEBUG", "upgrade", diff --git a/tests/cli_08_estimate_workload_test.py b/tests/cli_08_estimate_workload_test.py index 3a88555..7007611 100644 --- a/tests/cli_08_estimate_workload_test.py +++ b/tests/cli_08_estimate_workload_test.py @@ -1,20 +1,14 @@ import unittest from pathlib import Path -from . import ( - build_ctx_from_config_file, - cli_runner_invoke, - move_to_test_folder, -) +from . import cli_runner_invoke, move_to_test_folder class TestCliEstimateWorkload(unittest.TestCase): def test_cli_estimate_workload(self): move_to_test_folder() - ctx = build_ctx_from_config_file() cli_runner_invoke( - ctx, [ "--log-level=DEBUG", "estimate-workload", diff --git a/tests/cli_20_install_from_csv_test.py b/tests/cli_20_install_from_csv_test.py index c539a4f..8bc21fb 100644 --- a/tests/cli_20_install_from_csv_test.py +++ b/tests/cli_20_install_from_csv_test.py @@ -19,7 +19,6 @@ def test_cli_install_from_csv(): ensure_database(ctx, db_name, state="absent") cli_runner_invoke( - ctx, [ "--log-level=DEBUG", "install-from-csv", diff --git a/tests/cli_21_generate_module_analysis_test.py b/tests/cli_21_generate_module_analysis_test.py index f640aeb..3280e66 100644 --- a/tests/cli_21_generate_module_analysis_test.py +++ b/tests/cli_21_generate_module_analysis_test.py @@ -11,9 +11,10 @@ from . import ( def test_cli_generate_module_analysis(): move_to_test_folder() + ctx = build_ctx_from_config_file() + db_name = "database_test_cli___generate_module_analysis" - ctx = build_ctx_from_config_file() # identify main analysis file of openupgrade analysis_file_path = get_odoo_env_path(ctx, 15.0) / Path( "src/openupgrade/openupgrade_scripts/scripts" @@ -28,7 +29,6 @@ def test_cli_generate_module_analysis(): analysis_file_path cli_runner_invoke( - ctx, [ "--log-level=DEBUG", "generate-module-analysis",