-
-
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.
[IMP] Make default subchannel capacity configurable.
Either ODOO_QUEUE_JOB_DEFAULT_SUBCHANNEL_CAPACITY may be set as an environment variable, or default_subchannel_capacity may be set in the [queue_job] config file stanza.
- Loading branch information
Showing
3 changed files
with
34 additions
and
2 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 |
---|---|---|
@@ -1,10 +1,28 @@ | ||
# Copyright 2015-2016 Camptocamp SA | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) | ||
|
||
import os | ||
from unittest.mock import patch | ||
|
||
from odoo.tests import BaseCase | ||
|
||
# pylint: disable=odoo-addons-relative-import | ||
# we are testing, we want to test as we were an external consumer of the API | ||
from odoo.addons.queue_job.jobrunner import channels | ||
|
||
from .common import load_doctests | ||
|
||
load_tests = load_doctests(channels) | ||
|
||
|
||
class TestDefaultSubchannelCapacity(BaseCase): | ||
@patch.dict(os.environ, {"ODOO_QUEUE_JOB_DEFAULT_SUBCHANNEL_CAPACITY": "1"}) | ||
def test_default_subchannel_capacity_env(self): | ||
self.assertEqual(channels._default_subchannel_capacity(), 1) | ||
|
||
@patch.dict(channels.queue_job_config, {"default_subchannel_capacity": "1"}) | ||
def test_default_subchannel_capacity_conf(self): | ||
self.assertEqual(channels._default_subchannel_capacity(), 1) | ||
|
||
def test_default_subchannel_capacity_omit(self): | ||
self.assertIs(channels._default_subchannel_capacity(), None) |