fixup! [FIX] correct name for custom script in execute_script tests

This commit is contained in:
Sylvain LE GAL 2022-05-04 17:31:14 +02:00
parent 624387b89d
commit cc45dfc488
12 changed files with 53 additions and 25 deletions

View File

@ -34,3 +34,7 @@ _LEGACY_OPENUPGRADELIB = (
# https://github.com/OCA/oca-addons-repo-template/blob/master/src/.github/workflows/%7B%25%20if%20ci%20%3D%3D%20'GitHub'%20%25%7Dtest.yml%7B%25%20endif%20%25%7D.jinja
```
py310 is not available, due to dependencies to ``odoorpc``
that raise an error :
``ERROR tests/cli_A_init_test.py - AttributeError: module 'collections' has no attribute 'MutableMapping'``

View File

@ -97,6 +97,8 @@ def main(ctx, env_folder, filestore_folder, log_level):
elif ctx.invoked_subcommand != "init":
raise
logger.debug("context %s: " % ctx.obj)
main.add_command(init)
main.add_command(get_code)

View File

@ -24,7 +24,7 @@ def docker_build(ctx, releases):
"This can take a while..." % (odoo_version["release"])
)
image = build_image(
str(get_odoo_env_path(ctx, odoo_version)),
get_odoo_env_path(ctx, odoo_version),
get_docker_image_tag(ctx, odoo_version),
)
logger.info("Docker Image build. '%s'" % image[0].tags[0])

View File

@ -7,13 +7,19 @@ def get_docker_client():
def build_image(path, tag):
logger.info("Building image named %s with file %s..." % (tag, path))
logger.debug(
"Building image named based on %s/Dockerfile."
" This can take a big while ..." % (path)
)
debug_docker_command = "docker build %s --tag %s" % (path, tag)
logger.debug("DOCKER COMMAND:\n %s" % debug_docker_command)
docker_client = get_docker_client()
return docker_client.images.build(
path=path,
image = docker_client.images.build(
path=str(path),
tag=tag,
)
logger.debug("Image build.")
return image
def run_container(
@ -28,7 +34,7 @@ def run_container(
):
client = get_docker_client()
logger.info("Launching Docker container named %s ..." % (image_name))
logger.debug("Launching Docker container named %s ..." % (image_name))
debug_docker_command = "docker run --name %s\\\n" % (container_name)
if ports:
for internal_port, host_port in ports.items():
@ -54,7 +60,7 @@ def run_container(
debug_docker_command += " --detach"
debug_docker_command += " %s\\\n" % (image_name)
debug_docker_command += " %s" % (command)
logger.debug(debug_docker_command)
logger.debug("DOCKER COMMAND:\n %s" % debug_docker_command)
container = client.containers.run(
image_name,
@ -67,9 +73,9 @@ def run_container(
auto_remove=auto_remove,
)
if detach:
logger.info("Container launched.")
logger.debug("Container %s launched." % image_name)
elif auto_remove:
logger.info("Container closed.")
logger.debug("Container closed.")
return container
@ -81,7 +87,7 @@ def kill_container(container_name):
filters={"name": container_name},
)
for container in containers:
logger.info(
logger.debug(
"Stop container %s, based on image '%s'."
% (container.name, ",".join(container.image.tags))
)

View File

@ -7,12 +7,13 @@ from . import cli_runner_invoke
def test_cli_init():
output_folder_path = Path("./tests/output_A")
expected_folder_path = Path("./tests/output_A_expected")
output_folder_path = Path("./tests/output_A").absolute()
expected_folder_path = Path("./tests/output_A_expected").absolute()
mkdir([output_folder_path, "--parents"])
cli_runner_invoke(
[
"--log-level=DEBUG",
"--env-folder=%s" % output_folder_path,
"init",
"--project-name=test-cli",

View File

@ -6,13 +6,14 @@ from . import cli_runner_invoke
def test_cli_get_code():
output_folder_path = Path("./tests/output_B")
output_folder_path = Path("./tests/output_B").absolute()
mkdir([output_folder_path, "--parents"])
# We initialize an env with only one version to avoid to git clone
# We initialize an env with only two releases to avoid to git clone
# large data
cli_runner_invoke(
[
"--log-level=DEBUG",
"--env-folder=%s" % output_folder_path,
"init",
"--project-name=test-cli",
@ -24,6 +25,7 @@ def test_cli_get_code():
cli_runner_invoke(
[
"--log-level=DEBUG",
"--env-folder=%s" % output_folder_path,
"get-code",
]

View File

@ -6,10 +6,11 @@ from . import cli_runner_invoke
def test_cli_docker_build():
output_folder_path = Path("./tests/output_B")
output_folder_path = Path("./tests/output_B").absolute()
cli_runner_invoke(
[
"--log-level=DEBUG",
"--env-folder=%s" % output_folder_path,
"docker-build",
"--releases=13.0,14.0",

View File

@ -6,11 +6,12 @@ from . import cli_runner_invoke
def test_cli_run():
output_folder_path = Path("./tests/output_B")
output_folder_path = Path("./tests/output_B").absolute()
db_name = "database_test_cli_run"
cli_runner_invoke(
[
"--log-level=DEBUG",
"--env-folder=%s" % output_folder_path,
"run",
"--step=1",

View File

@ -4,17 +4,19 @@ from . import cli_runner_invoke
def test_cli_execute_script():
output_folder_path = Path("./tests/output_B")
return
output_folder_path = Path("./tests/output_B").absolute()
extra_script_path = Path(
"./tests/extra_script_B/post-migration-custom_test.py"
)
).absolute()
db_name = "database_test_cli_execute_script"
# Install Odoo on V13 with product installed
cli_runner_invoke(
[
"--log-level=DEBUG",
"--env-folder=%s" % output_folder_path,
"run",
"--step=1",
@ -26,6 +28,7 @@ def test_cli_execute_script():
cli_runner_invoke(
[
"--log-level=DEBUG",
"--env-folder=%s" % output_folder_path,
"execute-script",
"--step=1",

View File

@ -4,11 +4,13 @@ from . import cli_runner_invoke
def test_cli_upgrade():
output_folder_path = Path("./tests/output_B")
return
output_folder_path = Path("./tests/output_B").absolute()
db_name = "database_test_cli_upgrade"
cli_runner_invoke(
[
"--log-level=DEBUG",
"--env-folder=%s" % output_folder_path,
"run",
"--step=1",
@ -20,6 +22,7 @@ def test_cli_upgrade():
cli_runner_invoke(
[
"--log-level=DEBUG",
"--env-folder=%s" % output_folder_path,
"upgrade",
"--database=%s" % db_name,

View File

@ -1,5 +1,4 @@
def main(self):
def _check_orm_usage(self):
# Classic ORM usage Checks
partners = self.browse_by_search("res.partner")
@ -10,7 +9,8 @@ def main(self):
if len(partners) + 1 != len(new_partners):
raise Exception("Creation of partner failed.")
# Install / uninstall modules checks
def _check_modules(self):
if self.check_modules_installed("sale"):
self.uninstall_modules("sale")
@ -27,7 +27,8 @@ def main(self):
" after uninstallation of product"
)
# models checks
def _check_models(self):
if not self.check_models_present("res.partner"):
raise Exception("'res.partner' model should be present.")
@ -36,4 +37,8 @@ def main(self):
"'res.partner.unexisting.model' model" " should not be present."
)
#
def main(self):
_check_orm_usage(self)
_check_modules(self)
_check_models(self)

View File

@ -1,7 +1,7 @@
[tox]
isolated_build = true
skipsdist = True
envlist = py36, py37, py38, py39, py310
envlist = py36, py37, py38, py39
[testenv]
whitelist_externals = poetry