OpenStack Orchestration (Heat)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

61 lines
2.1 KiB

  1. #
  2. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  3. # not use this file except in compliance with the License. You may obtain
  4. # a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software
  9. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  10. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  11. # License for the specific language governing permissions and limitations
  12. # under the License.
  13. import uuid
  14. import yaml
  15. import mock
  16. from heat.engine import stack
  17. from heat.engine import template
  18. from heat.tests import common
  19. from heat.tests import utils
  20. class CloudConfigTest(common.HeatTestCase):
  21. def setUp(self):
  22. super(CloudConfigTest, self).setUp()
  23. self.ctx = utils.dummy_context()
  24. self.properties = {
  25. 'cloud_config': {'foo': 'bar'}
  26. }
  27. self.stack = stack.Stack(
  28. self.ctx, 'software_config_test_stack',
  29. template.Template({
  30. 'HeatTemplateFormatVersion': '2012-12-12',
  31. 'Resources': {
  32. 'config_mysql': {
  33. 'Type': 'OS::Heat::CloudConfig',
  34. 'Properties': self.properties
  35. }}}))
  36. self.config = self.stack['config_mysql']
  37. self.rpc_client = mock.MagicMock()
  38. self.config._rpc_client = self.rpc_client
  39. def test_handle_create(self):
  40. config_id = 'c8a19429-7fde-47ea-a42f-40045488226c'
  41. value = {'id': config_id}
  42. self.rpc_client.create_software_config.return_value = value
  43. self.config.id = 5
  44. self.config.uuid = uuid.uuid4().hex
  45. self.config.handle_create()
  46. self.assertEqual(config_id, self.config.resource_id)
  47. kwargs = self.rpc_client.create_software_config.call_args[1]
  48. self.assertEqual({
  49. 'name': self.config.physical_resource_name(),
  50. 'config': '\n'.join(['#cloud-config',
  51. yaml.safe_dump({'foo': 'bar'})]),
  52. 'group': 'Heat::Ungrouped'
  53. }, kwargs)