itsulu-blog-publisher/conftest.py
Nicholas Riegel c039b5f0cb release: v0.4.8 — CI pipeline green + Odoo 17 fixes (squash of !1)
Squash-merge of fix/ci-pipeline-corrections. Drives the full test suite
to 69/69 green on the ITSulu K8s cluster and fixes two production bugs.

Production fixes:
- Email template migrated from dead Odoo Mako (${}/% for) to Odoo 17
  inline_template ({{ }}) + qweb body (type="html", t-out/t-foreach/t-if).
  Notification emails previously rendered raw code in the subject/body.
- _create_blog_post now writes 'content': llm_response.body_html — every
  auto-generated post was publishing empty.
- Removed duplicate itsulu_social_id field (startup warning).

Testing & infra:
- CI pipeline corrected (stage order, DB auth, junit artifact, addons path).
- E2E moved to ephemeral jobs in the itsulu-testing K8s namespace.
- Test code brought up to Odoo 17 (mail rendering, blog.post.content,
  pytest-bdd env fixture, _render_field).

Versioning:
- Introduce MAJOR.MINOR.PATCH scheme, VERSION file, scripts/bump-version.sh,
  CHANGELOG.md; first release v0.4.8. CLAUDE.md §15 documents the process.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-30 10:58:57 -04:00

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)