@@ -88,3 +88,61 @@ def test_default_hidden_password(self):
8888 self .assertIn ("odoo_I_db_password" , defaults )
8989 self .assertIn ("odoo_I_smtp_password" , defaults )
9090 self .assertIn ("outgoing_mail_provider_promail_I_smtp_pass" , defaults )
91+
92+ @patch .dict (os .environ , {"SERVER_ENVIRONMENT_ALLOW_OVERWRITE_OPTIONS_SECTION" : "0" })
93+ @patch .dict (
94+ odoo_config .options ,
95+ {
96+ "running_env" : "testing" ,
97+ "server_environment_allow_overwrite_options_section" : True ,
98+ "odoo_test_option" : "fake odoo config" ,
99+ },
100+ )
101+ def test_server_environment_allow_overwrite_options_section (self ):
102+ with self .set_config_dir ("testfiles" ):
103+ server_env ._load_config ()
104+ self .assertEqual (
105+ odoo_config ["odoo_test_option" ], "Set in config file for testing env"
106+ )
107+
108+ @patch .dict (os .environ , {"SERVER_ENVIRONMENT_ALLOW_OVERWRITE_OPTIONS_SECTION" : "1" })
109+ @patch .dict (
110+ odoo_config .options ,
111+ {
112+ "running_env" : "testing" ,
113+ "server_environment_allow_overwrite_options_section" : False ,
114+ "odoo_test_option" : "fake odoo config" ,
115+ },
116+ )
117+ def test_server_environment_disabled_overwrite_options_section (self ):
118+ with self .set_config_dir ("testfiles" ):
119+ server_env ._load_config ()
120+ self .assertEqual (odoo_config ["odoo_test_option" ], "fake odoo config" )
121+
122+ @patch .dict (os .environ , {"SERVER_ENVIRONMENT_ALLOW_OVERWRITE_OPTIONS_SECTION" : "1" })
123+ @patch .dict (
124+ odoo_config .options ,
125+ {
126+ "running_env" : "testing" ,
127+ "odoo_test_option" : "fake odoo config" ,
128+ },
129+ )
130+ def test_server_environment_allow_overwrite_options_section_by_env (self ):
131+ with self .set_config_dir ("testfiles" ):
132+ server_env ._load_config ()
133+ self .assertEqual (
134+ odoo_config ["odoo_test_option" ], "Set in config file for testing env"
135+ )
136+
137+ @patch .dict (os .environ , {"SERVER_ENVIRONMENT_ALLOW_OVERWRITE_OPTIONS_SECTION" : "0" })
138+ @patch .dict (
139+ odoo_config .options ,
140+ {
141+ "running_env" : "testing" ,
142+ "odoo_test_option" : "fake odoo config" ,
143+ },
144+ )
145+ def test_server_environment_disabled_overwrite_options_section_by_env (self ):
146+ with self .set_config_dir ("testfiles" ):
147+ server_env ._load_config ()
148+ self .assertEqual (odoo_config ["odoo_test_option" ], "fake odoo config" )
0 commit comments