Skip to content

Commit

Permalink
[IMP] add tests for end migration scripts for newly installed modules
Browse files Browse the repository at this point in the history
  • Loading branch information
metaminux committed Aug 29, 2023
1 parent 9f09f7b commit 16de61e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -p $NEW_MODULE_SCRIPT_DIR
cp $END_SCRIPT_TEST $NEW_MODULE_SCRIPT_DIR
- name: OpenUpgrade test
run: |
# select modules and perform the upgrade
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import test_base_migration
from . import test_newly_installed_end_migration
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2023 Odoo Community Association (OCA)
# Copyright 2023 Guillaume Masson <[email protected]>
# 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")
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit 16de61e

Please sign in to comment.