Пример #1
0
class CloudsTUIFinishTestCase(unittest.TestCase):
    def setUp(self):
        self.controller = CloudsController()

        self.controllers_patcher = patch(
            'conjureup.controllers.clouds.tui.controllers')
        self.mock_controllers = self.controllers_patcher.start()

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

        self.render_patcher = patch(
            'conjureup.controllers.clouds.tui.CloudsController.render')
        self.mock_render = self.render_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.mock_app.conjurefile = {}
        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()

        self.gcc_patcher = patch(
            'conjureup.controllers.clouds.tui.juju.get_controller_in_cloud')
        self.mock_gcc = self.gcc_patcher.start()

    def tearDown(self):
        self.controllers_patcher.stop()
        self.utils_patcher.stop()
        self.render_patcher.stop()
        self.app_patcher.stop()
        self.ev_app_patcher.stop()
        self.juju_patcher.stop()
        self.gcc_patcher.stop()

    def test_finish_w_model(self):
        "clouds.finish with an existing controller"
        self.mock_gcc.return_value = 'testcontroller'
        self.mock_app.conjurefile['model'] = 'testmodel'
        self.mock_app.provider.cloud = 'cloud'
        self.controller.finish()
        self.mock_controllers.use.assert_has_calls(
            [call('credentials'), call().render()])

    def test_finish_no_model(self):
        "clouds.finish without existing controller"
        self.mock_gcc.return_value = None
        self.mock_app.conjurefile['cloud'] = 'testcloud'
        self.mock_app.conjurefile['controller'] = None
        self.mock_app.conjurefile['model'] = None
        self.controller.finish()
        self.mock_controllers.use.assert_has_calls(
            [call('credentials'), call().render()])
Пример #2
0
class CloudsTUIFinishTestCase(unittest.TestCase):
    def setUp(self):
        self.controller = CloudsController()

        self.controllers_patcher = patch(
            'conjureup.controllers.clouds.tui.controllers')
        self.mock_controllers = self.controllers_patcher.start()

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

        self.render_patcher = patch(
            'conjureup.controllers.clouds.tui.CloudsController.render')
        self.mock_render = self.render_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()

        self.gcc_patcher = patch(
            'conjureup.controllers.clouds.tui.juju.get_controller_in_cloud')
        self.mock_gcc = self.gcc_patcher.start()

    def tearDown(self):
        self.controllers_patcher.stop()
        self.utils_patcher.stop()
        self.render_patcher.stop()
        self.app_patcher.stop()
        self.ev_app_patcher.stop()
        self.juju_patcher.stop()
        self.gcc_patcher.stop()

    def test_finish_w_controller(self):
        "clouds.finish with an existing controller"
        self.mock_gcc.return_value = 'testcontroller'
        self.mock_app.argv.controller = 'testcontroller'
        self.mock_app.current_cloud = 'cloud'
        self.controller.finish()
        self.mock_juju.assert_has_calls([
            call.add_model(ANY, 'testcontroller', 'cloud', allow_exists=True)
        ])

    def test_finish_no_controller(self):
        "clouds.finish without existing controller"
        self.mock_gcc.return_value = None
        self.mock_app.argv.cloud = 'testcloud'
        self.mock_app.argv.controller = None
        self.controller.finish()
        self.mock_controllers.use.assert_has_calls(
            [call('newcloud'), call().render()])
class CloudsTUIFinishTestCase(unittest.TestCase):

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

        self.controllers_patcher = patch(
            'conjureup.controllers.clouds.tui.controllers')
        self.mock_controllers = self.controllers_patcher.start()

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

        self.render_patcher = patch(
            'conjureup.controllers.clouds.tui.CloudsController.render')
        self.mock_render = self.render_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()

        self.gcc_patcher = patch(
            'conjureup.controllers.clouds.tui.juju.get_controller_in_cloud')
        self.mock_gcc = self.gcc_patcher.start()

    def tearDown(self):
        self.controllers_patcher.stop()
        self.utils_patcher.stop()
        self.render_patcher.stop()
        self.app_patcher.stop()
        self.juju_patcher.stop()
        self.gcc_patcher.stop()

    def test_finish_w_controller(self):
        "clouds.finish with an existing controller"
        self.mock_gcc.return_value = 'testcontroller'
        self.mock_app.argv.controller = None
        self.controller.finish()
        self.mock_juju.assert_has_calls([
            call.add_model(ANY, 'testcontroller')])

    def test_finish_no_controller(self):
        "clouds.finish without existing controller"
        self.mock_gcc.return_value = None
        self.mock_app.argv.cloud = 'testcloud'
        self.mock_app.argv.controller = None
        self.controller.finish()
        self.mock_controllers.use.assert_has_calls([
            call('newcloud'), call().render()])