Exemple #1
0
    def test_allowed(self, mock_policy):
        expected_policy_rule = (("murano", "update_environment"),)

        update_name = tables.UpdateName()
        update_name.allowed(None, None, None)
        mock_policy.check.assert_called_once_with(
            expected_policy_rule, None)
Exemple #2
0
    def test_update_cell_except_exception(self, mock_api_utils,
                                          mock_exceptions):
        mock_api_utils.muranoclient().environments.update.side_effect =\
            Exception
        update_name = tables.UpdateName()

        result = update_name.update_cell(None, None, None, None, None)
        self.assertFalse(result)
        mock_exceptions.handle.assert_called_once_with(None, ignore=True)
Exemple #3
0
    def test_update_cell_except_value_error(self, mock_messages):
        expected_error_message = "The environment name field cannot be empty."
        update_name = tables.UpdateName()

        for cell_value in (None, ''):
            with self.assertRaisesRegexp(ValueError, expected_error_message):
                update_name.update_cell(None, None, None, None,
                                        new_cell_value=cell_value)
            mock_messages.warning.assert_called_once_with(
                None, expected_error_message)
            mock_messages.warning.reset_mock()
Exemple #4
0
    def test_update_cell(self, mock_api_utils):
        mock_api_utils.muranoclient().environments.update.side_effect = None
        mock_datum = mock.Mock(id='foo_datum_id')
        update_name = tables.UpdateName()
        cell_value = 'foo_cell_value'

        result = update_name.update_cell(None, mock_datum, None, None,
                                         new_cell_value=cell_value)
        self.assertTrue(result)
        mock_api_utils.muranoclient().environments.update.\
            assert_called_once_with('foo_datum_id', name='foo_cell_value')
Exemple #5
0
    def test_update_cell_except_http_conflict(self, mock_api_utils,
                                              mock_messages, mock_log):
        mock_api_utils.muranoclient().environments.update.side_effect =\
            exc.HTTPConflict
        mock_datum = mock.Mock(id='foo_datum_id')
        expected_error_message = "Couldn't update environment. "\
                                 "Reason: This name is already taken."
        update_name = tables.UpdateName()
        cell_value = 'foo_cell_value'

        with self.assertRaisesRegexp(ValueError, expected_error_message):
            update_name.update_cell(None, mock_datum, None, None,
                                    new_cell_value=cell_value)
        mock_api_utils.muranoclient().environments.update.\
            assert_called_once_with('foo_datum_id', name='foo_cell_value')
        mock_messages.warning.assert_called_once_with(
            None, expected_error_message)
        mock_log.warning.assert_called_once_with(expected_error_message)