[REF] Add logger in test
This commit is contained in:
parent
36db85e4b9
commit
1261dfaa2f
|
|
@ -51,6 +51,7 @@ def init(
|
|||
"""Initialize OpenUpgrade Wizard Environment based on the initial and
|
||||
the final version of Odoo you want to migrate.
|
||||
"""
|
||||
print(0 / 0)
|
||||
|
||||
# Handle arguments
|
||||
if extra_repository_list:
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ def move_to_test_folder():
|
|||
os.chdir(test_folder_path)
|
||||
|
||||
|
||||
def cli_runner_invoke(cmd):
|
||||
def cli_runner_invoke(ctx, cmd):
|
||||
try:
|
||||
result = CliRunner().invoke(
|
||||
main,
|
||||
cmd,
|
||||
|
|
@ -38,6 +39,22 @@ def cli_runner_invoke(cmd):
|
|||
_logger.error("exit_code: %s" % result.exit_code)
|
||||
_logger.error("output: %s" % result.output)
|
||||
assert result.exit_code == 0
|
||||
except Exception as exception:
|
||||
|
||||
log_files = [
|
||||
ctx.obj["log_folder_path"] / Path(f)
|
||||
for f in os.listdir(ctx.obj["log_folder_path"])
|
||||
if f[-4:] == ".log"
|
||||
]
|
||||
for log_file in log_files:
|
||||
print("============================")
|
||||
print(log_file)
|
||||
print("============================")
|
||||
_f = open(log_file)
|
||||
print(_f.read())
|
||||
_f.close()
|
||||
print("============================")
|
||||
raise exception
|
||||
|
||||
|
||||
def build_ctx_from_config_file() -> dict:
|
||||
|
|
@ -58,4 +75,5 @@ 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
|
||||
|
|
|
|||
|
|
@ -1,14 +1,21 @@
|
|||
import filecmp
|
||||
from pathlib import Path
|
||||
|
||||
from . import cli_runner_invoke, move_to_test_folder
|
||||
from . import (
|
||||
build_ctx_from_config_file,
|
||||
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",
|
||||
|
|
@ -17,7 +24,7 @@ def test_cli_init():
|
|||
"--final-version=15.0",
|
||||
"--extra-repository="
|
||||
"OCA/web,OCA/server-tools,OCA/bank-statement-import",
|
||||
]
|
||||
],
|
||||
)
|
||||
|
||||
assert filecmp.cmp(
|
||||
|
|
|
|||
|
|
@ -1,15 +1,22 @@
|
|||
from pathlib import Path
|
||||
|
||||
from . import cli_runner_invoke, move_to_test_folder
|
||||
from . import (
|
||||
build_ctx_from_config_file,
|
||||
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",
|
||||
]
|
||||
],
|
||||
)
|
||||
|
||||
# Check V14
|
||||
|
|
|
|||
|
|
@ -1,16 +1,23 @@
|
|||
from odoo_openupgrade_wizard.tools.tools_docker import get_docker_client
|
||||
|
||||
from . import cli_runner_invoke, move_to_test_folder
|
||||
from . import (
|
||||
build_ctx_from_config_file,
|
||||
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",
|
||||
"--versions=14.0,15.0",
|
||||
]
|
||||
],
|
||||
)
|
||||
|
||||
docker_client = get_docker_client()
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ def test_cli_run():
|
|||
ensure_database(ctx, db_name, state="absent")
|
||||
|
||||
cli_runner_invoke(
|
||||
ctx,
|
||||
[
|
||||
"--log-level=DEBUG",
|
||||
"run",
|
||||
|
|
@ -28,7 +29,7 @@ def test_cli_run():
|
|||
"--database=%s" % db_name,
|
||||
"--init-modules=base",
|
||||
"--stop-after-init",
|
||||
]
|
||||
],
|
||||
)
|
||||
|
||||
# Ensure that a subfolder filestore/DB_NAME has been created
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ def test_cli_execute_script_python():
|
|||
|
||||
# Install Odoo on V14 with base installed
|
||||
cli_runner_invoke(
|
||||
ctx,
|
||||
[
|
||||
"--log-level=DEBUG",
|
||||
"run",
|
||||
|
|
@ -38,7 +39,7 @@ def test_cli_execute_script_python():
|
|||
"--database=%s" % db_name,
|
||||
"--init-modules=base",
|
||||
"--stop-after-init",
|
||||
]
|
||||
],
|
||||
)
|
||||
|
||||
# Compute partners quantity
|
||||
|
|
@ -49,13 +50,14 @@ def test_cli_execute_script_python():
|
|||
|
||||
# Execute Custom Python Script
|
||||
cli_runner_invoke(
|
||||
ctx,
|
||||
[
|
||||
"--log-level=DEBUG",
|
||||
"execute-script-python",
|
||||
"--step=1",
|
||||
"--database=%s" % db_name,
|
||||
"--script-file-path=post-migration-custom_test.py",
|
||||
]
|
||||
],
|
||||
)
|
||||
partner_quantity_after = int(
|
||||
execute_sql_request(ctx, request, database=db_name)[0][0]
|
||||
|
|
|
|||
|
|
@ -33,12 +33,13 @@ 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(
|
||||
ctx,
|
||||
[
|
||||
"--log-level=DEBUG",
|
||||
"execute-script-sql",
|
||||
"--step=1",
|
||||
"--database=%s" % db_name,
|
||||
]
|
||||
],
|
||||
)
|
||||
|
||||
# Ensure that the request has been done correctly
|
||||
|
|
|
|||
|
|
@ -12,13 +12,14 @@ from . import (
|
|||
|
||||
def test_cli_upgrade():
|
||||
move_to_test_folder()
|
||||
ctx = build_ctx_from_config_file()
|
||||
|
||||
# Initialize database
|
||||
db_name = "database_test_cli___upgrade"
|
||||
ctx = build_ctx_from_config_file()
|
||||
ensure_database(ctx, db_name, state="absent")
|
||||
|
||||
cli_runner_invoke(
|
||||
ctx,
|
||||
[
|
||||
"--log-level=DEBUG",
|
||||
"run",
|
||||
|
|
@ -26,7 +27,7 @@ def test_cli_upgrade():
|
|||
"--database=%s" % db_name,
|
||||
"--init-modules=base",
|
||||
"--stop-after-init",
|
||||
]
|
||||
],
|
||||
)
|
||||
|
||||
# Ensure that 'base' module is installed at 14.0
|
||||
|
|
@ -41,13 +42,14 @@ def test_cli_upgrade():
|
|||
assert latest_version[0][0].startswith("14.")
|
||||
|
||||
cli_runner_invoke(
|
||||
ctx,
|
||||
[
|
||||
"--log-level=DEBUG",
|
||||
"upgrade",
|
||||
"--database=%s" % db_name,
|
||||
"--first-step=1",
|
||||
"--last-step=3",
|
||||
]
|
||||
],
|
||||
)
|
||||
|
||||
# Ensure that 'base' module is installed at 15.0
|
||||
|
|
|
|||
|
|
@ -1,14 +1,20 @@
|
|||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from . import cli_runner_invoke, move_to_test_folder
|
||||
from . import (
|
||||
build_ctx_from_config_file,
|
||||
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",
|
||||
|
|
@ -32,7 +38,7 @@ class TestCliEstimateWorkload(unittest.TestCase):
|
|||
",web_widget_one2many_tree_line_duplicate"
|
||||
",web_widget_dropdown_dynamic_example"
|
||||
",my_module_that_doesnt_exist",
|
||||
]
|
||||
],
|
||||
)
|
||||
|
||||
# We check file has been created
|
||||
|
|
|
|||
|
|
@ -19,11 +19,12 @@ def test_cli_install_from_csv():
|
|||
ensure_database(ctx, db_name, state="absent")
|
||||
|
||||
cli_runner_invoke(
|
||||
ctx,
|
||||
[
|
||||
"--log-level=DEBUG",
|
||||
"install-from-csv",
|
||||
"--database=%s" % db_name,
|
||||
]
|
||||
],
|
||||
)
|
||||
|
||||
# Ensure that 'base' is installed
|
||||
|
|
|
|||
|
|
@ -28,13 +28,14 @@ def test_cli_generate_module_analysis():
|
|||
|
||||
analysis_file_path
|
||||
cli_runner_invoke(
|
||||
ctx,
|
||||
[
|
||||
"--log-level=DEBUG",
|
||||
"generate-module-analysis",
|
||||
"--step=2",
|
||||
"--database=%s" % db_name,
|
||||
"--modules=base",
|
||||
]
|
||||
],
|
||||
)
|
||||
|
||||
# The file should has been recreated by the analysis command
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user