fixup! [FIX] correct name for custom script in execute_script tests
This commit is contained in:
parent
624387b89d
commit
cc45dfc488
|
|
@ -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
|
# 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'``
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,8 @@ def main(ctx, env_folder, filestore_folder, log_level):
|
||||||
elif ctx.invoked_subcommand != "init":
|
elif ctx.invoked_subcommand != "init":
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
logger.debug("context %s: " % ctx.obj)
|
||||||
|
|
||||||
|
|
||||||
main.add_command(init)
|
main.add_command(init)
|
||||||
main.add_command(get_code)
|
main.add_command(get_code)
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ def docker_build(ctx, releases):
|
||||||
"This can take a while..." % (odoo_version["release"])
|
"This can take a while..." % (odoo_version["release"])
|
||||||
)
|
)
|
||||||
image = build_image(
|
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),
|
get_docker_image_tag(ctx, odoo_version),
|
||||||
)
|
)
|
||||||
logger.info("Docker Image build. '%s'" % image[0].tags[0])
|
logger.info("Docker Image build. '%s'" % image[0].tags[0])
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,19 @@ def get_docker_client():
|
||||||
|
|
||||||
|
|
||||||
def build_image(path, tag):
|
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()
|
docker_client = get_docker_client()
|
||||||
return docker_client.images.build(
|
image = docker_client.images.build(
|
||||||
path=path,
|
path=str(path),
|
||||||
tag=tag,
|
tag=tag,
|
||||||
)
|
)
|
||||||
|
logger.debug("Image build.")
|
||||||
|
return image
|
||||||
|
|
||||||
|
|
||||||
def run_container(
|
def run_container(
|
||||||
|
|
@ -28,7 +34,7 @@ def run_container(
|
||||||
):
|
):
|
||||||
client = get_docker_client()
|
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)
|
debug_docker_command = "docker run --name %s\\\n" % (container_name)
|
||||||
if ports:
|
if ports:
|
||||||
for internal_port, host_port in ports.items():
|
for internal_port, host_port in ports.items():
|
||||||
|
|
@ -54,7 +60,7 @@ def run_container(
|
||||||
debug_docker_command += " --detach"
|
debug_docker_command += " --detach"
|
||||||
debug_docker_command += " %s\\\n" % (image_name)
|
debug_docker_command += " %s\\\n" % (image_name)
|
||||||
debug_docker_command += " %s" % (command)
|
debug_docker_command += " %s" % (command)
|
||||||
logger.debug(debug_docker_command)
|
logger.debug("DOCKER COMMAND:\n %s" % debug_docker_command)
|
||||||
|
|
||||||
container = client.containers.run(
|
container = client.containers.run(
|
||||||
image_name,
|
image_name,
|
||||||
|
|
@ -67,9 +73,9 @@ def run_container(
|
||||||
auto_remove=auto_remove,
|
auto_remove=auto_remove,
|
||||||
)
|
)
|
||||||
if detach:
|
if detach:
|
||||||
logger.info("Container launched.")
|
logger.debug("Container %s launched." % image_name)
|
||||||
elif auto_remove:
|
elif auto_remove:
|
||||||
logger.info("Container closed.")
|
logger.debug("Container closed.")
|
||||||
|
|
||||||
return container
|
return container
|
||||||
|
|
||||||
|
|
@ -81,7 +87,7 @@ def kill_container(container_name):
|
||||||
filters={"name": container_name},
|
filters={"name": container_name},
|
||||||
)
|
)
|
||||||
for container in containers:
|
for container in containers:
|
||||||
logger.info(
|
logger.debug(
|
||||||
"Stop container %s, based on image '%s'."
|
"Stop container %s, based on image '%s'."
|
||||||
% (container.name, ",".join(container.image.tags))
|
% (container.name, ",".join(container.image.tags))
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,13 @@ from . import cli_runner_invoke
|
||||||
|
|
||||||
|
|
||||||
def test_cli_init():
|
def test_cli_init():
|
||||||
output_folder_path = Path("./tests/output_A")
|
output_folder_path = Path("./tests/output_A").absolute()
|
||||||
expected_folder_path = Path("./tests/output_A_expected")
|
expected_folder_path = Path("./tests/output_A_expected").absolute()
|
||||||
mkdir([output_folder_path, "--parents"])
|
mkdir([output_folder_path, "--parents"])
|
||||||
|
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(
|
||||||
[
|
[
|
||||||
|
"--log-level=DEBUG",
|
||||||
"--env-folder=%s" % output_folder_path,
|
"--env-folder=%s" % output_folder_path,
|
||||||
"init",
|
"init",
|
||||||
"--project-name=test-cli",
|
"--project-name=test-cli",
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,14 @@ from . import cli_runner_invoke
|
||||||
|
|
||||||
|
|
||||||
def test_cli_get_code():
|
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"])
|
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
|
# large data
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(
|
||||||
[
|
[
|
||||||
|
"--log-level=DEBUG",
|
||||||
"--env-folder=%s" % output_folder_path,
|
"--env-folder=%s" % output_folder_path,
|
||||||
"init",
|
"init",
|
||||||
"--project-name=test-cli",
|
"--project-name=test-cli",
|
||||||
|
|
@ -24,6 +25,7 @@ def test_cli_get_code():
|
||||||
|
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(
|
||||||
[
|
[
|
||||||
|
"--log-level=DEBUG",
|
||||||
"--env-folder=%s" % output_folder_path,
|
"--env-folder=%s" % output_folder_path,
|
||||||
"get-code",
|
"get-code",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,11 @@ from . import cli_runner_invoke
|
||||||
|
|
||||||
|
|
||||||
def test_cli_docker_build():
|
def test_cli_docker_build():
|
||||||
output_folder_path = Path("./tests/output_B")
|
output_folder_path = Path("./tests/output_B").absolute()
|
||||||
|
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(
|
||||||
[
|
[
|
||||||
|
"--log-level=DEBUG",
|
||||||
"--env-folder=%s" % output_folder_path,
|
"--env-folder=%s" % output_folder_path,
|
||||||
"docker-build",
|
"docker-build",
|
||||||
"--releases=13.0,14.0",
|
"--releases=13.0,14.0",
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,12 @@ from . import cli_runner_invoke
|
||||||
|
|
||||||
|
|
||||||
def test_cli_run():
|
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"
|
db_name = "database_test_cli_run"
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(
|
||||||
[
|
[
|
||||||
|
"--log-level=DEBUG",
|
||||||
"--env-folder=%s" % output_folder_path,
|
"--env-folder=%s" % output_folder_path,
|
||||||
"run",
|
"run",
|
||||||
"--step=1",
|
"--step=1",
|
||||||
|
|
|
||||||
|
|
@ -4,17 +4,19 @@ from . import cli_runner_invoke
|
||||||
|
|
||||||
|
|
||||||
def test_cli_execute_script():
|
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(
|
extra_script_path = Path(
|
||||||
"./tests/extra_script_B/post-migration-custom_test.py"
|
"./tests/extra_script_B/post-migration-custom_test.py"
|
||||||
)
|
).absolute()
|
||||||
|
|
||||||
db_name = "database_test_cli_execute_script"
|
db_name = "database_test_cli_execute_script"
|
||||||
|
|
||||||
# Install Odoo on V13 with product installed
|
# Install Odoo on V13 with product installed
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(
|
||||||
[
|
[
|
||||||
|
"--log-level=DEBUG",
|
||||||
"--env-folder=%s" % output_folder_path,
|
"--env-folder=%s" % output_folder_path,
|
||||||
"run",
|
"run",
|
||||||
"--step=1",
|
"--step=1",
|
||||||
|
|
@ -26,6 +28,7 @@ def test_cli_execute_script():
|
||||||
|
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(
|
||||||
[
|
[
|
||||||
|
"--log-level=DEBUG",
|
||||||
"--env-folder=%s" % output_folder_path,
|
"--env-folder=%s" % output_folder_path,
|
||||||
"execute-script",
|
"execute-script",
|
||||||
"--step=1",
|
"--step=1",
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,13 @@ from . import cli_runner_invoke
|
||||||
|
|
||||||
|
|
||||||
def test_cli_upgrade():
|
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"
|
db_name = "database_test_cli_upgrade"
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(
|
||||||
[
|
[
|
||||||
|
"--log-level=DEBUG",
|
||||||
"--env-folder=%s" % output_folder_path,
|
"--env-folder=%s" % output_folder_path,
|
||||||
"run",
|
"run",
|
||||||
"--step=1",
|
"--step=1",
|
||||||
|
|
@ -20,6 +22,7 @@ def test_cli_upgrade():
|
||||||
|
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(
|
||||||
[
|
[
|
||||||
|
"--log-level=DEBUG",
|
||||||
"--env-folder=%s" % output_folder_path,
|
"--env-folder=%s" % output_folder_path,
|
||||||
"upgrade",
|
"upgrade",
|
||||||
"--database=%s" % db_name,
|
"--database=%s" % db_name,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
def main(self):
|
def _check_orm_usage(self):
|
||||||
|
|
||||||
# Classic ORM usage Checks
|
# Classic ORM usage Checks
|
||||||
partners = self.browse_by_search("res.partner")
|
partners = self.browse_by_search("res.partner")
|
||||||
|
|
||||||
|
|
@ -10,7 +9,8 @@ def main(self):
|
||||||
if len(partners) + 1 != len(new_partners):
|
if len(partners) + 1 != len(new_partners):
|
||||||
raise Exception("Creation of partner failed.")
|
raise Exception("Creation of partner failed.")
|
||||||
|
|
||||||
# Install / uninstall modules checks
|
|
||||||
|
def _check_modules(self):
|
||||||
if self.check_modules_installed("sale"):
|
if self.check_modules_installed("sale"):
|
||||||
self.uninstall_modules("sale")
|
self.uninstall_modules("sale")
|
||||||
|
|
||||||
|
|
@ -27,7 +27,8 @@ def main(self):
|
||||||
" after uninstallation of product"
|
" after uninstallation of product"
|
||||||
)
|
)
|
||||||
|
|
||||||
# models checks
|
|
||||||
|
def _check_models(self):
|
||||||
if not self.check_models_present("res.partner"):
|
if not self.check_models_present("res.partner"):
|
||||||
raise Exception("'res.partner' model should be present.")
|
raise Exception("'res.partner' model should be present.")
|
||||||
|
|
||||||
|
|
@ -36,4 +37,8 @@ def main(self):
|
||||||
"'res.partner.unexisting.model' model" " should not be present."
|
"'res.partner.unexisting.model' model" " should not be present."
|
||||||
)
|
)
|
||||||
|
|
||||||
#
|
|
||||||
|
def main(self):
|
||||||
|
_check_orm_usage(self)
|
||||||
|
_check_modules(self)
|
||||||
|
_check_models(self)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user