@@ -1185,22 +1185,15 @@ def test_network_can_be_enable(self, mock_checkout):
11851185 'job_type' : 'install_odoo' ,
11861186 })
11871187
1188- # by default, network is disabled
1189- def first_docker_run (cmd , log_path , * args , ** kwargs ):
1190- self .assertFalse (kwargs ['network_enabled' ])
1191-
1192- self .docker_run_patch = first_docker_run
11931188 config_step ._run_step (self .parent_build )()
1194-
1195- def second_docker_run (cmd , log_path , * args , ** kwargs ):
1196- self .assertTrue (kwargs ['network_enabled' ])
1197-
1198- self .docker_run_patch = second_docker_run
1189+ self .assertFalse (self .docker_run_calls [0 ][3 ]['network_enabled' ])
11991190
12001191 parent_build_params = self .parent_build .params_id .copy ({'config_data' : {'network_enabled' : True }})
12011192 parent_build = self .parent_build .copy ({'params_id' : parent_build_params .id })
12021193 config_step ._run_step (parent_build )()
12031194
1195+ self .assertTrue (self .docker_run_calls [1 ][3 ]['network_enabled' ])
1196+
12041197
12051198 @patch ('odoo.addons.runbot.models.build.BuildResult._checkout' )
12061199 def test_run_python_networkcan_be_enabled (self , mock_checkout ):
@@ -1241,6 +1234,21 @@ def test_install_custom_parametric_tags(self, mock_checkout, parse_config):
12411234 tags = self .get_test_tags (params )
12421235 self .assertEqual (tags , '"-at_install,/web/foo.py:WebSuite.test_unit_desktop[@bar/test with spaces],-/web/bar.py[@snafu/other test with spaces]"' )
12431236
1237+ @patch ('odoo.addons.runbot.models.build.BuildResult._checkout' )
1238+ def test_memory_limit (self , mock_checkout ):
1239+ """ test that network can be disabled with config_data """
1240+ config_step = self .ConfigStep .create ({
1241+ 'name' : 'default' ,
1242+ 'job_type' : 'install_odoo' ,
1243+ })
1244+ self .env ['ir.config_parameter' ].sudo ().set_param ('runbot.runbot_containers_memory' , 10 )
1245+ config_step ._run_step (self .parent_build )()
1246+ self .assertEqual (self .docker_run_calls [0 ][3 ]['memory' ], 10 * 1024 ** 3 )
1247+
1248+ parent_build_params = self .parent_build .params_id .copy ({'config_data' : {'memory_limit_factor' : 0.9 }})
1249+ parent_build = self .parent_build .copy ({'params_id' : parent_build_params .id })
1250+ config_step ._run_step (parent_build )()
1251+ self .assertEqual (self .docker_run_calls [1 ][3 ]['memory' ], 9 * 1024 ** 3 )
12441252class TestMakeResult (RunbotCase ):
12451253
12461254 def setUp (self ):
0 commit comments