def stubBuildConfig(cfg_dir, component_dir): # template to create buildConfig in test cases cfg = BuildConfig() cfg._runtime = "linux" cfg._tools = Tools() cfg._tools.import_tools_dir=cfg.import_tools_dir cfg._tools.runtime=cfg.runtime cfg.cfg_dir = MagicMock(return_value=cfg_dir) cfg.component_dir = MagicMock(return_value=component_dir) return cfg
def _test_tag_image(self,version,forced,docker_mock): def docker(args,handler=None,dir=None,echo=True,home=None): if len(args) and '-v' in args: handler("Docker version "+version+", build ab77bde/"+version) docker_mock.docker=MagicMock(side_effect=docker) def tag_name(build_cfg,gid,aid,tmp=False): return "tag_name" docker_mock.tag_name=MagicMock(side_effect=tag_name) cfg = BuildConfig() cfg._runtime = "linux" cfg.cfg_dir = MagicMock(return_value=os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'samples')) cfg.component_dir = MagicMock(return_value=os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'samples','docker')) d=dockerbuild.build(cfg) d.tag_image(True) docker_mock.tag_image.assert_called_once_with(None, "tag_name", forced)