Skip to content

Commit

Permalink
[FIX] *queue_job: Pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobaeza committed May 1, 2024
1 parent ced094b commit 190d3fe
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions queue_job/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def trap_jobs(self):


@contextmanager
def mock_with_delay():
def mock_with_delay(): # pylint: disable=E501
"""Context Manager mocking ``with_delay()``
DEPRECATED: use ``trap_jobs()'``.
Expand Down Expand Up @@ -390,9 +390,9 @@ def test_export(self):
self.assertDictEqual(delay_kwargs, {})
An example of the first kind of test:
https://github.com/camptocamp/connector-jira/blob/0ca4261b3920d5e8c2ae4bb0fc352ea3f6e9d2cd/connector_jira/tests/test_batch_timestamp_import.py#L43-L76 # noqa
https://github.com/camptocamp/connector-jira/blob/0ca4261b3920d5e8c2ae4bb0fc352ea3f6e9d2cd/connector_jira/tests/test_batch_timestamp_import.py#L43-L76
And the second kind:
https://github.com/camptocamp/connector-jira/blob/0ca4261b3920d5e8c2ae4bb0fc352ea3f6e9d2cd/connector_jira/tests/test_import_task.py#L34-L46 # noqa
https://github.com/camptocamp/connector-jira/blob/0ca4261b3920d5e8c2ae4bb0fc352ea3f6e9d2cd/connector_jira/tests/test_import_task.py#L34-L46
"""
with mock.patch(
Expand Down
2 changes: 1 addition & 1 deletion queue_job/tests/test_model_job_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_channel_complete_name_uniq(self):

# The context manager 'with self.assertRaises(IntegrityError)' purposefully
# not uses here due to its 'flush_all()' method inside it and exception raises
# before the line 'self.env.flush_all()'. So, we are expecting an IntegrityError.
# before the line 'self.env.flush_all()'. So, we are expecting an IntegrityError
try:
self.env.flush_all()
except IntegrityError as ex:
Expand Down
13 changes: 7 additions & 6 deletions test_queue_job/tests/test_delay_mocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,9 @@ def test_trap_jobs_on_with_delay_assert_model_enqueued_mismatch(self):
"identity_key=<function identity_exact at 0x[0-9a-fA-F]+>, "
"max_retries=1, priority=15\\) was not enqueued\\.\n"
"Actual enqueued jobs:\n"
r" \* <test.queue.job\({record_id},\)>.testing_method\(1, foo=2\) with properties "
r"\(priority=15, max_retries=1, eta=15, description=Test, channel=root.test, "
r" \* <test.queue.job\({record_id},\)>.testing_method\(1, foo=2\) with "
r"properties \(priority=15, max_retries=1, eta=15, description=Test, "
r"channel=root.test, "
r"identity_key=<function identity_exact at 0x[0-9a-fA-F]+>\)"
).format(record_id=recordset.id)
with self.assertRaisesRegex(AssertionError, message):
Expand All @@ -168,14 +169,14 @@ def test_trap_jobs_on_with_delay_assert_recordset_enqueued_mismatch(self):
self.env["test.queue.job"].button_that_uses_with_delay()
trap.assert_jobs_count(1)
message = (
rf"Job <test\.queue.job\({recordset.id},\)>\.testing_method\(1, foo=2\) with "
r"properties \(channel=root\.test, description=Test, eta=15, "
rf"Job <test\.queue.job\({recordset.id},\)>\.testing_method\(1, foo=2\)"
r" with properties \(channel=root\.test, description=Test, eta=15, "
"identity_key=<function identity_exact at 0x[0-9a-fA-F]+>, "
"max_retries=1, priority=15\\) was not enqueued\\.\n"
"Actual enqueued jobs:\n"
r" \* <test.queue.job\(\)>.testing_method\(1, foo=2\) with properties "
r"\(priority=15, max_retries=1, eta=15, description=Test, channel=root.test, "
r"identity_key=<function identity_exact at 0x[0-9a-fA-F]+>\)"
r"\(priority=15, max_retries=1, eta=15, description=Test, channel=root."
r"test, identity_key=<function identity_exact at 0x[0-9a-fA-F]+>\)"
)
with self.assertRaisesRegex(AssertionError, message):
trap.assert_enqueued_job(
Expand Down
2 changes: 1 addition & 1 deletion test_queue_job/tests/test_json_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


class TestJsonField(common.TransactionCase):
# TODO: when migrating to 16.0, adapt the checks in queue_job/tests/test_json_field.py
# TODO: when migrating to 16.0, adapt checks in queue_job/tests/test_json_field.py
# to verify the context keys are encoded and remove these
def test_encoder_recordset_store_context(self):
demo_user = self.env.ref("base.user_demo")
Expand Down

0 comments on commit 190d3fe

Please sign in to comment.