class DeployGUIRenderTestCase(unittest.TestCase): def setUp(self): self.view_patcher = patch( 'conjureup.controllers.deploy.gui.DeployStatusView') self.view_patcher.start() self.app_patcher = patch( 'conjureup.controllers.deploy.gui.app') self.mock_app = self.app_patcher.start() self.mock_app.ui = MagicMock(name="app.ui") self.controller = DeployController() self.track_screen_patcher = patch( 'conjureup.controllers.deploy.gui.track_screen') self.mock_track_screen = self.track_screen_patcher.start() self.controller._wait_for_applications = MagicMock() self.controller._refresh = MagicMock() self.common_patcher = patch( 'conjureup.controllers.deploy.gui.common') self.mock_common = self.common_patcher.start() def tearDown(self): self.common_patcher.stop() self.view_patcher.stop() self.app_patcher.stop() self.track_screen_patcher.stop() def test_render(self): "call render" self.controller.render() assert self.mock_app.loop.create_task.called
class DeployGUIRenderTestCase(unittest.TestCase): def setUp(self): self.controller = DeployController() self.utils_patcher = patch( 'conjureup.controllers.deploy.gui.utils') self.mock_utils = self.utils_patcher.start() self.mock_bundle = MagicMock(name="bundle") self.mock_bundle.machines = {"1": sentinel.machine_1} self.mock_service_1 = MagicMock(name="s1") self.mock_bundle.services = [self.mock_service_1] self.finish_patcher = patch( 'conjureup.controllers.deploy.gui.DeployController.finish') self.mock_finish = self.finish_patcher.start() self.submit_patcher = patch( 'conjureup.controllers.deploy.gui.async.submit') self.mock_submit = self.submit_patcher.start() self.predeploy_call = call(self.controller._pre_deploy_exec, ANY, queue_name=sentinel.JUJU_ASYNC_QUEUE) self.view_patcher = patch( 'conjureup.controllers.deploy.gui.ApplicationListView') self.view_patcher.start() self.app_patcher = patch( 'conjureup.controllers.deploy.gui.app') mock_app = self.app_patcher.start() mock_app.ui = MagicMock(name="app.ui") mock_app.metadata_controller.bundle = self.mock_bundle self.juju_patcher = patch( 'conjureup.controllers.deploy.gui.juju') self.mock_juju = self.juju_patcher.start() self.mock_juju.JUJU_ASYNC_QUEUE = sentinel.JUJU_ASYNC_QUEUE def tearDown(self): self.utils_patcher.stop() self.finish_patcher.stop() self.submit_patcher.stop() self.view_patcher.stop() self.app_patcher.stop() self.juju_patcher.stop() def test_queue_predeploy_once(self): "Call submit to schedule predeploy if we haven't yet" self.controller.render() self.mock_submit.assert_has_calls([self.predeploy_call], any_order=True) def test_call_add_machines_once_only(self): "Call add_machines once" self.controller.render() self.mock_submit.assert_has_calls([self.predeploy_call], any_order=True) self.mock_juju.add_machines.assert_called_once_with( [sentinel.machine_1], exc_cb=ANY)
class DeployGUIRenderTestCase(unittest.TestCase): def setUp(self): with patch.object(DeployController, 'init_machines_assignments'): self.controller = DeployController() self.utils_patcher = patch( 'conjureup.controllers.deploy.gui.utils') self.mock_utils = self.utils_patcher.start() self.mock_bundle = MagicMock(name="bundle") self.mock_bundle.machines = {"1": sentinel.machine_1} self.mock_service_1 = MagicMock(name="s1") self.mock_bundle.services = [self.mock_service_1] self.finish_patcher = patch( 'conjureup.controllers.deploy.gui.DeployController.finish') self.mock_finish = self.finish_patcher.start() self.submit_patcher = patch( 'conjureup.controllers.deploy.gui.async.submit') self.mock_submit = self.submit_patcher.start() self.predeploy_call = call(self.controller._pre_deploy_exec, ANY, queue_name=sentinel.JUJU_ASYNC_QUEUE) self.view_patcher = patch( 'conjureup.controllers.deploy.gui.ApplicationListView') self.view_patcher.start() self.app_patcher = patch( 'conjureup.controllers.deploy.gui.app') mock_app = self.app_patcher.start() mock_app.ui = MagicMock(name="app.ui") mock_app.metadata_controller.bundle = self.mock_bundle mock_app.current_controller = 'testcontroller' mock_app.bootstrap.running.exception.return_value = None self.juju_patcher = patch( 'conjureup.controllers.deploy.gui.juju') self.mock_juju = self.juju_patcher.start() self.mock_juju.JUJU_ASYNC_QUEUE = sentinel.JUJU_ASYNC_QUEUE self.track_screen_patcher = patch( 'conjureup.controllers.deploy.gui.track_screen') self.mock_track_screen = self.track_screen_patcher.start() def tearDown(self): self.utils_patcher.stop() self.finish_patcher.stop() self.submit_patcher.stop() self.view_patcher.stop() self.app_patcher.stop() self.juju_patcher.stop() self.track_screen_patcher.stop() def test_queue_predeploy_once(self): "Call submit to schedule predeploy if we haven't yet" self.controller.render() self.mock_submit.assert_has_calls([self.predeploy_call], any_order=True)
class DeployGUIRenderTestCase(unittest.TestCase): def setUp(self): self.controller = DeployController() self.utils_patcher = patch( 'conjureup.controllers.deploy.gui.utils') self.mock_utils = self.utils_patcher.start() self.mock_bundle = MagicMock(name="bundle") self.mock_bundle.machines = {"1": sentinel.machine_1} self.mock_service_1 = MagicMock(name="s1") self.mock_bundle.services = [self.mock_service_1] self.finish_patcher = patch( 'conjureup.controllers.deploy.gui.DeployController.finish') self.mock_finish = self.finish_patcher.start() self.submit_patcher = patch( 'conjureup.controllers.deploy.gui.async.submit') self.mock_submit = self.submit_patcher.start() self.predeploy_call = call(self.controller._pre_deploy_exec, ANY, queue_name=sentinel.JUJU_ASYNC_QUEUE) self.view_patcher = patch( 'conjureup.controllers.deploy.gui.ApplicationListView') self.view_patcher.start() self.app_patcher = patch( 'conjureup.controllers.deploy.gui.app') mock_app = self.app_patcher.start() mock_app.ui = MagicMock(name="app.ui") mock_app.metadata_controller.bundle = self.mock_bundle self.juju_patcher = patch( 'conjureup.controllers.deploy.gui.juju') self.mock_juju = self.juju_patcher.start() self.mock_juju.JUJU_ASYNC_QUEUE = sentinel.JUJU_ASYNC_QUEUE def tearDown(self): self.utils_patcher.stop() self.finish_patcher.stop() self.submit_patcher.stop() self.view_patcher.stop() self.app_patcher.stop() self.juju_patcher.stop() def test_queue_predeploy_once(self): "Call submit to schedule predeploy if we haven't yet" self.controller.render() self.mock_submit.assert_has_calls([self.predeploy_call], any_order=True) def test_call_add_machines_once_only(self): "Call add_machines once" self.controller.render() self.mock_submit.assert_has_calls([self.predeploy_call], any_order=True) self.mock_juju.add_machines.assert_called_once_with( [sentinel.machine_1], exc_cb=ANY)
class DeployGUIRenderTestCase(unittest.TestCase): def setUp(self): with patch.object(DeployController, 'init_machines_assignments'): self.controller = DeployController() self.mock_bundle = MagicMock(name="bundle") self.mock_bundle.machines = {"1": sentinel.machine_1} self.mock_service_1 = MagicMock(name="s1") self.mock_bundle.services = [self.mock_service_1] self.finish_patcher = patch( 'conjureup.controllers.deploy.gui.DeployController.finish') self.mock_finish = self.finish_patcher.start() self.common_patcher = patch('conjureup.controllers.deploy.gui.common') self.mock_common = self.common_patcher.start() self.view_patcher = patch( 'conjureup.controllers.deploy.gui.ApplicationListView') self.view_patcher.start() self.app_patcher = patch('conjureup.controllers.deploy.gui.app') self.mock_app = self.app_patcher.start() self.mock_app.ui = MagicMock(name="app.ui") self.mock_app.metadata_controller.bundle = self.mock_bundle self.mock_app.current_controller = 'testcontroller' self.mock_app.bootstrap.running.exception.return_value = None self.ev_app_patcher = patch('conjureup.events.app', self.mock_app) self.ev_app_patcher.start() self.juju_patcher = patch('conjureup.controllers.deploy.gui.juju') self.mock_juju = self.juju_patcher.start() self.track_screen_patcher = patch( 'conjureup.controllers.deploy.gui.track_screen') self.mock_track_screen = self.track_screen_patcher.start() def tearDown(self): self.finish_patcher.stop() self.common_patcher.stop() self.view_patcher.stop() self.app_patcher.stop() self.ev_app_patcher.stop() self.juju_patcher.stop() self.track_screen_patcher.stop() def test_queue_predeploy_once(self): "Call submit to schedule predeploy if we haven't yet" self.controller.render() pd = self.mock_common.pre_deploy.return_value self.mock_app.loop.create_task.assert_called_once_with(pd)
class DeployGUIRenderTestCase(unittest.TestCase): def setUp(self): self.controller = DeployController() self.utils_patcher = patch('conjureup.controllers.deploy.gui.utils') self.mock_utils = self.utils_patcher.start() self.bundleinfo_patcher = patch( 'conjureup.controllers.deploy.gui.get_bundleinfo') self.mock_get_bundleinfo = self.bundleinfo_patcher.start() self.mock_bundle = MagicMock(name="bundle") self.mock_bundle.machines = {"1": sentinel.machine_1} self.mock_service_1 = MagicMock(name="s1") self.mock_get_bundleinfo.return_value = ("filename", self.mock_bundle, [self.mock_service_1]) self.finish_patcher = patch( 'conjureup.controllers.deploy.gui.DeployController.finish') self.mock_finish = self.finish_patcher.start() self.submit_patcher = patch( 'conjureup.controllers.deploy.gui.async.submit') self.mock_submit = self.submit_patcher.start() self.predeploy_call = call(self.controller._pre_deploy_exec, ANY, queue_name=sentinel.JUJU_ASYNC_QUEUE) self.view_patcher = patch( 'conjureup.controllers.deploy.gui.ServiceWalkthroughView') self.view_patcher.start() self.app_patcher = patch('conjureup.controllers.deploy.gui.app') mock_app = self.app_patcher.start() mock_app.ui = MagicMock(name="app.ui") self.juju_patcher = patch('conjureup.controllers.deploy.gui.juju') self.mock_juju = self.juju_patcher.start() self.mock_juju.JUJU_ASYNC_QUEUE = sentinel.JUJU_ASYNC_QUEUE def tearDown(self): self.utils_patcher.stop() self.bundleinfo_patcher.stop() self.finish_patcher.stop() self.submit_patcher.stop() self.view_patcher.stop() self.app_patcher.stop() self.juju_patcher.stop() def test_queue_predeploy_skipping(self): "Do not enqueue predeploy more than once" self.controller.is_predeploy_queued = True self.controller.render() self.assertEqual(self.mock_submit.call_count, 0) def test_queue_predeploy_once(self): "Call submit to schedule predeploy if we haven't yet" self.controller.render() self.mock_submit.assert_has_calls([self.predeploy_call], any_order=True) def test_call_add_machines_once_only(self): "Call add_machines once" self.controller.render() self.mock_submit.assert_has_calls([self.predeploy_call], any_order=True) self.mock_submit.reset_mock() self.controller.is_predeploy_queued = True self.controller.render() self.assertEqual(self.mock_submit.call_count, 0) self.mock_juju.add_machines.assert_called_once_with( [sentinel.machine_1], exc_cb=ANY) def test_finish_at_end(self): "Call finish only at end" # the ServiceWalkthroughView will call finish() for the first # N-1 services if the user chooses to do so individually self.assertEqual(self.mock_finish.call_count, 0) self.controller.render() self.assertEqual(self.mock_finish.call_count, 0) self.controller.svc_idx += 1 self.controller.render() self.mock_finish.assert_called_once_with()
class DeployGUIRenderTestCase(unittest.TestCase): def setUp(self): self.controller = DeployController() self.utils_patcher = patch( 'conjureup.controllers.deploy.gui.utils') self.mock_utils = self.utils_patcher.start() self.bundleinfo_patcher = patch( 'conjureup.controllers.deploy.gui.get_bundleinfo') self.mock_get_bundleinfo = self.bundleinfo_patcher.start() self.mock_bundle = MagicMock(name="bundle") self.mock_bundle.machines = {"1": sentinel.machine_1} self.mock_service_1 = MagicMock(name="s1") self.mock_get_bundleinfo.return_value = ("filename", self.mock_bundle, [self.mock_service_1]) self.finish_patcher = patch( 'conjureup.controllers.deploy.gui.DeployController.finish') self.mock_finish = self.finish_patcher.start() self.submit_patcher = patch( 'conjureup.controllers.deploy.gui.async.submit') self.mock_submit = self.submit_patcher.start() self.predeploy_call = call(self.controller._pre_deploy_exec, ANY, queue_name=sentinel.JUJU_ASYNC_QUEUE) self.view_patcher = patch( 'conjureup.controllers.deploy.gui.ServiceWalkthroughView') self.view_patcher.start() self.app_patcher = patch( 'conjureup.controllers.deploy.gui.app') mock_app = self.app_patcher.start() mock_app.ui = MagicMock(name="app.ui") self.juju_patcher = patch( 'conjureup.controllers.deploy.gui.juju') self.mock_juju = self.juju_patcher.start() self.mock_juju.JUJU_ASYNC_QUEUE = sentinel.JUJU_ASYNC_QUEUE def tearDown(self): self.utils_patcher.stop() self.bundleinfo_patcher.stop() self.finish_patcher.stop() self.submit_patcher.stop() self.view_patcher.stop() self.app_patcher.stop() self.juju_patcher.stop() def test_queue_predeploy_skipping(self): "Do not enqueue predeploy more than once" self.controller.is_predeploy_queued = True self.controller.render() self.assertEqual(self.mock_submit.call_count, 0) def test_queue_predeploy_once(self): "Call submit to schedule predeploy if we haven't yet" self.controller.render() self.mock_submit.assert_has_calls([self.predeploy_call], any_order=True) def test_call_add_machines_once_only(self): "Call add_machines once" self.controller.render() self.mock_submit.assert_has_calls([self.predeploy_call], any_order=True) self.mock_submit.reset_mock() self.controller.is_predeploy_queued = True self.controller.render() self.assertEqual(self.mock_submit.call_count, 0) self.mock_juju.add_machines.assert_called_once_with( [sentinel.machine_1], exc_cb=ANY) def test_finish_at_end(self): "Call finish only at end" # the ServiceWalkthroughView will call finish() for the first # N-1 services if the user chooses to do so individually self.assertEqual(self.mock_finish.call_count, 0) self.controller.render() self.assertEqual(self.mock_finish.call_count, 0) self.controller.svc_idx += 1 self.controller.render() self.mock_finish.assert_called_once_with()