-
-
Notifications
You must be signed in to change notification settings - Fork 460
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
queue_job: fix retry format with tuple values
#348 added support for randomized retry intervals. Configuration of randomized retry intervals is not possible due to the formatting checks not being updated. This should fix it.
- Loading branch information
Showing
3 changed files
with
54 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import odoo.tests.common as common | ||
from odoo import exceptions | ||
|
||
|
||
class TestJobFunction(common.TransactionCase): | ||
def setUp(self): | ||
super(TestJobFunction, self).setUp() | ||
self.test_function_model = self.env.ref( | ||
"queue_job.job_function_queue_job__test_job" | ||
) | ||
|
||
def test_check_retry_pattern_randomized_case(self): | ||
randomized_pattern = "{1: (10, 20), 2: (20, 40)}" | ||
self.test_function_model.edit_retry_pattern = randomized_pattern | ||
self.assertEqual( | ||
self.test_function_model.edit_retry_pattern, randomized_pattern | ||
) | ||
|
||
def test_check_retry_pattern_fixed_case(self): | ||
fixed_pattern = "{1: 10, 2: 20}" | ||
self.test_function_model.edit_retry_pattern = fixed_pattern | ||
self.assertEqual(self.test_function_model.edit_retry_pattern, fixed_pattern) | ||
|
||
def test_check_retry_pattern_invalid_cases(self): | ||
invalid_time_value_pattern = "{1: a, 2: 20}" | ||
with self.assertRaises(exceptions.UserError): | ||
self.test_function_model.edit_retry_pattern = invalid_time_value_pattern | ||
|
||
invalid_retry_count_pattern = "{a: 10, 2: 20}" | ||
with self.assertRaises(exceptions.UserError): | ||
self.test_function_model.edit_retry_pattern = invalid_retry_count_pattern | ||
|
||
invalid_randomized_pattern = "{1: (1, 2, 3), 2: 20}" | ||
with self.assertRaises(exceptions.UserError): | ||
self.test_function_model.edit_retry_pattern = invalid_randomized_pattern |