Skip to content

Commit c5732d6

Browse files
authored
Merge pull request OCA#4669 from hbrunn/17.0-tests
[17.0][OU-ADD] enable tests, add decorator to make them convenient to use
2 parents 12e94d8 + ee79c51 commit c5732d6

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

.github/workflows/documentation-commit.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ jobs:
5252
unixodbc-dev
5353
- name: Requirements Installation
5454
run: |
55+
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
5556
pip install -q -r odoo/requirements.txt
5657
pip install -r ./requirements.txt
5758
- name: OpenUpgrade Docs

.github/workflows/test.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,15 @@ jobs:
8585
unixodbc-dev
8686
- name: Requirements Installation
8787
run: |
88+
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
8889
pip install -q -r odoo/requirements.txt
8990
pip install -r ./openupgrade/requirements.txt
9091
# this is for v16 l10n_eg_edi_eta which crashes without it
9192
pip install asn1crypto
9293
- name: Test data
9394
run: |
94-
if test -n "$(ls openupgrade/openupgrade_scripts/scripts/*/*/tests/data*.py 2> /dev/null)"; then
95-
for snippet in openupgrade/openupgrade_scripts/scripts/*/*/tests/data*.py; do
95+
if test -n "$(ls openupgrade/openupgrade_scripts/scripts/*/tests/data*.py 2> /dev/null)"; then
96+
for snippet in openupgrade/openupgrade_scripts/scripts/*/tests/data*.py; do
9697
odoo-old/odoo-bin shell -d $DB < $snippet
9798
done
9899
fi
@@ -131,14 +132,16 @@ jobs:
131132
echo Execution of Openupgrade with the update of the following modules : $MODULES_NEW
132133
# Silence redundant logs from unlinking records (1 line is enough)
133134
# to prevent log overflow
134-
OPENUPGRADE_TESTS=1 $ODOO \
135+
$ODOO \
135136
--addons-path=`echo $ADDONS_PATHS | awk -v OFS="," '$1=$1'` \
136137
--database=$DB \
137138
--db_host=$DB_HOST \
138139
--db_password=$DB_PASSWORD \
139140
--db_port=$DB_PORT \
140141
--db_user=$DB_USERNAME \
141142
--load=base,web,openupgrade_framework \
143+
--test-enable \
144+
--test-tags openupgrade \
142145
--log-handler odoo.models.unlink:WARNING \
143146
--stop-after-init \
144147
--update=$MODULES_NEW

openupgrade_framework/__init__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,20 @@
1414
"location of openupgrade_scripts"
1515
)
1616
config["upgrade_path"] = os.path.join(path, "scripts")
17+
18+
19+
def openupgrade_test(cls):
20+
"""
21+
Set attributes on a test class necessary for the test framework
22+
Use as decorator on test classes in openupgrade_scripts/scripts/*/tests/test_*.py
23+
"""
24+
tags = getattr(cls, "test_tags", None) or set()
25+
if "openupgrade" not in tags:
26+
tags.add("openupgrade")
27+
if not any(t.endswith("_install") for t in tags):
28+
tags.add("at_install")
29+
cls.test_tags = tags
30+
cls.test_module = cls.__module__.split(".")[2]
31+
cls.test_class = cls.__name__
32+
cls.test_sequence = 0
33+
return cls

0 commit comments

Comments
 (0)