odoo-openupgrade-wizard/tests/cli_21_generate_module_analysis_test.py
Rémy Taymans a0307847b9 Allow mocking the ODOO_RPC_URL for testing
Depending of the test environment, the url of the odoo container may
change.

Using pytest in a local shell, Odoo will be available at 0.0.0.0
address.

Using pytest in a docker-in-docker environment, the url for the Odoo
container will be exposed on a different address depending on the
configuration of the docker-in-docker environment.

The mock check whether the user has configured a différent URL for the
Odoo RPC calls, and set it accordingly using mock feature.

In the gitlab-ci, the ODOO_RPC_URL should be used to set the correct
address for the RPC calls.
2023-11-09 16:21:20 +01:00

45 lines
1.1 KiB
Python

from pathlib import Path
from odoo_openupgrade_wizard.tools.tools_odoo import get_odoo_env_path
from . import (
build_ctx_from_config_file,
cli_runner_invoke,
mock_odoo_rpc_url,
move_to_test_folder,
)
def test_cli_generate_module_analysis(mocker):
move_to_test_folder()
mock_odoo_rpc_url(mocker)
ctx = build_ctx_from_config_file()
db_name = "database_test_cli___generate_module_analysis"
# identify main analysis file of openupgrade
analysis_file_path = get_odoo_env_path(ctx, 15.0) / Path(
"src/openupgrade/openupgrade_scripts/scripts"
"/base/15.0.1.3/upgrade_general_log.txt"
)
# We remove this file and run the analysis
try:
analysis_file_path.unlink()
except FileNotFoundError:
pass
analysis_file_path
cli_runner_invoke(
[
"--log-level=DEBUG",
"generate-module-analysis",
"--step=2",
"--database=%s" % db_name,
"--modules=base",
],
)
# The file should has been recreated by the analysis command
assert analysis_file_path.exists()