Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] queue_job: Don't raise a warning for valid context #679

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion queue_job/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ def must_run_without_delay(env):
return True

if env.context.get("queue_job__no_delay"):
_logger.warning("`queue_job__no_delay` ctx key found. NO JOB scheduled.")
_logger.info("`queue_job__no_delay` ctx key found. NO JOB scheduled.")
return True
13 changes: 9 additions & 4 deletions test_queue_job/tests/test_job_auto_delay.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@ def test_auto_delay_inside_job(self):

def test_auto_delay_force_sync(self):
"""method forced to run synchronously"""
result = (
self.env["test.queue.job"]
.with_context(_job_force_sync=True)
.delay_me(1, kwarg=2)
with self.assertLogs(level="WARNING") as log_catcher:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test needs an update no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

result = (
self.env["test.queue.job"]
.with_context(_job_force_sync=True)
.delay_me(1, kwarg=2)
)
self.assertEqual(
len(log_catcher.output), 1, "Exactly one warning should be logged"
)
self.assertIn(" ctx key found. NO JOB scheduled. ", log_catcher.output[0])
self.assertTrue(result, (1, 2))

def test_auto_delay_context_key_set(self):
Expand Down
Loading