Beispiel #1
0
class TestCharmBase(unittest.TestCase):
    def setUp(self):
        self.mock_jujuclient = MagicMock(name='jujuclient')
        self.mock_juju_state = MagicMock(name='juju_state')
        self.mock_ui = MagicMock(name='ui')
        self.mock_config = MagicMock(name='config')

        self.get_config_patcher = patch('cloudinstall.charms.get_charm_config')
        self.mock_get_config = self.get_config_patcher.start()
        self.mock_get_config.return_value = ({}, None)

        self.charm = CharmBase(juju=self.mock_jujuclient,
                               juju_state=self.mock_juju_state,
                               ui=self.mock_ui,
                               config=self.mock_config)

    def tearDown(self):
        self.get_config_patcher.stop()

    def test_subordinate_deploy_success(self):
        self.charm.subordinate = True
        self.charm.charm_name = 'fake'
        self.charm.deploy('fake mspec')
        self.mock_jujuclient.deploy.assert_called_with('fake', 'fake', 0, ANY,
                                                       None, None)
class TestCharmBase(unittest.TestCase):

    def setUp(self):
        self.mock_jujuclient = MagicMock(name='jujuclient')
        self.mock_juju_state = MagicMock(name='juju_state')
        self.mock_ui = MagicMock(name='ui')
        self.mock_config = MagicMock(name='config')

        self.get_config_patcher = patch('cloudinstall.charms.get_charm_config')
        self.mock_get_config = self.get_config_patcher.start()
        self.mock_get_config.return_value = ({}, None)

        self.charm = CharmBase(juju=self.mock_jujuclient,
                               juju_state=self.mock_juju_state,
                               ui=self.mock_ui,
                               config=self.mock_config)

    def tearDown(self):
        self.get_config_patcher.stop()

    def test_subordinate_deploy_success(self):
        self.mock_config.getopt.return_value = False
        self.charm.subordinate = True
        self.charm.charm_name = 'fake'
        self.charm.deploy('fake mspec')
        self.mock_jujuclient.deploy.assert_called_with('fake', 'fake',
                                                       0, ANY, None,
                                                       None)
class TestCharmBase(unittest.TestCase):
    def setUp(self):
        self.mock_jujuclient = MagicMock(name='jujuclient')
        self.mock_juju_state = MagicMock(name='juju_state')
        self.mock_ui = MagicMock(name='ui')
        self.mock_config = MagicMock(name='config')

        self.get_config_patcher = patch('cloudinstall.charms.get_charm_config')
        self.mock_get_config = self.get_config_patcher.start()
        self.mock_get_config.return_value = ({}, None)

        self.charm = CharmBase(juju=self.mock_jujuclient,
                               juju_state=self.mock_juju_state,
                               ui=self.mock_ui,
                               config=self.mock_config)

    def tearDown(self):
        self.get_config_patcher.stop()

    def test_subordinate_deploy_success(self):
        self.mock_config.getopt.return_value = False
        self.charm.subordinate = True
        self.charm.charm_name = 'fake'
        self.charm.available_sources = ['charmstore']
        self.charm.deploy('fake mspec')
        self.mock_jujuclient.deploy.assert_called_with('fake', 'fake', 0, ANY,
                                                       None, None)

    def test_no_available_sources(self):
        """ Exception raised when no available sources defined
        """
        self.mock_config.getopt.return_value = False
        self.charm.charm_name = 'fake'
        self.charm.available_sources = []
        self.assertRaises(Exception, self.charm.deploy)
class TestCharmBase(unittest.TestCase):

    def setUp(self):
        self.mock_jujuclient = MagicMock(name='jujuclient')
        self.mock_juju_state = MagicMock(name='juju_state')
        self.mock_ui = MagicMock(name='ui')
        self.mock_config = MagicMock(name='config')

        self.get_config_patcher = patch('cloudinstall.charms.get_charm_config')
        self.mock_get_config = self.get_config_patcher.start()
        self.mock_get_config.return_value = ({}, None)

        self.charm = CharmBase(juju=self.mock_jujuclient,
                               juju_state=self.mock_juju_state,
                               ui=self.mock_ui,
                               config=self.mock_config)

    def tearDown(self):
        self.get_config_patcher.stop()

    def test_subordinate_deploy_success(self):
        self.mock_config.getopt.return_value = False
        self.charm.subordinate = True
        self.charm.charm_name = 'fake'
        self.charm.available_sources = ['charmstore']
        self.charm.deploy('fake mspec')
        self.mock_jujuclient.deploy.assert_called_with('fake', 'fake',
                                                       0, ANY, None,
                                                       None)

    def test_no_available_sources(self):
        """ Exception raised when no available sources defined
        """
        self.mock_config.getopt.return_value = False
        self.charm.charm_name = 'fake'
        self.charm.available_sources = []
        self.assertRaises(Exception, self.charm.deploy)