Ejemplo n.º 1
0
class BootstrapwaitGUIFinishTestCase(unittest.TestCase):

    def setUp(self):
        self.controller = BootstrapWaitController()

        self.controllers_patcher = patch(
            'conjureup.controllers.bootstrapwait.gui.controllers')
        self.mock_controllers = self.controllers_patcher.start()

        self.render_patcher = patch(
            'conjureup.controllers.bootstrapwait.gui.'
            'BootstrapWaitController.render')
        self.mock_render = self.render_patcher.start()
        self.app_patcher = patch(
            'conjureup.controllers.bootstrapwait.gui.app')
        self.mock_app = self.app_patcher.start()
        self.mock_app.ui = MagicMock(name="app.ui")

    def tearDown(self):
        self.controllers_patcher.stop()
        self.render_patcher.stop()
        self.app_patcher.stop()

    def test_finish(self):
        "call finish"
        self.controller.finish()
Ejemplo n.º 2
0
class BootstrapwaitGUIFinishTestCase(unittest.TestCase):
    def setUp(self):
        self.controller = BootstrapWaitController()

        self.controllers_patcher = patch(
            'conjureup.controllers.bootstrapwait.gui.controllers')
        self.mock_controllers = self.controllers_patcher.start()

        self.render_patcher = patch('conjureup.controllers.bootstrapwait.gui.'
                                    'BootstrapWaitController.render')
        self.mock_render = self.render_patcher.start()
        self.app_patcher = patch('conjureup.controllers.bootstrapwait.gui.app')
        self.mock_app = self.app_patcher.start()
        self.mock_app.ui = MagicMock(name="app.ui")
        self.ev_app_patcher = patch('conjureup.events.app', self.mock_app)
        self.ev_app_patcher.start()

        self.asleep_patcher = patch('asyncio.sleep')
        self.mock_asleep = self.asleep_patcher.start()

    def tearDown(self):
        self.controllers_patcher.stop()
        self.render_patcher.stop()
        self.app_patcher.stop()
        self.ev_app_patcher.stop()
        self.asleep_patcher.stop()

    def test_refresh(self):
        "call refresh"

        async def set_bs():
            events.Bootstrapped.set()

        events.Bootstrapped.clear()
        self.mock_asleep.return_value = set_bs()
        mock_view = MagicMock()
        with test_loop() as loop:
            loop.run_until_complete(self.controller.refresh(mock_view))
        mock_view.redraw_kitt.assert_called_once_with()

    def test_finish(self):
        "call finish"
        events.Bootstrapped.set()
        with test_loop() as loop:
            loop.run_until_complete(self.controller.finish())
        self.mock_controllers.use.assert_called_once_with('deploystatus')