Exemplo n.º 1
0
    def test_description_is_optional(self, status_get, wait_st):
        """Assert that if heat_template_version is omitted, it's added."""

        status_get.return_value = 'NOT_FOUND'
        wait_st.return_value = {}
        context = {constants.CTX_ENVIRONMENT: self.environment_mock}

        with helpers.contextual(context):
            hs = heat_stack.HeatStack('test-stack', None)
        hs._template = {'resources': {'test': 1}}
        hs._files = {}
        hs._hot_environment = ''
        hs._parameters = {}
        hs._applied = False
        hs.push()

        expected_template = {
            'heat_template_version': '2013-05-23',
            'resources': {'test': 1}
        }
        self.heat_client_mock.stacks.create.assert_called_with(
            stack_name='test-stack',
            disable_rollback=True,
            parameters={},
            template=expected_template,
            files={},
            environment=''
        )
        self.assertTrue(hs._applied)
Exemplo n.º 2
0
    def test_update_wrong_template_version(self, current):
        """Template version other than expected should cause error."""

        context = {constants.CTX_ENVIRONMENT: self.environment_mock}
        with helpers.contextual(context):
            hs = heat_stack.HeatStack(
                'test-stack', 'Generated by TestHeatStack')
        hs._template = {'resources': {'test': 1}}

        invalid_template = {
            'heat_template_version': 'something else'
        }

        current.return_value = {}

        e = self.assertRaises(heat_stack.HeatStackError,
                              hs.update_template,
                              invalid_template)
        err_msg = "Currently only heat_template_version 2013-05-23 "\
                  "is supported."
        self.assertEqual(err_msg, str(e))

        # Check it's ok without a version
        hs.update_template({})
        expected = {'resources': {'test': 1}}
        self.assertEqual(expected, hs._template)

        # .. or with a good version
        hs.update_template({'heat_template_version': '2013-05-23'})
        expected['heat_template_version'] = '2013-05-23'
        self.assertEqual(expected, hs._template)
Exemplo n.º 3
0
 def payload(__context, __receiver, *args, **kwargs):
     args = tuple(dsl.to_mutable(arg, engine) for arg in args)
     kwargs = dsl.to_mutable(kwargs, engine)
     with helpers.contextual(__context):
         __context[constants.CTX_NAMES_SCOPE] = murano_class
         result = helpers.evaluate(cls(*args, **kwargs), __context)
         __receiver.object.extension = result
Exemplo n.º 4
0
    def test_update_wrong_template_version(self, current):
        """Template version other than expected should cause error."""

        context = {constants.CTX_ENVIRONMENT: self.environment_mock}
        with helpers.contextual(context):
            hs = heat_stack.HeatStack('test-stack',
                                      'Generated by TestHeatStack')
        hs._template = {'resources': {'test': 1}}

        invalid_template = {'heat_template_version': 'something else'}

        current.return_value = {}

        e = self.assertRaises(heat_stack.HeatStackError, hs.update_template,
                              invalid_template)
        err_msg = "Currently only heat_template_version 2013-05-23 "\
                  "is supported."
        self.assertEqual(err_msg, str(e))

        # Check it's ok without a version
        hs.update_template({})
        expected = {'resources': {'test': 1}}
        self.assertEqual(expected, hs._template)

        # .. or with a good version
        hs.update_template({'heat_template_version': '2013-05-23'})
        expected['heat_template_version'] = '2013-05-23'
        self.assertEqual(expected, hs._template)
Exemplo n.º 5
0
    def test_description_is_optional(self, status_get, wait_st):
        """Assert that if heat_template_version is omitted, it's added."""

        status_get.return_value = 'NOT_FOUND'
        wait_st.return_value = {}
        context = {constants.CTX_ENVIRONMENT: self.environment_mock}

        with helpers.contextual(context):
            hs = heat_stack.HeatStack('test-stack', None)
        hs._template = {'resources': {'test': 1}}
        hs._files = {}
        hs._hot_environment = ''
        hs._parameters = {}
        hs._applied = False
        hs.push()

        expected_template = {
            'heat_template_version': '2013-05-23',
            'resources': {
                'test': 1
            }
        }
        self.heat_client_mock.stacks.create.assert_called_with(
            stack_name='test-stack',
            disable_rollback=True,
            parameters={},
            template=expected_template,
            files={},
            environment='')
        self.assertTrue(hs._applied)
Exemplo n.º 6
0
 def payload(__context, __receiver, *args, **kwargs):
     args = tuple(dsl.to_mutable(arg, engine) for arg in args)
     kwargs = dsl.to_mutable(kwargs, engine)
     with helpers.contextual(__context):
         __context[constants.CTX_NAMES_SCOPE] = \
             murano_class
         return helpers.evaluate(cls(*args, **kwargs), __context)
Exemplo n.º 7
0
 def test_listener_enabled(self):
     self.override_config('disable_murano_agent', False, 'engine')
     al = self.runner.testAgentListener().extension
     self.assertTrue(al.enabled)
     with self.runner.session(), helpers.contextual(self.context):
         try:
             al.subscribe('msgid', 'event')
             self.assertEqual({'msgid': 'event'}, al._subscriptions)
         finally:
             al.stop()
Exemplo n.º 8
0
 def test_listener_enabled(self):
     self.override_config('disable_murano_agent', False, 'engine')
     al = self.runner.testAgentListener().extension
     self.assertTrue(al.enabled)
     with helpers.contextual(self.context):
         try:
             al.subscribe('msgid', 'event')
             self.assertEqual({'msgid': 'event'}, al._subscriptions)
         finally:
             al.stop()
Exemplo n.º 9
0
 def payload(__context, *args, **kwargs):
     with helpers.contextual(__context):
         return body(*args, **kwargs)
Exemplo n.º 10
0
 def static_payload(__context, __receiver, *args, **kwargs):
     with helpers.contextual(__context):
         __context[constants.CTX_NAMES_SCOPE] = \
             murano_method.declaring_type
         return body(*args, **kwargs)
Exemplo n.º 11
0
 def payload(__context, __self, *args, **kwargs):
     with helpers.contextual(__context):
         __context[constants.CTX_NAMES_SCOPE] = \
             murano_method.declaring_type
         return body(__self.extension, *args, **kwargs)
Exemplo n.º 12
0
 def wrapper():
     with helpers.with_object_store(object_store):
         with helpers.contextual(context):
             return func(*args, **kwargs)
Exemplo n.º 13
0
 def payload(__context, __sender, *args, **kwargs):
     assert __sender is None
     args = tuple(dsl.to_mutable(arg, engine) for arg in args)
     kwargs = dsl.to_mutable(kwargs, engine)
     with helpers.contextual(__context):
         return helpers.evaluate(cls(*args, **kwargs), __context)
Exemplo n.º 14
0
 def payload(__context, *args, **kwargs):
     with helpers.contextual(__context):
         return body(*args, **kwargs)
Exemplo n.º 15
0
 def payload(__context, __sender, *args, **kwargs):
     assert __sender is None
     args = tuple(dsl.to_mutable(arg, engine) for arg in args)
     kwargs = dsl.to_mutable(kwargs, engine)
     with helpers.contextual(__context):
         return cls(*args, **kwargs)
Exemplo n.º 16
0
 def static_payload(__context, __receiver, *args, **kwargs):
     with helpers.contextual(__context):
         __context[constants.CTX_NAMES_SCOPE] = \
             murano_method.declaring_type
         return body(*args, **kwargs)
Exemplo n.º 17
0
 def payload(__context, __self, *args, **kwargs):
     with helpers.contextual(__context):
         __context[constants.CTX_NAMES_SCOPE] = \
             murano_method.declaring_type
         return body(__self.extension, *args, **kwargs)
Exemplo n.º 18
0
 def wrapper():
     with helpers.with_object_store(object_store):
         with helpers.contextual(context):
             return func(*args, **kwargs)