def test_deploy_bundle_template(self):
     self.patch_object(lc_deploy.utils, 'get_charm_config')
     self.patch_object(lc_deploy, 'get_template')
     self.get_template.return_value = './tests/bundles/bionic.yaml.j2'
     self.patch_object(lc_deploy.os.path, 'exists')
     self.exists.return_value = False
     self.patch_object(lc_deploy, 'render_template')
     self.render_template.return_value = '/tmp/mytmpdir/bionic.yaml'
     self.get_charm_config.return_value = {}
     self.patch_object(lc_deploy.tempfile, 'TemporaryDirectory')
     enter_mock = mock.MagicMock()
     enter_mock.__enter__.return_value = '/tmp/mytmpdir'
     self.TemporaryDirectory.return_value = enter_mock
     self.patch_object(lc_deploy, 'render_overlays')
     self.patch_object(lc_deploy.utils, 'check_output_logging')
     self.render_overlays.return_value = []
     lc_deploy.deploy_bundle('./tests/bundles/bionic.yaml',
                             'newmodel',
                             force=True)
     self.check_output_logging.assert_called_once_with([
         'juju', 'deploy', '-m', 'newmodel', '--force',
         '/tmp/mytmpdir/bionic.yaml'
     ])
     self.get_template.assert_called_once_with(
         './tests/bundles/bionic.yaml', template_dir='./tests/bundles')
     self.render_template.assert_called_once_with(
         './tests/bundles/bionic.yaml.j2',
         '/tmp/mytmpdir/bionic.yaml',
         model_ctxt=None)
示例#2
0
 def test_deploy_bundle(self):
     self.patch_object(lc_deploy.utils, 'get_charm_config')
     self.get_charm_config.return_value = {}
     self.patch_object(lc_deploy, 'render_overlays')
     self.patch_object(lc_deploy.subprocess, 'check_call')
     self.render_overlays.return_value = []
     lc_deploy.deploy_bundle('bun.yaml', 'newmodel')
     self.check_call.assert_called_once_with(
         ['juju', 'deploy', '-m', 'newmodel', 'bun.yaml'])
示例#3
0
 def test_deploy_bundle(self):
     self.patch_object(lc_deploy.utils, 'get_charm_config')
     self.get_charm_config.return_value = {}
     self.patch_object(lc_deploy, 'render_overlays')
     self.patch_object(lc_deploy.utils, 'check_output_logging')
     self.render_overlays.return_value = []
     lc_deploy.deploy_bundle('bun.yaml', 'newmodel', force=True)
     self.check_output_logging.assert_called_once_with(
         ['juju', 'deploy', '-m', 'newmodel', 'bun.yaml', '--force'])
 def test_deploy_bundle_template_conflict(self):
     self.patch_object(lc_deploy.utils, 'get_charm_config')
     template_mock = mock.MagicMock()
     template_mock.filename = './tests/bundles/bionic.yaml.j2'
     self.patch_object(lc_deploy, 'get_template')
     self.get_template.return_value = template_mock
     self.patch_object(lc_deploy.os.path, 'exists')
     self.exists.return_value = True
     self.get_charm_config.return_value = {}
     self.patch_object(lc_deploy.tempfile, 'TemporaryDirectory')
     enter_mock = mock.MagicMock()
     enter_mock.__enter__.return_value = '/tmp/mytmpdir'
     self.TemporaryDirectory.return_value = enter_mock
     with self.assertRaises(zaza_exceptions.TemplateConflict):
         lc_deploy.deploy_bundle('./tests/bundles/bionic.yaml',
                                 'newmodel',
                                 force=True)
 def test_deploy_bundle(self):
     self.patch_object(lc_deploy.subprocess, 'check_call')
     lc_deploy.deploy_bundle('bun.yaml', 'newmodel')
     self.check_call.assert_called_once_with(
         ['juju', 'deploy', '-m', 'newmodel', 'bun.yaml'])