fix: use request.getfixturevalue for odoo_env and list API for generate_email

- 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>
This commit is contained in:
Nicholas Riegel 2026-05-30 02:43:27 -04:00
parent 3245d4e1b2
commit b4d5502d9f
2 changed files with 8 additions and 8 deletions

View file

@ -254,10 +254,10 @@ class TestNotificationEmail(TransactionCase):
# ACT — render the template synchronously to check the subject
template = self.env.ref('itsulu_blog_publisher.email_template_blog_published')
rendered = template.generate_email(log.id, fields=['subject'])
rendered = template.generate_email([log.id], fields=['subject'])
# ASSERT
subject = rendered.get('subject', '')
subject = rendered[log.id].get('subject', '')
self.assertTrue(subject, "Rendered email subject must be non-empty")
self.assertIn('[ITSulu Insights] Blog Post Published:', subject,
f"Unexpected subject: {subject}")
@ -300,8 +300,8 @@ class TestNotificationEmail(TransactionCase):
# Verify template renders all platform copy in the body
template = self.env.ref('itsulu_blog_publisher.email_template_blog_published')
rendered = template.generate_email(log.id, fields=['body_html'])
body = rendered.get('body_html', '')
rendered = template.generate_email([log.id], fields=['body_html'])
body = rendered[log.id].get('body_html', '')
self.assertIn('Twitter A copy', body, "Body must contain Twitter copy")
self.assertIn('LinkedIn copy', body, "Body must contain LinkedIn copy")
@ -319,8 +319,8 @@ class TestNotificationEmail(TransactionCase):
# ASSERT — render the template synchronously to check the URL appears in the body
template = self.env.ref('itsulu_blog_publisher.email_template_blog_published')
rendered = template.generate_email(log.id, fields=['body_html'])
body = rendered.get('body_html', '')
rendered = template.generate_email([log.id], fields=['body_html'])
body = rendered[log.id].get('body_html', '')
self.assertIn('itsulu.com', body, "Body must contain itsulu.com URL")
def test_notification_email_is_not_sent_for_draft_posts(self):

View file

@ -8,9 +8,9 @@ import pytest
@pytest.fixture
def odoo_env(env):
def odoo_env(request):
"""Re-export pytest-odoo's env fixture for use in pytest-bdd step definitions."""
return env
return request.getfixturevalue('env')
print(">>> conftest.py loaded", file=sys.stderr)