def test_docker_build_template(self, mock_ds): """test build with template""" mock_ds.run = mock.Mock() self.opts.dockerstache_template = 'template' self.opts.dockerstache_context = 'context' self.opts.dockerstache_defaults = 'defaults' self.opts.no_cache = False dckr.docker_build(self.opts, self.config) self.failUnless(mock_ds.run.called) mock_ds.run.assert_has_calls( mock.call( output='vm/docker_image', context=None, defaults=None, input='template', extend_context=mock.ANY ) ) self.mock_popen.assert_has_calls( mock.call( [ 'docker', 'build', '-t', 'unittesting/unittesting:latest', '-t', 'unittesting/unittesting:1.2.3', 'vm/docker_image' ], stderr=mock.ANY, stdout=mock.ANY ) )
def test_docker_build_login(self): """test build with login""" self.opts.login = True # no creds in config: self.assertRaises(SystemExit, dckr.docker_build, self.opts, self.config) self.config['docker']['docker_login_username'] = '******' self.config['docker']['docker_login_password'] = '******' self.config['docker']['docker_login_email'] = '*****@*****.**' self.config['docker']['repo'] = 'unittesting' dckr.docker_build(self.opts, self.config) self.failUnless(self.mock_check_output.called) self.mock_check_output.assert_has_calls( [ mock.call( ['docker', 'login', '-u', 'steve', '-p', 'st3v3R0X', 'unittesting'], ) ]) self.mock_popen.assert_has_calls( mock.call( [ 'docker', 'build', '-t', 'unittesting/unittesting:latest', '-t', 'unittesting/unittesting:1.2.3', 'vm/docker_image' ], stderr=mock.ANY, stdout=mock.ANY ) )
def test_docker_build(self): """test straight docker build call""" dckr.docker_build(self.opts, self.config) self.failUnless(self.mock_subp.check_output.called) self.mock_subp.check_output.assert_has_calls( mock.call([ 'docker', 'build', '-t', 'unittesting/unittesting:latest', '-t', 'unittesting/unittesting:1.2.3', 'vm/docker_image' ]))
def test_docker_build_args(self): """test straight docker build call""" self.opts.build_arg = {"OPTION1": "VALUE1"} dckr.docker_build(self.opts, self.config) self.failUnless(self.mock_check_output.called) self.mock_check_output.assert_has_calls( mock.call([ 'docker', 'build', '-t', 'unittesting/unittesting:latest', '-t', 'unittesting/unittesting:1.2.3', '--build-arg', 'OPTION1=VALUE1', 'vm/docker_image' ]))
def test_docker_build(self): """test straight docker build call""" dckr.docker_build(self.opts, self.config) self.failUnless(self.mock_popen.wait.called) self.mock_popen.assert_has_calls( mock.call([ 'docker', 'build', '-t', 'unittesting/unittesting:latest', '-t', 'unittesting/unittesting:1.2.3', 'vm/docker_image' ], stderr=mock.ANY, stdout=mock.ANY))
def test_docker_build_addl_repos(self): self.config['docker']['additional_repos'] = "repo1:8080, repo2:8080 " dckr.docker_build(self.opts, self.config) self.failUnless(self.mock_subp.check_output.called) self.mock_subp.check_output.assert_has_calls( mock.call([ 'docker', 'build', '-t', 'unittesting/unittesting:latest', '-t', 'unittesting/unittesting:1.2.3', '-t', 'repo1:8080/unittesting:1.2.3', '-t', 'repo1:8080/unittesting:latest', '-t', 'repo2:8080/unittesting:1.2.3', '-t', 'repo2:8080/unittesting:latest', 'vm/docker_image' ]))
def test_docker_build_args(self): """test straight docker build call""" self.opts.build_arg = {"OPTION1": "VALUE1"} self.opts.no_cache = False dckr.docker_build(self.opts, self.config) self.failUnless(self.mock_popen.wait.called) self.mock_popen.assert_has_calls( mock.call([ 'docker', 'build', '-t', 'unittesting/unittesting:latest', '-t', 'unittesting/unittesting:1.2.3', '--build-arg', 'OPTION1=VALUE1', 'vm/docker_image' ], stderr=mock.ANY, stdout=mock.ANY))
def test_docker_build_addl_repos(self): self.config['docker']['additional_repos'] = "repo1:8080, repo2:8080 " dckr.docker_build(self.opts, self.config) self.failUnless(self.mock_popen.wait.called) self.mock_popen.assert_has_calls( mock.call([ 'docker', 'build', '-t', 'unittesting/unittesting:latest', '-t', 'unittesting/unittesting:1.2.3', '-t', 'repo1:8080/unittesting:1.2.3', '-t', 'repo1:8080/unittesting:latest', '-t', 'repo2:8080/unittesting:1.2.3', '-t', 'repo2:8080/unittesting:latest', 'vm/docker_image' ], stderr=mock.ANY, stdout=mock.ANY))
def test_docker_build(self): """test straight docker build call""" dckr.docker_build(self.opts, self.config) self.failUnless(self.mock_popen.wait.called) self.mock_popen.assert_has_calls( mock.call( [ 'docker', 'build', '-t', 'unittesting/unittesting:latest', '-t', 'unittesting/unittesting:1.2.3', 'vm/docker_image' ], stderr=mock.ANY, stdout=mock.ANY ) )
def test_docker_build_args_local_test(self): """test straight docker build call""" self.opts.build_arg = {} self.opts.no_cache = False self.opts.local_test = True dckr.docker_build(self.opts, self.config) self.failUnless(self.mock_popen.wait.called) self.mock_popen.assert_has_calls( mock.call([ 'docker', 'build', '-t', 'unittesting/unittesting:latest', '-t', 'unittesting/unittesting:1.2.3', '--build-arg', 'LOCAL_INSTALL=/opt/unittesting-latest.tar.gz', 'vm/docker_image' ], stderr=mock.ANY, stdout=mock.ANY))
def test_docker_build_args(self): """test straight docker build call""" self.opts.build_arg = {"OPTION1": "VALUE1"} self.opts.no_cache = False dckr.docker_build(self.opts, self.config) self.failUnless(self.mock_popen.wait.called) self.mock_popen.assert_has_calls( mock.call( [ 'docker', 'build', '-t', 'unittesting/unittesting:latest', '-t', 'unittesting/unittesting:1.2.3', '--build-arg', 'OPTION1=VALUE1', 'vm/docker_image'], stderr=mock.ANY, stdout=mock.ANY ) )
def test_docker_build_addl_repos(self): self.config['docker']['additional_repos'] = "repo1:8080, repo2:8080 " dckr.docker_build(self.opts, self.config) self.failUnless(self.mock_popen.wait.called) self.mock_popen.assert_has_calls( mock.call( [ 'docker', 'build', '-t', 'unittesting/unittesting:latest', '-t', 'unittesting/unittesting:1.2.3', '-t', 'repo1:8080/unittesting:1.2.3', '-t', 'repo1:8080/unittesting:latest', '-t', 'repo2:8080/unittesting:1.2.3', '-t', 'repo2:8080/unittesting:latest', 'vm/docker_image'], stderr=mock.ANY, stdout=mock.ANY ) )
def test_docker_build_args_local_test(self): """test straight docker build call""" self.opts.build_arg = {} self.opts.no_cache = False self.opts.local_test = True dckr.docker_build(self.opts, self.config) self.failUnless(self.mock_popen.wait.called) self.mock_popen.assert_has_calls( mock.call( [ 'docker', 'build', '-t', 'unittesting/unittesting:latest', '-t', 'unittesting/unittesting:1.2.3', '--build-arg', 'LOCAL_INSTALL=/opt/unittesting-latest.tar.gz', 'vm/docker_image'], stderr=mock.ANY, stdout=mock.ANY ) )