Skip to content
Open
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
28 changes: 23 additions & 5 deletions bin/oca_init_test_database
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,32 @@ set -exo pipefail

oca_wait_for_postgres

# Identify ODOO_MAJOR version
if [[ "$ODOO_VERSION" =~ ^([0-9]+)\.([0-9]+)$ ]]; then
ODOO_MAJOR="${BASH_REMATCH[1]}"
else
printf 'Invalid ODOO_VERSION format: %s\n' "$ODOO_VERSION" >&2
exit 1
fi

# Select addons to install
if [ -n "${INCLUDE}" ]; then
ADDONS=$(manifestoo --select-include "${INCLUDE}" --select-exclude "${EXCLUDE}" list-depends --separator=,)
else
ADDONS=$(manifestoo --select-addons-dir ${ADDONS_DIR} --select-exclude "${EXCLUDE}" list-depends --separator=,)
fi

unbuffer $(which odoo) \
-d ${PGDATABASE} \
-i ${ADDONS:-base} \
--http-interface=127.0.0.1 \
--stop-after-init | oca_checklog_odoo
# Build odoo run parameters
params=(
-d "$PGDATABASE"
-i "$ADDONS"
--http-interface=127.0.0.1
--stop-after-init
)

# Add --skip-auto-install for Odoo 19.0 and later
if (( ODOO_MAJOR >= 19 )); then
params+=(--skip-auto-install)
fi

unbuffer $(which odoo) ${params[@]} | oca_checklog_odoo
Empty file.
8 changes: 8 additions & 0 deletions tests/data/addons/addon_auto_install/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "addon with successful test",
"version": "1.0.0",
"depends": [
"base",
],
"auto_install": True,
}
1 change: 1 addition & 0 deletions tests/data/addons/addon_auto_install/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_success
6 changes: 6 additions & 0 deletions tests/data/addons/addon_auto_install/tests/test_success.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from odoo.tests.common import TransactionCase


class Test(TransactionCase):
def test_success(self):
pass
11 changes: 11 additions & 0 deletions tests/test_success.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,14 @@ def test_success():
["oca_run_tests"], cwd=addons_dir, text=True
)
assert did_run_test_module(result, "addon_success.tests.test_success")


def test_success_auto_install():
"""Test successful test with auto-install."""
with install_test_addons(["addon_auto_install"]) as addons_dir:
dropdb()
subprocess.check_call(["oca_init_test_database"], cwd=addons_dir)
result = subprocess.check_output(
["oca_run_tests"], cwd=addons_dir, text=True
)
assert did_run_test_module(result, "addon_auto_install.tests.test_success")