diff --git a/test_queue_job/__manifest__.py b/test_queue_job/__manifest__.py index baa4e9cf06..9424e31cd3 100644 --- a/test_queue_job/__manifest__.py +++ b/test_queue_job/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Queue Job Tests", - "version": "17.0.1.0.1", + "version": "18.0.1.0.0", "author": "Camptocamp,Odoo Community Association (OCA)", "license": "LGPL-3", "category": "Generic Modules", diff --git a/test_queue_job/security/ir.model.access.csv b/test_queue_job/security/ir.model.access.csv index dba58d51a2..40b9c7f138 100644 --- a/test_queue_job/security/ir.model.access.csv +++ b/test_queue_job/security/ir.model.access.csv @@ -1,4 +1,4 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_test_queue_job,access_test_queue_job,model_test_queue_job,,1,1,1,1 -access_test_queue_channel,access_test_queue_channel,model_test_queue_channel,,1,1,1,1 -access_test_related_action,access_test_related_action,model_test_related_action,,1,1,1,1 +access_test_queue_job,access_test_queue_job,model_test_queue_job,queue_job.group_queue_job_manager,1,1,1,1 +access_test_queue_channel,access_test_queue_channel,model_test_queue_channel,queue_job.group_queue_job_manager,1,1,1,1 +access_test_related_action,access_test_related_action,model_test_related_action,queue_job.group_queue_job_manager,1,1,1,1 diff --git a/test_queue_job/tests/common.py b/test_queue_job/tests/common.py index a32fcc380a..335c072625 100644 --- a/test_queue_job/tests/common.py +++ b/test_queue_job/tests/common.py @@ -17,6 +17,6 @@ def setUpClass(cls): def _create_job(self): test_job = Job(self.method) test_job.store() - stored = Job.db_record_from_uuid(self.env, test_job.uuid) + stored = Job.db_records_from_uuids(self.env, [test_job.uuid]) self.assertEqual(len(stored), 1) return stored diff --git a/test_queue_job/tests/test_delay_mocks.py b/test_queue_job/tests/test_delay_mocks.py index e9e071fd0a..9bd3760168 100644 --- a/test_queue_job/tests/test_delay_mocks.py +++ b/test_queue_job/tests/test_delay_mocks.py @@ -143,11 +143,12 @@ def test_trap_jobs_on_with_delay_assert_model_enqueued_mismatch(self): "identity_key=, " "max_retries=1, priority=15\\) was not enqueued\\.\n" "Actual enqueued jobs:\n" - r" \* .testing_method\(1, foo=2\) with " + rf" \* .testing_method" + r"\(1, foo=2\) with " r"properties \(priority=15, max_retries=1, eta=15, description=Test, " r"channel=root.test, " r"identity_key=\)" - ).format(record_id=recordset.id) + ) with self.assertRaisesRegex(AssertionError, message): trap.assert_enqueued_job( self.env["test.queue.job"].testing_method, diff --git a/test_queue_job/tests/test_delayable.py b/test_queue_job/tests/test_delayable.py index 416638f37b..3bd6cfd5cd 100644 --- a/test_queue_job/tests/test_delayable.py +++ b/test_queue_job/tests/test_delayable.py @@ -2,6 +2,9 @@ # Copyright 2019 Guewen Baconnier # license lgpl-3.0 or later (http://www.gnu.org/licenses/lgpl.html) +import gc +import logging + import odoo.tests.common as common from odoo.addons.queue_job.delay import ( @@ -279,20 +282,23 @@ def test_delayable_group_of_chain(self): ) def test_log_not_delayed(self): - logger_name = "odoo.addons.queue_job" - with self.assertLogs(logger_name, level="WARN") as test: + with self.assertLogs(level=logging.WARNING) as test: # When a Delayable never gets a delay() call, # when the GC collects it and calls __del__, a warning - # will be displayed. We cannot test this is a scenario - # using the GC as it isn't predictable. Call __del__ - # directly + # will be displayed. node = self.job_node(1) - node.__del__() expected = ( "WARNING:odoo.addons.queue_job.delay:Delayable " "Delayable(test.queue.job().testing_method((1,), {}))" " was prepared but never delayed" ) + self.assertFalse(node._generated_job) + + # Remove reference + del node + # Collect garbage using gc + gc.collect() + self.assertEqual(test.output, [expected]) def test_delay_job_already_exists(self): diff --git a/test_queue_job/tests/test_job.py b/test_queue_job/tests/test_job.py index d7414ef7aa..4d771f5516 100644 --- a/test_queue_job/tests/test_job.py +++ b/test_queue_job/tests/test_job.py @@ -527,9 +527,7 @@ def test_button_done(self): stored = self._create_job() stored.button_done() self.assertEqual(stored.state, DONE) - self.assertEqual( - stored.result, "Manually set to done by %s" % self.env.user.name - ) + self.assertEqual(stored.result, f"Manually set to done by {self.env.user.name}") def test_button_done_enqueue_waiting_dependencies(self): job_root = Job(self.env["test.queue.job"].testing_method) diff --git a/test_queue_job/tests/test_job_auto_delay.py b/test_queue_job/tests/test_job_auto_delay.py index 14c1e2ed61..56dbf16313 100644 --- a/test_queue_job/tests/test_job_auto_delay.py +++ b/test_queue_job/tests/test_job_auto_delay.py @@ -32,16 +32,7 @@ def test_auto_delay_inside_job(self): def test_auto_delay_force_sync(self): """method forced to run synchronously""" - with self.assertLogs(level="WARNING") as log_catcher: - 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]) + result = self.env["test.queue.job"].delay_me(1, kwarg=2) self.assertTrue(result, (1, 2)) def test_auto_delay_context_key_set(self): diff --git a/test_queue_job/tests/test_job_function.py b/test_queue_job/tests/test_job_function.py index 17781ac475..320b4973c5 100644 --- a/test_queue_job/tests/test_job_function.py +++ b/test_queue_job/tests/test_job_function.py @@ -4,7 +4,7 @@ class TestJobFunction(common.TransactionCase): def setUp(self): - super(TestJobFunction, self).setUp() + super().setUp() self.test_function_model = self.env.ref( "queue_job.job_function_queue_job__test_job" )