commit
c0b43a47be
|
|
@ -5,6 +5,12 @@ used values are 'dev', 'test', 'production'::
|
||||||
[options]
|
[options]
|
||||||
running_env=dev
|
running_env=dev
|
||||||
|
|
||||||
|
Or set the `RUNNING_ENV` or `ODOO_STAGE` environment variable. If both all are set config file
|
||||||
|
will take the precedence on environment and `RUNNING_ENV` over `ODOO_STAGE`.
|
||||||
|
|
||||||
|
`ODOO_STAGE` is used for odoo.sh platform where we can't set `RUNNING_ENV`, possible
|
||||||
|
observed values are `production`, `staging` and `dev`
|
||||||
|
|
||||||
Values associated to keys containing 'passw' are only displayed in the 'dev'
|
Values associated to keys containing 'passw' are only displayed in the 'dev'
|
||||||
environment.
|
environment.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,13 +45,20 @@ _boolean_states = {
|
||||||
|
|
||||||
def _load_running_env():
|
def _load_running_env():
|
||||||
if not system_base_config.get("running_env"):
|
if not system_base_config.get("running_env"):
|
||||||
_logger.info("`running_env` not found. Using default = `test`.")
|
env_running_env = os.environ.get("RUNNING_ENV", os.environ.get("ODOO_STAGE"))
|
||||||
_logger.info(
|
if env_running_env:
|
||||||
"We strongly recommend against using the rc file but instead use an "
|
system_base_config["running_env"] = env_running_env
|
||||||
"explicit config file or env variable."
|
else:
|
||||||
)
|
_logger.info(
|
||||||
# safe default
|
"`running_env` or `RUNNING_ENV`, `ODOO_STAGE` not found. "
|
||||||
system_base_config["running_env"] = "test"
|
"Using default = `test`."
|
||||||
|
)
|
||||||
|
_logger.info(
|
||||||
|
"We strongly recommend against using the rc file but instead use an "
|
||||||
|
"explicit config file or env variable."
|
||||||
|
)
|
||||||
|
# safe default
|
||||||
|
system_base_config["running_env"] = "test"
|
||||||
|
|
||||||
|
|
||||||
_load_running_env()
|
_load_running_env()
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Copyright 2018 Camptocamp (https://www.camptocamp.com).
|
# Copyright 2018 Camptocamp (https://www.camptocamp.com).
|
||||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||||
|
import os
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from odoo.tools.config import config as odoo_config
|
from odoo.tools.config import config as odoo_config
|
||||||
|
|
@ -35,8 +35,21 @@ class TestEnv(common.ServerEnvironmentCase):
|
||||||
|
|
||||||
@patch.dict(odoo_config.options, {"running_env": "whatever"})
|
@patch.dict(odoo_config.options, {"running_env": "whatever"})
|
||||||
def test_default_non_dev_env(self):
|
def test_default_non_dev_env(self):
|
||||||
|
server_env._load_running_env()
|
||||||
self._test_default(hidden_pwd=True)
|
self._test_default(hidden_pwd=True)
|
||||||
|
|
||||||
|
@patch.dict(odoo_config.options, {"running_env": None})
|
||||||
|
@patch.dict(os.environ, {"RUNNING_ENV": "dev"})
|
||||||
|
def test_default_dev_from_environ(self):
|
||||||
|
server_env._load_running_env()
|
||||||
|
self._test_default()
|
||||||
|
|
||||||
|
@patch.dict(odoo_config.options, {"running_env": None})
|
||||||
|
@patch.dict(os.environ, {"ODOO_STAGE": "dev"})
|
||||||
|
def test_odoosh_dev_from_environ(self):
|
||||||
|
server_env._load_running_env()
|
||||||
|
self._test_default()
|
||||||
|
|
||||||
@patch.dict(odoo_config.options, {"running_env": "testing"})
|
@patch.dict(odoo_config.options, {"running_env": "testing"})
|
||||||
def test_value_retrival(self):
|
def test_value_retrival(self):
|
||||||
with self.set_config_dir("testfiles"):
|
with self.set_config_dir("testfiles"):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue