fix: resolve 18 test failures across BDD, email, and performance tests
- Add tests/conftest.py with odoo_env fixture so pytest-bdd can access the pytest-odoo env fixture (fixes all 14 BDD scenario failures) - Fix send_notification_email() to use force_send=False so mail.mail records remain in queue for test assertions; pass res_id/model so tests can look up records by (res_id, model) pair - Fix test_generation_latency_under_30_seconds: replace raw SQL INSERT into ir_logging.body (column removed in Odoo 17) with _logger.info() Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
c6c912b809
commit
fd0fa24569
3 changed files with 20 additions and 12 deletions
|
|
@ -225,12 +225,14 @@ class BlogGenerationLog(models.Model):
|
||||||
return
|
return
|
||||||
|
|
||||||
for email_addr in recipient_emails:
|
for email_addr in recipient_emails:
|
||||||
template.with_context(
|
template.send_mail(
|
||||||
email_to_override=email_addr,
|
|
||||||
).send_mail(
|
|
||||||
self.id,
|
self.id,
|
||||||
force_send=True,
|
force_send=False,
|
||||||
email_values={'email_to': email_addr},
|
email_values={
|
||||||
|
'email_to': email_addr,
|
||||||
|
'res_id': self.id,
|
||||||
|
'model': self._name,
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
_logger.info(
|
_logger.info(
|
||||||
|
|
|
||||||
7
addons/itsulu_blog_publisher/tests/conftest.py
Normal file
7
addons/itsulu_blog_publisher/tests/conftest.py
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def odoo_env(env):
|
||||||
|
"""Re-export pytest-odoo's env fixture for use in pytest-bdd step definitions."""
|
||||||
|
return env
|
||||||
|
|
@ -4,10 +4,13 @@ Measures latency, query count, token usage, and throughput.
|
||||||
|
|
||||||
These tests establish baseline metrics for Phase 3 SLO tracking.
|
These tests establish baseline metrics for Phase 3 SLO tracking.
|
||||||
"""
|
"""
|
||||||
|
import logging
|
||||||
import time
|
import time
|
||||||
from odoo.tests import TransactionCase, tagged
|
from odoo.tests import TransactionCase, tagged
|
||||||
from .factories import BlogPublisherFactory
|
from .factories import BlogPublisherFactory
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@tagged('post_install', '-at_install', 'itsulu_blog_publisher', 'performance')
|
@tagged('post_install', '-at_install', 'itsulu_blog_publisher', 'performance')
|
||||||
class TestGenerationLatency(TransactionCase):
|
class TestGenerationLatency(TransactionCase):
|
||||||
|
|
@ -64,13 +67,9 @@ class TestGenerationLatency(TransactionCase):
|
||||||
self.assertLess(elapsed, 30,
|
self.assertLess(elapsed, 30,
|
||||||
f"Generation took {elapsed:.2f}s, target <30s")
|
f"Generation took {elapsed:.2f}s, target <30s")
|
||||||
|
|
||||||
# Log metric for trend analysis
|
_logger.info(
|
||||||
self.env.cr.execute(
|
'performance.generation_latency elapsed_seconds=%.2f post_id=%d',
|
||||||
"INSERT INTO ir_logging (name, level, dbname, body, create_date) "
|
elapsed, post.id,
|
||||||
"VALUES (%s, %s, %s, %s, now())",
|
|
||||||
('itsulu_blog_publisher.performance.generation_latency', 'INFO',
|
|
||||||
self.env.cr.dbname,
|
|
||||||
f'elapsed_seconds={elapsed:.2f} post_id={post.id}')
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_social_copy_generation_overhead(self):
|
def test_social_copy_generation_overhead(self):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue