From 070a19ab31bf65b0f4fc73759c50e2e28e1c8a8f Mon Sep 17 00:00:00 2001 From: Guillaume MASSON Date: Fri, 25 Aug 2023 16:19:08 +0200 Subject: [PATCH] =?UTF-8?q?[IMP]=C2=A0add=20tests=20for=20end=20migration?= =?UTF-8?q?=20scripts=20for=20newly=20installed=20modules?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test.yml | 6 ++++++ .../scripts/base/16.0.1.3/tests/__init__.py | 1 + .../base/16.0.1.3/tests/end-migration_test.py | 14 ++++++++++++++ .../tests/test_newly_installed_end_migration.py | 10 ++++++++++ 4 files changed, 31 insertions(+) create mode 100644 openupgrade_scripts/scripts/base/16.0.1.3/tests/end-migration_test.py create mode 100644 openupgrade_scripts/scripts/base/16.0.1.3/tests/test_newly_installed_end_migration.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 287a1f17db11..96be7bf1d756 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -95,6 +95,12 @@ jobs: for snippet in openupgrade/openupgrade_scripts/scripts/*/*/tests/data*.py; do odoo-old/odoo-bin shell -d $DB < $snippet done + - name: Test end-migration script for newly installed module (i.e. "spreadsheet" for v16) + run: | + END_SCRIPT_TEST=openupgrade/openupgrade_scripts/scripts/base/16.0.1.3/tests/end-migration_test.py + NEW_MODULE_SCRIPT_DIR=openupgrade/openupgrade_scripts/scripts/spreadsheet/16.0.1.0/ + mkdir $NEW_MODULE_SCRIPT_DIR + cp $END_SCRIPT_TEST $NEW_MODULE_SCRIPT_DIR - name: OpenUpgrade test run: | # select modules and perform the upgrade 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/end-migration_test.py b/openupgrade_scripts/scripts/base/16.0.1.3/tests/end-migration_test.py new file mode 100644 index 000000000000..d28d5562205b --- /dev/null +++ b/openupgrade_scripts/scripts/base/16.0.1.3/tests/end-migration_test.py @@ -0,0 +1,14 @@ +# 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")