This commit is contained in:
Sylvain LE GAL 2022-06-29 17:45:21 +02:00
parent 9f5dea8a00
commit 842e2ca389
11 changed files with 11 additions and 41 deletions

View File

@ -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

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -21,7 +21,6 @@ def test_cli_run():
ensure_database(ctx, db_name, state="absent")
cli_runner_invoke(
ctx,
[
"--log-level=DEBUG",
"run",

View File

@ -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",

View File

@ -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"

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",