diff --git a/openupgrade_scripts/scripts/base/16.0.1.3/tests/__init__.py b/openupgrade_scripts/scripts/base/16.0.1.3/tests/__init__.py index 8e84cc263319..aa4adee7d02e 100644 --- a/openupgrade_scripts/scripts/base/16.0.1.3/tests/__init__.py +++ b/openupgrade_scripts/scripts/base/16.0.1.3/tests/__init__.py @@ -1 +1,2 @@ from . import test_base_migration +from . import test_newly_installed_end_migration diff --git a/openupgrade_scripts/scripts/base/16.0.1.3/tests/data.py b/openupgrade_scripts/scripts/base/16.0.1.3/tests/data.py index 3a6320e3e6e6..74938e75f488 100644 --- a/openupgrade_scripts/scripts/base/16.0.1.3/tests/data.py +++ b/openupgrade_scripts/scripts/base/16.0.1.3/tests/data.py @@ -1,3 +1,30 @@ +import shutil +import os + +# create an end-migration script for a newly installed module +openupgrade_script_dir = os.path.join( + os.getenv("github.workspace"), + "openupgrade", + "openupgrade_scripts", +) +src_script = os.path.join( + openupgrade_script_dir, + "base", + "16.0.1.3", + "tests", + "end-migration_test.py", +) +dest_script_dir = os.path.join( + openupgrade_script_dir, + "spreadsheet", + "16.0.1.0", +) +dest_script = os.path.join( + dest_script_dir, + "end-migration.py", +) +os.mkdir(dest_script_dir) +shutil.copy(src_script, dest_script) env = locals().get("env") # set company_registry in v15 to be sure we migrate it correctly to v16 env.ref("base.main_company").company_registry = "424242" diff --git a/openupgrade_scripts/scripts/base/16.0.1.3/tests/end-migration_test.py b/openupgrade_scripts/scripts/base/16.0.1.3/tests/end-migration_test.py new file mode 100644 index 000000000000..ef2debe1d9e2 --- /dev/null +++ b/openupgrade_scripts/scripts/base/16.0.1.3/tests/end-migration_test.py @@ -0,0 +1,15 @@ +# Copyright 2023 Odoo Community Association (OCA) +# Copyright 2023 Guillaume Masson +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +import logging + +from openupgradelib import openupgrade + +_logger = logging.getLogger(__name__) + + +@openupgrade.migrate(no_version=True) +def migrate(env, version): + params = env["ir.config_parameter"].sudo() + params.set_param("openupgrade.test_end_migration", "Executed") + diff --git a/openupgrade_scripts/scripts/base/16.0.1.3/tests/test_newly_installed_end_migration.py b/openupgrade_scripts/scripts/base/16.0.1.3/tests/test_newly_installed_end_migration.py new file mode 100644 index 000000000000..d3214953c27e --- /dev/null +++ b/openupgrade_scripts/scripts/base/16.0.1.3/tests/test_newly_installed_end_migration.py @@ -0,0 +1,10 @@ +from odoo.tests import TransactionCase, tagged + + +@tagged('-at_install', 'post_install') +class TestNewlyInstalledEndMigration(TransactionCase): + def test_newly_installed_end_migration(self): + """Make sure the code of the end-migration script has been executed""" + params = self.env["ir.config_parameter"].sudo() + res = params.get_param("openupgrade.test_end_migration", default="Not executed") + self.assertEqual(res, "Executed")