wip
This commit is contained in:
parent
1028d74db2
commit
c34f74f320
|
|
@ -1,5 +1,7 @@
|
|||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
from click.testing import CliRunner
|
||||
|
||||
from odoo_openupgrade_wizard.cli import main
|
||||
|
|
@ -21,3 +23,24 @@ def cli_runner_invoke(cmd):
|
|||
_logger.error("exit_code: %s" % result.exit_code)
|
||||
_logger.error("output: %s" % result.output)
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def build_ctx_from_config_file(env_folder_path) -> dict:
|
||||
class context:
|
||||
pass
|
||||
|
||||
ctx = context()
|
||||
setattr(ctx, "obj", {})
|
||||
config_file_path = env_folder_path / "config.yml"
|
||||
if not config_file_path.exists():
|
||||
raise Exception("Configuration file not found %s" % config_file_path)
|
||||
with open(config_file_path) as file:
|
||||
config = yaml.safe_load(file)
|
||||
ctx.obj["config"] = config
|
||||
file.close()
|
||||
|
||||
ctx.obj["env_folder_path"] = env_folder_path
|
||||
ctx.obj["postgres_folder_path"] = env_folder_path / Path(
|
||||
"./postgres_data/data"
|
||||
)
|
||||
return ctx
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@ from pathlib import Path
|
|||
from odoo_openupgrade_wizard.tools_docker import get_docker_client
|
||||
from odoo_openupgrade_wizard.tools_postgres import execute_sql_request
|
||||
|
||||
from . import cli_runner_invoke
|
||||
from . import build_ctx_from_config_file, cli_runner_invoke
|
||||
|
||||
|
||||
def test_cli_run():
|
||||
output_folder_path = Path("./tests/output_B").absolute()
|
||||
|
||||
ctx = build_ctx_from_config_file(output_folder_path)
|
||||
db_name = "database_test_cli_run"
|
||||
cli_runner_invoke(
|
||||
[
|
||||
|
|
@ -35,7 +35,7 @@ def test_cli_run():
|
|||
" WHERE state ='installed'"
|
||||
" AND name='base';"
|
||||
)
|
||||
assert execute_sql_request(request, database=db_name)
|
||||
assert execute_sql_request(ctx, request, database=db_name)
|
||||
|
||||
# Ensure that 'point_of_sale' module is not installed
|
||||
request = (
|
||||
|
|
@ -44,7 +44,7 @@ def test_cli_run():
|
|||
" WHERE state ='installed'"
|
||||
" AND name='point_of_sale';"
|
||||
)
|
||||
assert not execute_sql_request(request, database=db_name)
|
||||
assert not execute_sql_request(ctx, request, database=db_name)
|
||||
|
||||
# Ensure that all the containers are removed
|
||||
docker_client = get_docker_client()
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from odoo_openupgrade_wizard.tools_postgres import (
|
|||
execute_sql_request,
|
||||
)
|
||||
|
||||
from . import cli_runner_invoke
|
||||
from . import build_ctx_from_config_file, cli_runner_invoke
|
||||
|
||||
|
||||
def test_cli_upgrade():
|
||||
|
|
@ -13,7 +13,8 @@ def test_cli_upgrade():
|
|||
|
||||
db_name = "database_test_cli_upgrade"
|
||||
|
||||
ensure_database(db_name, state="absent")
|
||||
ctx = build_ctx_from_config_file(output_folder_path)
|
||||
ensure_database(ctx, db_name, state="absent")
|
||||
|
||||
cli_runner_invoke(
|
||||
[
|
||||
|
|
@ -34,7 +35,7 @@ def test_cli_upgrade():
|
|||
" WHERE state ='installed'"
|
||||
" AND name='base';"
|
||||
)
|
||||
latest_version = execute_sql_request(request, database=db_name)
|
||||
latest_version = execute_sql_request(ctx, request, database=db_name)
|
||||
|
||||
assert latest_version[0][0].startswith("13.")
|
||||
|
||||
|
|
@ -56,6 +57,6 @@ def test_cli_upgrade():
|
|||
" WHERE state ='installed'"
|
||||
" AND name='base';"
|
||||
)
|
||||
latest_version = execute_sql_request(request, database=db_name)
|
||||
latest_version = execute_sql_request(ctx, request, database=db_name)
|
||||
|
||||
assert latest_version[0][0].startswith("14.")
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user