[IMP] coverage of estimate-workload
This commit is contained in:
parent
c1b5efa13f
commit
0da6590d6f
|
|
@ -4,6 +4,7 @@ from pathlib import Path
|
||||||
import click
|
import click
|
||||||
|
|
||||||
from odoo_openupgrade_wizard import templates
|
from odoo_openupgrade_wizard import templates
|
||||||
|
from odoo_openupgrade_wizard.tools_odoo import get_odoo_modules_from_csv
|
||||||
from odoo_openupgrade_wizard.tools_odoo_module import Analysis
|
from odoo_openupgrade_wizard.tools_odoo_module import Analysis
|
||||||
from odoo_openupgrade_wizard.tools_system import (
|
from odoo_openupgrade_wizard.tools_system import (
|
||||||
ensure_file_exists_from_template,
|
ensure_file_exists_from_template,
|
||||||
|
|
@ -18,11 +19,25 @@ from odoo_openupgrade_wizard.tools_system import (
|
||||||
),
|
),
|
||||||
default="./analysis.html",
|
default="./analysis.html",
|
||||||
)
|
)
|
||||||
|
@click.option(
|
||||||
|
"--extra-modules",
|
||||||
|
"extra_modules_list",
|
||||||
|
# TODO, add a callback to check the quality of the argument
|
||||||
|
help="Coma separated modules to analyse. If not set, the modules.csv"
|
||||||
|
" file will be used to define the list of module to analyse."
|
||||||
|
"Ex: 'account,product,base'",
|
||||||
|
)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def estimate_workload(ctx, analysis_file_path):
|
def estimate_workload(ctx, analysis_file_path, extra_modules_list):
|
||||||
# Analyse
|
# Analyse
|
||||||
analysis = Analysis(ctx)
|
analysis = Analysis(ctx)
|
||||||
analysis.analyse_module_version(ctx)
|
|
||||||
|
if extra_modules_list:
|
||||||
|
module_list = extra_modules_list.split(",")
|
||||||
|
else:
|
||||||
|
module_list = get_odoo_modules_from_csv(ctx.obj["module_file_path"])
|
||||||
|
|
||||||
|
analysis.analyse_module_version(ctx, module_list)
|
||||||
analysis.analyse_missing_module()
|
analysis.analyse_missing_module()
|
||||||
analysis.analyse_openupgrade_state(ctx)
|
analysis.analyse_openupgrade_state(ctx)
|
||||||
analysis.estimate_workload(ctx)
|
analysis.estimate_workload(ctx)
|
||||||
|
|
|
||||||
|
|
@ -133,8 +133,6 @@ MODULES_CSV_TEMPLATE = """
|
||||||
base,Base
|
base,Base
|
||||||
account,Account Module
|
account,Account Module
|
||||||
web_responsive,Web Responsive Module
|
web_responsive,Web Responsive Module
|
||||||
account_facturx,Account Factur X
|
|
||||||
account_bank_statement_import, Account Bank Statement Import
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
ANALYSIS_HTML_TEMPLATE = """
|
ANALYSIS_HTML_TEMPLATE = """
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ from odoo_openupgrade_wizard.configuration_version_dependant import (
|
||||||
from odoo_openupgrade_wizard.tools_odoo import (
|
from odoo_openupgrade_wizard.tools_odoo import (
|
||||||
get_odoo_addons_path,
|
get_odoo_addons_path,
|
||||||
get_odoo_env_path,
|
get_odoo_env_path,
|
||||||
get_odoo_modules_from_csv,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -27,8 +26,8 @@ class Analysis(object):
|
||||||
x["release"] for x in ctx.obj["config"]["odoo_versions"]
|
x["release"] for x in ctx.obj["config"]["odoo_versions"]
|
||||||
]
|
]
|
||||||
|
|
||||||
def analyse_module_version(self, ctx):
|
def analyse_module_version(self, ctx, module_list):
|
||||||
self._generate_module_version_first_release(ctx)
|
self._generate_module_version_first_release(ctx, module_list)
|
||||||
|
|
||||||
for count in range(len(self.all_releases) - 1):
|
for count in range(len(self.all_releases) - 1):
|
||||||
previous_release = self.all_releases[count]
|
previous_release = self.all_releases[count]
|
||||||
|
|
@ -95,15 +94,14 @@ class Analysis(object):
|
||||||
for module_version in odoo_module.module_versions.values():
|
for module_version in odoo_module.module_versions.values():
|
||||||
module_version.estimate_workload(ctx)
|
module_version.estimate_workload(ctx)
|
||||||
|
|
||||||
def _generate_module_version_first_release(self, ctx):
|
def _generate_module_version_first_release(self, ctx, module_list):
|
||||||
not_found_modules = []
|
not_found_modules = []
|
||||||
logger.info(
|
logger.info(
|
||||||
"Analyse version %s. (First Release)" % self.initial_release
|
"Analyse version %s. (First Release)" % self.initial_release
|
||||||
)
|
)
|
||||||
module_names = get_odoo_modules_from_csv(ctx.obj["module_file_path"])
|
|
||||||
|
|
||||||
# Instanciate a new odoo_module
|
# Instanciate a new odoo_module
|
||||||
for module_name in module_names:
|
for module_name in module_list:
|
||||||
|
|
||||||
addon_path = OdooModule.get_addon_path(
|
addon_path = OdooModule.get_addon_path(
|
||||||
ctx, module_name, self.initial_release
|
ctx, module_name, self.initial_release
|
||||||
|
|
@ -388,9 +386,6 @@ class OdooModule(object):
|
||||||
else:
|
else:
|
||||||
return self.name < other.name
|
return self.name < other.name
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return "%s - %s" % (self.unique_name, self.module_type)
|
|
||||||
|
|
||||||
|
|
||||||
class OdooModuleVersion(object):
|
class OdooModuleVersion(object):
|
||||||
|
|
||||||
|
|
@ -617,10 +612,3 @@ class OdooModuleVersion(object):
|
||||||
"To port from %s"
|
"To port from %s"
|
||||||
% self.get_last_existing_version().release
|
% self.get_last_existing_version().release
|
||||||
)
|
)
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return "%s - %s - %s" % (
|
|
||||||
self.odoo_module.name,
|
|
||||||
self.release,
|
|
||||||
self.addon_path,
|
|
||||||
)
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,50 @@
|
||||||
|
import unittest
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from . import cli_runner_invoke, move_to_test_folder
|
from . import cli_runner_invoke, move_to_test_folder
|
||||||
|
|
||||||
|
|
||||||
def test_cli_estimate_workload():
|
class TestCliEstimateWorkload(unittest.TestCase):
|
||||||
|
def test_cli_estimate_workload(self):
|
||||||
move_to_test_folder()
|
move_to_test_folder()
|
||||||
|
|
||||||
cli_runner_invoke(
|
cli_runner_invoke(
|
||||||
[
|
[
|
||||||
"--log-level=DEBUG",
|
"--log-level=DEBUG",
|
||||||
"estimate-workload",
|
"estimate-workload",
|
||||||
|
"--extra-modules="
|
||||||
|
# Done Module
|
||||||
|
"account"
|
||||||
|
# Deleted module (because merged)
|
||||||
|
",account_analytic_default"
|
||||||
|
# Deleted module (because renamed)
|
||||||
|
",account_facturx"
|
||||||
|
# Deleted module (because lost merge)
|
||||||
|
",base_gengo"
|
||||||
|
# Some modules that are not ported (for the time being)
|
||||||
|
",l10n_be_invoice_bba,l10n_ch_qriban,l10n_latam_base"
|
||||||
|
# OCA Portted Modules
|
||||||
|
",web_responsive"
|
||||||
|
# OCA Unported modules
|
||||||
|
",web_boolean_button"
|
||||||
|
",web_editor_background_color"
|
||||||
|
",web_pivot_computed_measure"
|
||||||
|
",web_view_calendar_list"
|
||||||
|
",web_widget_child_selector"
|
||||||
|
",web_widget_one2many_tree_line_duplicate"
|
||||||
|
",web_widget_dropdown_dynamic_example",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
# We check file has been created
|
||||||
|
# parsing this file is a mess, so we don't do it ;-)
|
||||||
|
assert Path("./analysis.html").exists()
|
||||||
|
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
cli_runner_invoke(
|
||||||
|
[
|
||||||
|
"--log-level=DEBUG",
|
||||||
|
"estimate-workload",
|
||||||
|
"--extra-modules=my_module_that_doesnt_exist",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
# TODO, write test
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user