Exemple #1
0
class CloudsTUIRenderTestCase(unittest.TestCase):
    def setUp(self):
        self.controller = CloudsController()

        self.utils_patcher = patch('conjureup.controllers.clouds.tui.utils')
        self.mock_utils = self.utils_patcher.start()

        self.finish_patcher = patch(
            'conjureup.controllers.clouds.tui.CloudsController.finish')
        self.mock_finish = self.finish_patcher.start()

        self.app_patcher = patch('conjureup.controllers.clouds.tui.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.juju_patcher = patch('conjureup.controllers.clouds.tui.juju')
        self.mock_juju = self.juju_patcher.start()
        events.Shutdown.clear()

    def tearDown(self):
        self.utils_patcher.stop()
        self.finish_patcher.stop()
        self.app_patcher.stop()
        self.ev_app_patcher.stop()
        self.juju_patcher.stop()

    def test_render(self):
        "Rendering with a known cloud should call finish"
        self.mock_app.provider.cloud = "aws"
        t = ['aws']
        self.mock_juju.get_clouds.return_value.keys.return_value = t
        self.controller.render()
        self.mock_finish.assert_called_once_with()
class CloudsTUIRenderTestCase(unittest.TestCase):

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

        self.utils_patcher = patch(
            'conjureup.controllers.clouds.tui.utils')
        self.mock_utils = self.utils_patcher.start()

        self.finish_patcher = patch(
            'conjureup.controllers.clouds.tui.CloudsController.finish')
        self.mock_finish = self.finish_patcher.start()

        self.app_patcher = patch(
            'conjureup.controllers.clouds.tui.app')
        self.mock_app = self.app_patcher.start()
        self.mock_app.ui = MagicMock(name="app.ui")

        self.juju_patcher = patch(
            'conjureup.controllers.clouds.tui.juju')
        self.mock_juju = self.juju_patcher.start()

    def tearDown(self):
        self.utils_patcher.stop()
        self.finish_patcher.stop()
        self.app_patcher.stop()
        self.juju_patcher.stop()

    def test_render(self):
        "Rendering with a known cloud should call finish"
        self.mock_app.argv.cloud = "testcloud"
        t = ['testcloud']
        self.mock_juju.get_clouds.return_value.keys.return_value = t
        self.controller.render()
        self.mock_finish.assert_called_once_with()

    def test_render_unknown(self):
        "Rendering with an unknown cloud should raise"
        with self.assertRaises(SystemExit):
            self.controller.render()
Exemple #3
0
class CloudsTUIRenderTestCase(unittest.TestCase):

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

        self.utils_patcher = patch(
            'conjureup.controllers.clouds.tui.utils')
        self.mock_utils = self.utils_patcher.start()

        self.finish_patcher = patch(
            'conjureup.controllers.clouds.tui.CloudsController.finish')
        self.mock_finish = self.finish_patcher.start()

        self.app_patcher = patch(
            'conjureup.controllers.clouds.tui.app')
        self.mock_app = self.app_patcher.start()
        self.mock_app.ui = MagicMock(name="app.ui")

        self.juju_patcher = patch(
            'conjureup.controllers.clouds.tui.juju')
        self.mock_juju = self.juju_patcher.start()

    def tearDown(self):
        self.utils_patcher.stop()
        self.finish_patcher.stop()
        self.app_patcher.stop()
        self.juju_patcher.stop()

    def test_render(self):
        "Rendering with a known cloud should call finish"
        self.mock_app.argv.cloud = "testcloud"
        t = ['testcloud']
        self.mock_juju.get_clouds.return_value.keys.return_value = t
        self.controller.render()
        self.mock_finish.assert_called_once_with()

    def test_render_unknown(self):
        "Rendering with an unknown cloud should raise"
        with self.assertRaises(SystemExit):
            self.controller.render()