示例#1
0
class CloudsGUIFinishTestCase(unittest.TestCase):
    def setUp(self):
        self.controller = CloudsController()

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

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

        self.cloudname = 'testcloudname'

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

    def test_finish_no_controller(self):
        "clouds.finish without existing controller"
        self.controller.finish('testcloud')
        self.mock_controllers.use.assert_has_calls(
            [call('newcloud'), call().render('testcloud')])
class CloudsGUIFinishTestCase(unittest.TestCase):

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

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

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

        self.cloudname = 'testcloudname'

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

    def test_finish_no_controller(self):
        "clouds.finish without existing controller"
        self.controller.finish('testcloud')
        self.mock_controllers.use.assert_has_calls([
            call('newcloud'), call().render()])
class CloudsGUIFinishTestCase(unittest.TestCase):

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

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

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

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

        self.cloudname = 'testcloudname'
        self.juju_patcher = patch(
            'conjureup.controllers.clouds.gui.juju')
        self.mock_juju = self.juju_patcher.start()

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

        self.petname_patcher = patch(
            'conjureup.controllers.clouds.gui.petname')
        self.mock_petname = self.petname_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()
        self.mock_petname.stop()

    def test_finish_w_controller(self):
        "clouds.finish with an existing controller"
        self.mock_gcc.return_value = 'testcontroller'
        self.mock_petname.Name.return_value = 'moo'
        self.controller.finish('testcloud')
        self.mock_juju.add_model.assert_called_once_with('moo',
                                                         'testcontroller')

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

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

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

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

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

        self.cloudname = 'testcloudname'
        self.juju_patcher = patch(
            'conjureup.controllers.clouds.gui.juju')
        self.mock_juju = self.juju_patcher.start()

        self.gcc_patcher = patch(
            'conjureup.controllers.clouds.gui.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.controller.finish('testcloud')
        self.mock_juju.assert_has_calls([
            call.switch_controller('testcontroller')])

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

        self.controllers_patcher = patch(
            'conjureup.controllers.clouds.gui.controllers')
        self.mock_controllers = self.controllers_patcher.start()
        self.utils_patcher = patch('conjureup.controllers.clouds.gui.utils')
        self.mock_utils = self.utils_patcher.start()

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

        self.cloud_types_patcher = patch(
            'conjureup.juju.get_cloud_types_by_name')
        self.mock_cloud_types = self.cloud_types_patcher.start()
        self.mock_cloud_types.return_value = {'aws': 'ec2'}

        self.cloudname = 'testcloudname'

        self.track_event_patcher = patch(
            'conjureup.controllers.clouds.gui.track_event')
        self.mock_track_event = self.track_event_patcher.start()

        self.mock_provider = MagicMock()
        self.load_schema_patcher = patch(
            'conjureup.controllers.clouds.gui.load_schema', self.mock_provider)
        self.mock_load_schema = self.load_schema_patcher.start()

    def tearDown(self):
        self.controllers_patcher.stop()
        self.render_patcher.stop()
        self.app_patcher.stop()
        self.track_event_patcher.stop()
        self.utils_patcher.stop()
        self.load_schema_patcher.stop()

    def test_finish_no_controller(self):
        "clouds.finish without existing controller"
        self.mock_utils.gen_model.renturn_type = 'abacadaba'
        self.controller.finish('aws')
        self.mock_controllers.use.assert_has_calls(
            [call('credentials'), call().render()])