Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][OU-ADD] enable tests, add decorator to make them convenient to use #4669

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is because tests must live in the base directory of the addon's path

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 \
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the env var was a leftover from the pre-openupgrade_framework test mechanism

--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
Loading