Skip to content

Commit

Permalink
Merge pull request OCA#4669 from hbrunn/17.0-tests
Browse files Browse the repository at this point in the history
[17.0][OU-ADD] enable tests, add decorator to make them convenient to use
  • Loading branch information
pedrobaeza authored Nov 18, 2024
2 parents 12e94d8 + ee79c51 commit c5732d6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/documentation-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ jobs:
unixodbc-dev
- name: Requirements Installation
run: |
sed -i -E "s/(gevent==)21\.8\.0( ; sys_platform != 'win32' and python_version == '3.10')/\122.10.2\2/;s/(greenlet==)1.1.2( ; sys_platform != 'win32' and python_version == '3.10')/\12.0.2\2/" odoo/requirements.txt
pip install -q -r odoo/requirements.txt
pip install -r ./requirements.txt
- name: OpenUpgrade Docs
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,15 @@ jobs:
unixodbc-dev
- name: Requirements Installation
run: |
sed -i -E "s/(gevent==)21\.8\.0( ; sys_platform != 'win32' and python_version == '3.10')/\122.10.2\2/;s/(greenlet==)1.1.2( ; sys_platform != 'win32' and python_version == '3.10')/\12.0.2\2/" odoo/requirements.txt
pip install -q -r odoo/requirements.txt
pip install -r ./openupgrade/requirements.txt
# this is for v16 l10n_eg_edi_eta which crashes without it
pip install asn1crypto
- name: Test data
run: |
if test -n "$(ls openupgrade/openupgrade_scripts/scripts/*/*/tests/data*.py 2> /dev/null)"; then
for snippet in openupgrade/openupgrade_scripts/scripts/*/*/tests/data*.py; do
if test -n "$(ls openupgrade/openupgrade_scripts/scripts/*/tests/data*.py 2> /dev/null)"; then
for snippet in openupgrade/openupgrade_scripts/scripts/*/tests/data*.py; do
odoo-old/odoo-bin shell -d $DB < $snippet
done
fi
Expand Down Expand Up @@ -131,14 +132,16 @@ jobs:
echo Execution of Openupgrade with the update of the following modules : $MODULES_NEW
# Silence redundant logs from unlinking records (1 line is enough)
# to prevent log overflow
OPENUPGRADE_TESTS=1 $ODOO \
$ODOO \
--addons-path=`echo $ADDONS_PATHS | awk -v OFS="," '$1=$1'` \
--database=$DB \
--db_host=$DB_HOST \
--db_password=$DB_PASSWORD \
--db_port=$DB_PORT \
--db_user=$DB_USERNAME \
--load=base,web,openupgrade_framework \
--test-enable \
--test-tags openupgrade \
--log-handler odoo.models.unlink:WARNING \
--stop-after-init \
--update=$MODULES_NEW
17 changes: 17 additions & 0 deletions openupgrade_framework/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,20 @@
"location of openupgrade_scripts"
)
config["upgrade_path"] = os.path.join(path, "scripts")


def openupgrade_test(cls):
"""
Set attributes on a test class necessary for the test framework
Use as decorator on test classes in openupgrade_scripts/scripts/*/tests/test_*.py
"""
tags = getattr(cls, "test_tags", None) or set()
if "openupgrade" not in tags:
tags.add("openupgrade")
if not any(t.endswith("_install") for t in tags):
tags.add("at_install")
cls.test_tags = tags
cls.test_module = cls.__module__.split(".")[2]
cls.test_class = cls.__name__
cls.test_sequence = 0
return cls

0 comments on commit c5732d6

Please sign in to comment.