[REF][WIP] remove xml_rpc connexion to make CI green, and replace by click_odoo script

This commit is contained in:
Sylvain LE GAL 2022-05-30 23:46:31 +02:00
parent c4ef08cf64
commit ecd03ba392
25 changed files with 331 additions and 201 deletions

3
.gitignore vendored
View File

@ -4,5 +4,6 @@ __pycache__
.tox
.coverage
.pytest_cache
/tests/output/*
/tests/data/output/*
log/
_auto_generated_odoo.cfg

View File

@ -49,11 +49,14 @@ pytest:
tests/cli_02_get_code_test.py
tests/cli_03_docker_build_test.py
tests/cli_04_run_test.py
tests/cli_05_execute_script_python_test.py
tests/cli_06_execute_script_sql_test.py
# Disabled : calling OdooRPC on mounted container
# in a container (gitlab) does'nt seems to work.
tests/cli_07_upgrade_test.py
# - poetry run pytest --verbose --verbose tests/cli_05_execute_script_python_test.py
# - poetry run pytest --verbose --verbose
# - poetry run pytest --verbose --verbose tests/cli_07_upgrade_test.py
# - poetry run pytest --verbose --verbose tests/cli_08_generate_module_analysis_test.py
# Disabled test on gitlab-ci :
# The following tests should work locally but doesn't on gitlab-ci
# because calling OdooRPC on mounted container
# in a container (gitlab) doesn't work.
# tests/cli_20_install_from_csv_test.py
# tests/cli_21_generate_module_analysis_test.py

View File

@ -7,9 +7,7 @@ from odoo_openupgrade_wizard.cli_options import (
get_migration_step_from_options,
step_option,
)
from odoo_openupgrade_wizard.tools_odoo import (
execute_python_files_post_migration,
)
from odoo_openupgrade_wizard.tools_odoo import execute_click_odoo_python_files
@click.command()
@ -21,7 +19,6 @@ from odoo_openupgrade_wizard.tools_odoo import (
type=click.Path(
exists=True,
dir_okay=False,
resolve_path=True,
),
help="List of python files that will be executed, replacing the default"
" scripts placed in the migration step folder.",
@ -30,6 +27,6 @@ from odoo_openupgrade_wizard.tools_odoo import (
def execute_script_python(ctx, step, database, script_file_path):
migration_step = get_migration_step_from_options(ctx, step)
execute_python_files_post_migration(
execute_click_odoo_python_files(
ctx, database, migration_step, [Path(x) for x in script_file_path]
)

View File

@ -21,7 +21,6 @@ from odoo_openupgrade_wizard.tools_postgres import (
type=click.Path(
exists=True,
dir_okay=False,
resolve_path=True,
),
help="List of SQL files that will be executed, replacing the default"
" scripts placed in the migration step folder.",

View File

@ -8,7 +8,7 @@ from odoo_openupgrade_wizard.cli_options import (
last_step_option,
)
from odoo_openupgrade_wizard.tools_odoo import (
execute_python_files_post_migration,
execute_click_odoo_python_files,
kill_odoo,
run_odoo,
)
@ -38,4 +38,4 @@ def upgrade(ctx, first_step, last_step, database):
logger.info("Received Keyboard Interrupt or System Exiting...")
finally:
kill_odoo(ctx, migration_step)
execute_python_files_post_migration(ctx, database, migration_step)
execute_click_odoo_python_files(ctx, database, migration_step)

View File

@ -120,7 +120,7 @@ def skip_addon_path(migration_step: dict, path: Path) -> bool:
) and migration_step["release"] < 14.0
def get_server_wide_modules_upgrade(migration_step: dict) -> str:
def get_server_wide_modules_upgrade(migration_step: dict) -> list:
"""return a list of modules to load, depending on the migration step."""
if (
migration_step["release"] >= 14.0

View File

@ -71,6 +71,7 @@ PYTHON_REQUIREMENTS_TXT_TEMPLATE = """
{{ python_librairy }}
{% endfor %}
odoorpc
click-odoo
"""
DEBIAN_REQUIREMENTS_TXT_TEMPLATE = """
@ -111,8 +112,13 @@ USER odoo
PRE_MIGRATION_SQL_TEMPLATE = ""
POST_MIGRATION_PY_TEMPLATE = """
def main(self):
pass
import logging
_logger = logging.getLogger(__name__)
_logger.info("Executing post-migration.py script ...")
env = env # noqa: F821
"""
GIT_IGNORE_CONTENT = """
@ -123,6 +129,5 @@ GIT_IGNORE_CONTENT = """
MODULES_CSV_TEMPLATE = """
base,Base
account,Account Module
product,Product
web_responsive,Web Responsive Module
"""

View File

@ -1,4 +1,4 @@
import importlib.util
import configparser
import os
import sys
import traceback
@ -15,7 +15,6 @@ from odoo_openupgrade_wizard.configuration_version_dependant import (
skip_addon_path,
)
from odoo_openupgrade_wizard.tools_docker import kill_container, run_container
from odoo_openupgrade_wizard.tools_odoo_instance import OdooInstance
from odoo_openupgrade_wizard.tools_postgres import get_postgres_container
from odoo_openupgrade_wizard.tools_system import get_script_folder
@ -76,13 +75,6 @@ def get_odoo_version_from_migration_step(ctx, migration_step: dict) -> dict:
raise Exception
def get_server_wide_modules(ctx, migration_step: dict) -> str:
# TODO, read from odoo.cfg file, the key server_wide_modules
modules = []
modules += get_server_wide_modules_upgrade(migration_step)
return modules
def generate_odoo_command(
ctx,
migration_step: dict,
@ -93,22 +85,12 @@ def generate_odoo_command(
shell: bool,
demo: bool,
) -> str:
addons_path = get_odoo_addons_path(ctx, Path("/odoo_env"), migration_step)
server_wide_modules = get_server_wide_modules(ctx, migration_step)
server_wide_modules_cmd = (
server_wide_modules
and "--load %s" % ",".join(server_wide_modules)
or ""
)
database_cmd = database and "--database %s" % database or ""
update_cmd = update and "--update %s" % update or ""
init_cmd = init and "--init %s" % init or ""
stop_after_init_cmd = stop_after_init and "--stop-after-init" or ""
shell_cmd = shell and "shell" or ""
demo_cmd = not demo and "--without-demo all" or ""
log_file = "/env/log/{}____{}.log".format(
ctx.obj["log_prefix"], migration_step["complete_name"]
)
command = (
Path("/odoo_env")
/ Path(get_odoo_folder(migration_step))
@ -117,16 +99,7 @@ def generate_odoo_command(
result = (
f" {command}"
f" {shell_cmd}"
f" --db_host db"
f" --db_port 5432"
f" --db_user odoo"
f" --db_password odoo"
f" --workers 0"
f" --config /odoo_env/odoo.cfg"
f" --data-dir /env/filestore/"
f" --logfile {log_file}"
f" --addons-path {addons_path}"
f" {server_wide_modules_cmd}"
f" --config /odoo_env/_auto_generated_odoo.cfg"
f" {demo_cmd}"
f" {database_cmd}"
f" {update_cmd}"
@ -136,6 +109,52 @@ def generate_odoo_command(
return result
def generate_odoo_config_file(ctx, migration_step, log_file):
"""Create a config file name _auto_generated_odoo.cfg
in the according environment (defined by migration_step)
This configuration file is a merge of the odoo.cfg file that can
contain custom values, and the values required to run the docker container.
"""
odoo_version = get_odoo_version_from_migration_step(ctx, migration_step)
odoo_env_path = get_odoo_env_path(ctx, odoo_version)
custom_odoo_config_file = odoo_env_path / "odoo.cfg"
auto_generated_odoo_config_file = (
odoo_env_path / "_auto_generated_odoo.cfg"
)
parser = configparser.RawConfigParser()
# Read custom file
parser.read(custom_odoo_config_file)
# compute addons_path
addons_path = get_odoo_addons_path(ctx, Path("/odoo_env"), migration_step)
# compute server wides modules
server_wide_modules = parser.get(
"options", "server_wide_modules", fallback=[]
)
server_wide_modules += get_server_wide_modules_upgrade(migration_step)
# Add required keys
if "options" not in parser:
parser.add_section("options")
parser.set("options", "db_host", "db")
parser.set("options", "db_port", 5432)
parser.set("options", "db_user", "odoo")
parser.set("options", "db_password", "odoo")
parser.set("options", "workers", 0)
parser.set("options", "data_dir", "/env/filestore/")
parser.set("options", "logfile", log_file)
parser.set("options", "addons_path", addons_path)
if server_wide_modules:
parser.set(
"options", "server_wide_modules", ",".join(server_wide_modules)
)
parser.write(open(auto_generated_odoo_config_file, "w"))
def run_odoo(
ctx,
migration_step: dict,
@ -169,6 +188,10 @@ def run_odoo(
odoo_version = get_odoo_version_from_migration_step(ctx, migration_step)
env_path = ctx.obj["env_folder_path"]
odoo_env_path = get_odoo_env_path(ctx, odoo_version)
log_file = "/env/log/{}____{}.log".format(
ctx.obj["log_prefix"], migration_step["complete_name"]
)
generate_odoo_config_file(ctx, migration_step, log_file)
command = generate_odoo_command(
ctx,
@ -208,48 +231,65 @@ def kill_odoo(ctx, migration_step: dict):
kill_container(get_docker_container_name(ctx, migration_step))
def execute_python_files_post_migration(
def execute_click_odoo_python_files(
ctx, database: str, migration_step: dict, python_files: list = []
):
if not python_files:
script_folder = get_script_folder(ctx, migration_step)
if not python_files:
# Get post-migration python scripts to execute
script_folder = get_script_folder(ctx, migration_step)
python_files = [
script_folder / Path(f)
Path("scripts") / Path(migration_step["complete_name"]) / Path(f)
for f in os.listdir(script_folder)
if os.path.isfile(os.path.join(script_folder, f))
and f[-3:] == ".py"
]
python_files = sorted(python_files)
try:
# Launch Odoo
run_odoo(
ctx,
migration_step,
detached_container=True,
database=database,
)
# Prepare data information for docker
odoo_version = get_odoo_version_from_migration_step(ctx, migration_step)
links = {ctx.obj["config"]["postgres_container_name"]: "db"}
env_path = ctx.obj["env_folder_path"]
odoo_env_path = get_odoo_env_path(ctx, odoo_version)
# Create Odoo instance via Odoo RPC
odoo_instance = OdooInstance(ctx, database)
# Generate odoo config file
log_file = "/env/log/{}____{}__post_migration.log".format(
ctx.obj["log_prefix"], migration_step["complete_name"]
)
generate_odoo_config_file(ctx, migration_step, log_file)
for python_file in python_files:
# Generate Python Script
logger.info("Running Script Post (Python) %s" % python_file)
package_name = "script.%s.%s" % (
migration_step["complete_name"],
python_file.name[:-3],
# TODO, check if we should set python2 for old version of Odoo
# or just 'python'
command = (
"click-odoo"
" --database {database}"
" --config /odoo_env/_auto_generated_odoo.cfg"
" /env/{python_file}"
).format(
database=database,
python_file=str(python_file),
)
module_spec = importlib.util.spec_from_file_location(
package_name, python_file
try:
logger.info(
"Executing script %s / %s"
% (migration_step["complete_name"], python_file)
)
run_container(
get_docker_image_tag(ctx, odoo_version),
get_docker_container_name(ctx, migration_step),
command=command,
ports={},
volumes={
env_path: "/env/",
odoo_env_path: "/odoo_env/",
},
links=links,
detach=False,
auto_remove=True,
)
module = importlib.util.module_from_spec(module_spec)
module_spec.loader.exec_module(module)
module.main(odoo_instance)
except Exception as e:
traceback.print_exc()
logger.error(
"An error occured. Exiting. %s\n%s"
% (e, traceback.print_exception(*sys.exc_info()))

View File

@ -80,7 +80,7 @@ def git_aggregate(folder_path: Path, config_path: Path):
do_push=False,
expand_env=False,
env_file=None,
force=False,
force=True,
)
with working_directory_keeper:
os.chdir(folder_path)

View File

@ -1,2 +1,2 @@
[pytest]
norecursedirs = tests/output/*
norecursedirs=tests/data/*

View File

@ -1,8 +1,10 @@
import logging
import os
from pathlib import Path
import yaml
from click.testing import CliRunner
from plumbum.cmd import mkdir
from odoo_openupgrade_wizard.cli import main
@ -13,6 +15,19 @@ def assert_result_cli_invoke(result):
pass
def move_to_test_folder():
"""function to call at the beginning at the tests
to change the current working directory.
Note : this function is idempotens, to avoid to generate errors
if many tests scripts are executed.
"""
if os.getcwd().endswith("tests/data/output"):
return
test_folder_path = Path("tests/data/output")
mkdir([test_folder_path, "--parents"])
os.chdir(test_folder_path)
def cli_runner_invoke(cmd):
result = CliRunner().invoke(
main,
@ -25,7 +40,9 @@ def cli_runner_invoke(cmd):
assert result.exit_code == 0
def build_ctx_from_config_file(env_folder_path) -> dict:
def build_ctx_from_config_file() -> dict:
env_folder_path = Path(".")
class context:
pass

View File

@ -1,20 +1,16 @@
import filecmp
from pathlib import Path
from plumbum.cmd import mkdir
from . import cli_runner_invoke
from . import cli_runner_invoke, move_to_test_folder
def test_cli_init():
output_folder_path = Path("./tests/output").absolute()
expected_folder_path = Path("./tests/output_expected").absolute()
mkdir([output_folder_path, "--parents"])
move_to_test_folder()
expected_folder_path = Path("../output_expected").absolute()
cli_runner_invoke(
[
"--log-level=DEBUG",
"--env-folder=%s" % output_folder_path,
"init",
"--project-name=test-cli",
"--initial-release=13.0",
@ -24,6 +20,6 @@ def test_cli_init():
)
assert filecmp.cmp(
output_folder_path / Path("config.yml"),
Path("config.yml"),
expected_folder_path / Path("config.yml"),
)

View File

@ -1,31 +1,25 @@
from pathlib import Path
from . import cli_runner_invoke
from . import cli_runner_invoke, move_to_test_folder
def test_cli_get_code():
output_folder_path = Path("./tests/output").absolute()
move_to_test_folder()
cli_runner_invoke(
[
"--log-level=DEBUG",
"--env-folder=%s" % output_folder_path,
"get-code",
]
)
# Check V13
openupgrade_path = output_folder_path / Path(
"./src/env_13.0/src/openupgrade"
)
openupgrade_path = Path("./src/env_13.0/src/openupgrade")
assert openupgrade_path.exists()
assert (openupgrade_path / Path("odoo")).exists()
# check V14
openupgrade_path = output_folder_path / Path(
"./src/env_14.0/src/openupgrade"
)
openupgrade_path = Path("./src/env_14.0/src/openupgrade")
assert openupgrade_path.exists()

View File

@ -1,17 +1,13 @@
from pathlib import Path
from odoo_openupgrade_wizard.tools_docker import get_docker_client
from . import cli_runner_invoke
from . import cli_runner_invoke, move_to_test_folder
def test_cli_docker_build():
output_folder_path = Path("./tests/output").absolute()
move_to_test_folder()
cli_runner_invoke(
[
"--log-level=DEBUG",
"--env-folder=%s" % output_folder_path,
"docker-build",
"--releases=13.0,14.0",
]

View File

@ -3,17 +3,19 @@ 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 build_ctx_from_config_file, cli_runner_invoke
from . import (
build_ctx_from_config_file,
cli_runner_invoke,
move_to_test_folder,
)
def test_cli_run():
output_folder_path = Path("./tests/output").absolute()
ctx = build_ctx_from_config_file(output_folder_path)
db_name = "database_test_cli_run"
move_to_test_folder()
db_name = "database_test_cli___run"
cli_runner_invoke(
[
"--log-level=DEBUG",
"--env-folder=%s" % output_folder_path,
"run",
"--step=1",
"--database=%s" % db_name,
@ -23,12 +25,11 @@ def test_cli_run():
)
# Ensure that a subfolder filestore/DB_NAME has been created
db_filestore_path = output_folder_path / Path(
"./filestore/filestore/%s" % db_name
)
db_filestore_path = Path("./filestore/filestore/%s" % db_name)
assert db_filestore_path.exists()
# Ensure that 'base' module is installed
ctx = build_ctx_from_config_file()
request = (
"SELECT id"
" FROM ir_module_module"

View File

@ -1,38 +1,58 @@
from pathlib import Path
from . import cli_runner_invoke
from plumbum.cmd import cp
from odoo_openupgrade_wizard.tools_postgres import execute_sql_request
from . import (
build_ctx_from_config_file,
cli_runner_invoke,
move_to_test_folder,
)
def test_cli_execute_script_python():
output_folder_path = Path("./tests/output").absolute()
move_to_test_folder()
extra_script_path = Path("../extra_script/click_odoo_test.py").absolute()
cp(
extra_script_path,
Path("click_odoo_test.py"),
)
extra_script_path = Path(
"./tests/extra_script/post-migration-custom_test.py"
).absolute()
db_name = "database_test_cli___execute_script_python"
db_name = "database_test_cli_execute_script_python"
# Install Odoo on V13 with product installed
# Install Odoo on V13 with base installed
cli_runner_invoke(
[
"--log-level=DEBUG",
"--env-folder=%s" % output_folder_path,
"run",
"--step=1",
"--database=%s" % db_name,
"--init-modules=product",
"--init-modules=base",
"--stop-after-init",
]
)
# Compute partners quantity
ctx = build_ctx_from_config_file()
request = "SELECT count(*)" " FROM res_partner;"
partner_quantity_before = int(
execute_sql_request(ctx, request, database=db_name)[0][0]
)
# Execute Custom Python Script
cli_runner_invoke(
[
"--log-level=DEBUG",
"--env-folder=%s" % output_folder_path,
"execute-script-python",
"--step=1",
"--database=%s" % db_name,
"--script-file-path=%s" % extra_script_path,
"--script-file-path=click_odoo_test.py",
]
)
# TODO, add manually script
partner_quantity_after = int(
execute_sql_request(ctx, request, database=db_name)[0][0]
)
# Ensure that partners have been created by click_odoo_test.py
assert partner_quantity_after == (partner_quantity_before + 10)

View File

@ -1,32 +1,40 @@
import shutil
from pathlib import Path
from plumbum.cmd import cp
from odoo_openupgrade_wizard.tools_postgres import (
ensure_database,
execute_sql_request,
)
from . import build_ctx_from_config_file, cli_runner_invoke
from . import (
build_ctx_from_config_file,
cli_runner_invoke,
move_to_test_folder,
)
def test_cli_execute_script_sql():
output_folder_path = Path("./tests/output").absolute()
move_to_test_folder()
extra_script_path = Path(
"./tests/extra_script/pre-migration-custom_test.sql"
"../extra_script/pre-migration-custom_test.sql"
).absolute()
destination_path = output_folder_path / "scripts/step_01__update__13.0"
shutil.copy(extra_script_path, destination_path)
ctx = build_ctx_from_config_file(output_folder_path)
db_name = "database_test_cli_execute_script_sql"
# Deploy SQL Script
destination_path = Path("scripts/step_01__update__13.0")
cp([extra_script_path, destination_path])
ctx = build_ctx_from_config_file()
# Reset database
db_name = "database_test_cli___execute_script_sql"
ensure_database(ctx, db_name, state="absent")
ensure_database(ctx, db_name, state="present")
# TODO call with script-file-path
# to avoid to copy file in scripts/step_xxx folder
cli_runner_invoke(
[
"--log-level=DEBUG",
"--env-folder=%s" % output_folder_path,
"execute-script-sql",
"--step=1",
"--database=%s" % db_name,

View File

@ -1,25 +1,26 @@
from pathlib import Path
from odoo_openupgrade_wizard.tools_postgres import (
ensure_database,
execute_sql_request,
)
from . import build_ctx_from_config_file, cli_runner_invoke
from . import (
build_ctx_from_config_file,
cli_runner_invoke,
move_to_test_folder,
)
def test_cli_upgrade():
output_folder_path = Path("./tests/output").absolute()
move_to_test_folder()
db_name = "database_test_cli_upgrade"
ctx = build_ctx_from_config_file(output_folder_path)
# Initialize database
db_name = "database_test_cli___upgrade"
ctx = build_ctx_from_config_file()
ensure_database(ctx, db_name, state="absent")
cli_runner_invoke(
[
"--log-level=DEBUG",
"--env-folder=%s" % output_folder_path,
"run",
"--step=1",
"--database=%s" % db_name,
@ -42,7 +43,6 @@ def test_cli_upgrade():
cli_runner_invoke(
[
"--log-level=DEBUG",
"--env-folder=%s" % output_folder_path,
"upgrade",
"--database=%s" % db_name,
"--first-step=1",

View File

@ -0,0 +1,39 @@
from odoo_openupgrade_wizard.tools_postgres import (
ensure_database,
execute_sql_request,
)
from . import (
build_ctx_from_config_file,
cli_runner_invoke,
move_to_test_folder,
)
def test_cli_install_from_csv():
move_to_test_folder()
# Initialize database
db_name = "database_test_cli___install_from_csv"
ctx = build_ctx_from_config_file()
ensure_database(ctx, db_name, state="absent")
cli_runner_invoke(
[
"--log-level=DEBUG",
"install-from-csv",
"--database=%s" % db_name,
]
)
# Ensure that 'account' is installed
# and also 'product', by dependencies
request = (
"SELECT count(*)"
" FROM ir_module_module"
" WHERE state ='installed'"
" AND name in ('product', 'account');"
)
module_qty = int(execute_sql_request(ctx, request, database=db_name)[0][0])
assert module_qty == 2

View File

@ -2,16 +2,18 @@ from pathlib import Path
from odoo_openupgrade_wizard.tools_odoo import get_odoo_env_path
from . import build_ctx_from_config_file, cli_runner_invoke
from . import (
build_ctx_from_config_file,
cli_runner_invoke,
move_to_test_folder,
)
def test_cli_generate_module_analysis():
# TODO, fixme, this test is not working for the time being
return
output_folder_path = Path("./tests/output").absolute()
db_name = "database_test_cli_cli_generate_module_analysis"
move_to_test_folder()
db_name = "database_test_cli___generate_module_analysis"
ctx = build_ctx_from_config_file(output_folder_path)
ctx = build_ctx_from_config_file()
# identify main analysis file of openupgrade
analysis_file_path = get_odoo_env_path(ctx, {"release": 14.0}) / Path(
"src/openupgrade/openupgrade_scripts/scripts"
@ -28,7 +30,6 @@ def test_cli_generate_module_analysis():
cli_runner_invoke(
[
"--log-level=DEBUG",
"--env-folder=%s" % output_folder_path,
"generate-module-analysis",
"--step=2",
"--database=%s" % db_name,

View File

@ -0,0 +1,11 @@
import logging
_logger = logging.getLogger(__name__)
_logger.info("click_odoo_test.py : Begin of script ...")
env = env # noqa: F821
for i in range(0, 10):
env["res.partner"].create({"name": "Partner #%d" % (i)})
_logger.info("click_odoo_test.py : End of script.")

View File

@ -0,0 +1,46 @@
# Unused for the time being
# def _check_orm_usage(self):
# # Classic ORM usage Checks
# partners = self.browse_by_search("res.partner")
# self.browse_by_create("res.partner", {"name": "New Partner"})
# new_partners = self.browse_by_search("res.partner")
# if len(partners) + 1 != len(new_partners):
# raise Exception("Creation of partner failed.")
# def _check_modules(self):
# if self.check_modules_installed("sale"):
# self.uninstall_modules("sale")
# self.install_modules("sale")
# if not self.check_modules_installed("sale"):
# raise Exception("'sale' module should be installed")
# self.uninstall_modules(["product"])
# if self.check_modules_installed("sale"):
# raise Exception(
# "'sale' module should not be installed"
# " after uninstallation of product"
# )
# def _check_models(self):
# if not self.check_models_present("res.partner"):
# raise Exception("'res.partner' model should be present.")
# if self.check_models_present("res.partner.unexisting.model"):
# raise Exception(
# "'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,44 +0,0 @@
def _check_orm_usage(self):
# Classic ORM usage Checks
partners = self.browse_by_search("res.partner")
self.browse_by_create("res.partner", {"name": "New Partner"})
new_partners = self.browse_by_search("res.partner")
if len(partners) + 1 != len(new_partners):
raise Exception("Creation of partner failed.")
def _check_modules(self):
if self.check_modules_installed("sale"):
self.uninstall_modules("sale")
self.install_modules("sale")
if not self.check_modules_installed("sale"):
raise Exception("'sale' module should be installed")
self.uninstall_modules(["product"])
if self.check_modules_installed("sale"):
raise Exception(
"'sale' module should not be installed"
" after uninstallation of product"
)
def _check_models(self):
if not self.check_models_present("res.partner"):
raise Exception("'res.partner' model should be present.")
if self.check_models_present("res.partner.unexisting.model"):
raise Exception(
"'res.partner.unexisting.model' model" " should not be present."
)
def main(self):
_check_orm_usage(self)
_check_modules(self)
_check_models(self)