- odoo_env fixture: use request.getfixturevalue('env') instead of
direct env parameter injection — pytest-bdd cannot inject pytest-odoo
fixtures by name into conftest fixtures; getfixturevalue() bypasses
this limitation
- generate_email: use list-based API generate_email([res_id]) returning
{res_id: {field: value}} — Odoo 17 does not accept a bare int
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
"""
|
|
Global pytest configuration for ITSulu Blog Publisher tests.
|
|
Installs the addon into the test database before any test code runs.
|
|
"""
|
|
import subprocess
|
|
import sys
|
|
import pytest
|
|
|
|
|
|
@pytest.fixture
|
|
def odoo_env(request):
|
|
"""Re-export pytest-odoo's env fixture for use in pytest-bdd step definitions."""
|
|
return request.getfixturevalue('env')
|
|
|
|
|
|
print(">>> conftest.py loaded", file=sys.stderr)
|
|
|
|
|
|
def pytest_configure(config):
|
|
"""Install itsulu_blog_publisher into the test database."""
|
|
print(">>> pytest_configure hook called", file=sys.stderr)
|
|
|
|
db_name = getattr(config.option, 'odoo_database', None)
|
|
print(f">>> odoo_database option: {db_name}", file=sys.stderr)
|
|
|
|
if not db_name:
|
|
print(">>> No database name — skipping install", file=sys.stderr)
|
|
return
|
|
|
|
print(f"\n🚀 Installing itsulu_blog_publisher into {db_name}...", file=sys.stderr)
|
|
|
|
cmd = [
|
|
'odoo',
|
|
'-d', db_name,
|
|
'-i', 'itsulu_blog_publisher',
|
|
'--without-demo=all',
|
|
'--stop-after-init',
|
|
]
|
|
|
|
try:
|
|
result = subprocess.run(cmd, capture_output=True, text=True, timeout=120)
|
|
if result.returncode == 0:
|
|
print(f"✅ Addon installed successfully", file=sys.stderr)
|
|
else:
|
|
print(f"⚠️ Install returned {result.returncode}", file=sys.stderr)
|
|
if result.stderr:
|
|
print(f" STDERR: {result.stderr[-300:]}", file=sys.stderr)
|
|
except subprocess.TimeoutExpired:
|
|
print(f"⚠️ Install timed out (120s)", file=sys.stderr)
|
|
except Exception as e:
|
|
print(f"⚠️ Install error: {e}", file=sys.stderr)
|
|
|